Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 542fb340 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Browser: Enable webGL by default

parent 455c4943
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
From 1a021fdb9f112dafddedac59dfe755dadf641afe Mon Sep 17 00:00:00 2001
From: althafvly <althafvly@gmail.com>
Date: Tue, 24 Oct 2023 14:39:06 +0530
Subject: [PATCH] Browser: Enable webgl by default

---
 .../core/browser/bromite_content_settings/webgl.inc           | 2 +-
 .../renderer/core/execution_context/execution_context.cc      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/components/content_settings/core/browser/bromite_content_settings/webgl.inc b/components/content_settings/core/browser/bromite_content_settings/webgl.inc
index 3ff01832baef4..dd88ffeab7bbb 100644
--- a/components/content_settings/core/browser/bromite_content_settings/webgl.inc
+++ b/components/content_settings/core/browser/bromite_content_settings/webgl.inc
@@ -1,4 +1,4 @@
-  Register(ContentSettingsType::WEBGL, "webgl", CONTENT_SETTING_BLOCK,
+  Register(ContentSettingsType::WEBGL, "webgl", CONTENT_SETTING_ALLOW,
            WebsiteSettingsInfo::SYNCABLE,
            /*allowlisted_schemes=*/{},
            /*valid_settings=*/{CONTENT_SETTING_ALLOW,
diff --git a/third_party/blink/renderer/core/execution_context/execution_context.cc b/third_party/blink/renderer/core/execution_context/execution_context.cc
index 1bc4805ab9da9..e021859af960d 100644
--- a/third_party/blink/renderer/core/execution_context/execution_context.cc
+++ b/third_party/blink/renderer/core/execution_context/execution_context.cc
@@ -87,8 +87,8 @@ blink::WebContentSettingsClient* GetContentSettingsClientFor(
 bool AllowWebgl(ExecutionContext* context) {
   blink::WebContentSettingsClient* settings = GetContentSettingsClientFor(context);
   if (settings)
-    return settings->AllowContentSetting(ContentSettingsType::WEBGL, false);
-  return false;
+    return settings->AllowContentSetting(ContentSettingsType::WEBGL, true);
+  return true;
 }
 
 ExecutionContext::ExecutionContext(v8::Isolate* isolate,
-- 
2.34.1
+0 −291
Original line number Diff line number Diff line
From 71dbcf8989c5228d9078676c75c77186de48c935 Mon Sep 17 00:00:00 2001
From: althafvly <althafvly@gmail.com>
Date: Tue, 19 Sep 2023 13:34:49 +0530
Subject: [PATCH 30/35] Revert "Add webGL site setting"

This reverts commit 94d605389f12260a10d1d270491907c8788b3bd2.
---
 .../impl/BromiteWebGLContentSetting.java      | 92 -------------------
 .../bromite_content_settings/webgl.grdp       | 27 ------
 .../bromite_content_settings/webgl.inc        | 22 -----
 .../common/bromite_content_settings/WEBGL.inc |  1 -
 .../execution_context/execution_context.cc    |  7 --
 .../execution_context/execution_context.h     |  2 -
 .../webgl/webgl_rendering_context_base.cc     | 32 ++++---
 .../webgl/webgl_rendering_context_base.h      |  2 -
 8 files changed, 19 insertions(+), 166 deletions(-)
 delete mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java
 delete mode 100644 components/browser_ui/strings/bromite_content_settings/webgl.grdp
 delete mode 100644 components/content_settings/core/browser/bromite_content_settings/webgl.inc
 delete mode 100644 components/content_settings/core/common/bromite_content_settings/WEBGL.inc

diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java
deleted file mode 100644
index f7bb6433b714d..0000000000000
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteWebGLContentSetting.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-    This file is part of Bromite.
-
-    Bromite is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    Bromite is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with Bromite. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-package org.chromium.components.browser_ui.site_settings.impl;
-
-import org.chromium.components.browser_ui.site_settings.R;
-
-import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting;
-import org.chromium.components.browser_ui.site_settings.ContentSettingsResources;
-import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory;
-import org.chromium.components.content_settings.ContentSettingValues;
-import org.chromium.components.content_settings.ContentSettingsType;
-import org.chromium.content_public.browser.BrowserContextHandle;
-
-import androidx.annotation.Nullable;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import java.util.ArrayList;
-
-public class BromiteWebGLContentSetting extends BromiteCustomContentSetting {
-    public BromiteWebGLContentSetting() {
-        super(/*contentSettingsType*/ ContentSettingsType.WEBGL,
-              /*defaultEnabledValue*/ ContentSettingValues.ALLOW,
-              /*defaultDisabledValue*/ ContentSettingValues.BLOCK,
-              /*allowException*/ true,
-              /*preferenceKey*/ "webgl",
-              /*profilePrefKey*/ "webgl");
-    }
-
-    @Override
-    public ContentSettingsResources.ResourceItem getResourceItem() {
-        return new ContentSettingsResources.ResourceItem(
-            /*icon*/ R.drawable.web_asset,
-            /*title*/ R.string.webgl_permission_title,
-            /*defaultEnabledValue*/ getDefaultEnabledValue(),
-            /*defaultDisabledValue*/ getDefaultDisabledValue(),
-            /*enabledSummary*/ R.string.website_settings_category_webgl_enabled,
-            /*disabledSummary*/ R.string.website_settings_category_webgl_disabled);
-    }
-
-    @Override
-    public int getCategorySummary(@Nullable @ContentSettingValues int value) {
-        switch (value) {
-            case ContentSettingValues.ALLOW:
-                return R.string.website_settings_category_webgl_enabled;
-            case ContentSettingValues.BLOCK:
-                return R.string.website_settings_category_webgl_disabled;
-            default:
-                return 0;
-        }
-    }
-
-    @Override
-    public int getCategoryDescription() {
-        return R.string.settings_site_settings_webgl_description;
-    }
-
-    @Override
-    public boolean requiresTriStateContentSetting() {
-        return false;
-    }
-
-    @Override
-    public boolean showOnlyDescriptions() {
-        return true;
-    }
-
-    @Override
-    public int getAddExceptionDialogMessage() {
-        return R.string.website_settings_category_webgl_enabled;
-    }
-
-    @Override
-    public @Nullable Boolean considerException(SiteSettingsCategory category, @ContentSettingValues int value) {
-        return value != ContentSettingValues.BLOCK;
-    }
-}
diff --git a/components/browser_ui/strings/bromite_content_settings/webgl.grdp b/components/browser_ui/strings/bromite_content_settings/webgl.grdp
deleted file mode 100644
index 53635991ed294..0000000000000
--- a/components/browser_ui/strings/bromite_content_settings/webgl.grdp
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<grit-part>
-  <message name="IDS_SITE_SETTINGS_TYPE_WEBGL" desc="The label used for webgl site settings controls." formatter_data="android_java">
-    Webgl
-  </message>
-  <message name="IDS_SETTINGS_SITE_SETTINGS_WEBGL_DESCRIPTION" desc="Description of the webgl content setting." formatter_data="android_java">
-    Enable Webgl, a JavaScript API for rendering high-performance interactive 3D and 2D graphics
-  </message>
-  <message name="IDS_SITE_SETTINGS_TYPE_WEBGL_MID_SENTENCE" desc="The label used for webgl site settings controls when used mid-sentence." formatter_data="android_java">
-    webgl
-  </message>
-  <message name="IDS_WEBGL_PERMISSION_TITLE" desc="Title of the permission to use webgl [CHAR-LIMIT=32]" formatter_data="android_java">
-    Webgl
-  </message>
-  <message name="IDS_WEBSITE_SETTINGS_CATEGORY_WEBGL_ENABLED" desc="Summary text explaining that webgl is full enabled." formatter_data="android_java">
-    Enabled
-  </message>
-  <message name="IDS_WEBSITE_SETTINGS_CATEGORY_WEBGL_DISABLED" desc="Summary text explaining that webgl is full disabled." formatter_data="android_java">
-    Disabled
-  </message>
-  <message name="IDS_SETTINGS_SITE_SETTINGS_WEBGL_ALLOWED_EXCEPTIONS" desc="Label for the allowed exceptions site list of the webgl setting.">
-    Allowed to use webgl
-  </message>
-  <message name="IDS_SETTINGS_SITE_SETTINGS_WEBGL_BLOCKED_EXCEPTIONS" desc="Label for the blocked exceptions site list of the webgl setting.">
-    Not allowed to use webgl
-  </message>
-</grit-part>
diff --git a/components/content_settings/core/browser/bromite_content_settings/webgl.inc b/components/content_settings/core/browser/bromite_content_settings/webgl.inc
deleted file mode 100644
index 3ff01832baef4..0000000000000
--- a/components/content_settings/core/browser/bromite_content_settings/webgl.inc
+++ /dev/null
@@ -1,22 +0,0 @@
-  Register(ContentSettingsType::WEBGL, "webgl", CONTENT_SETTING_BLOCK,
-           WebsiteSettingsInfo::SYNCABLE,
-           /*allowlisted_schemes=*/{},
-           /*valid_settings=*/{CONTENT_SETTING_ALLOW,
-                               CONTENT_SETTING_BLOCK},
-           WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE,
-           WebsiteSettingsRegistry::ALL_PLATFORMS,
-           ContentSettingsInfo::INHERIT_IN_INCOGNITO,
-           ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS);
-
-  content_settings::WebsiteSettingsRegistry::GetInstance()
-    ->GetMutable(ContentSettingsType::WEBGL)
-    ->set_show_into_info_page()
-    .set_desktop_ui()
-    .set_is_renderer_content_setting()
-    .set_title_ui(IDS_SITE_SETTINGS_TYPE_WEBGL)
-    .set_description_ui(IDS_SETTINGS_SITE_SETTINGS_WEBGL_DESCRIPTION)
-    .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_WEBGL_ENABLED)
-    .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_WEBGL_DISABLED)
-    .set_allowed_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_WEBGL_ALLOWED_EXCEPTIONS)
-    .set_blocked_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_WEBGL_BLOCKED_EXCEPTIONS)
-    .set_mid_sentence_ui(IDS_SITE_SETTINGS_TYPE_WEBGL);
diff --git a/components/content_settings/core/common/bromite_content_settings/WEBGL.inc b/components/content_settings/core/common/bromite_content_settings/WEBGL.inc
deleted file mode 100644
index 30dc2ff2d125f..0000000000000
--- a/components/content_settings/core/common/bromite_content_settings/WEBGL.inc
+++ /dev/null
@@ -1 +0,0 @@
-  WEBGL,
diff --git a/third_party/blink/renderer/core/execution_context/execution_context.cc b/third_party/blink/renderer/core/execution_context/execution_context.cc
index 1bc4805ab9da9..d6208255ef5e8 100644
--- a/third_party/blink/renderer/core/execution_context/execution_context.cc
+++ b/third_party/blink/renderer/core/execution_context/execution_context.cc
@@ -84,13 +84,6 @@ blink::WebContentSettingsClient* GetContentSettingsClientFor(
   return settings;
 }
 
-bool AllowWebgl(ExecutionContext* context) {
-  blink::WebContentSettingsClient* settings = GetContentSettingsClientFor(context);
-  if (settings)
-    return settings->AllowContentSetting(ContentSettingsType::WEBGL, false);
-  return false;
-}
-
 ExecutionContext::ExecutionContext(v8::Isolate* isolate,
                                    Agent* agent,
                                    bool is_window)
diff --git a/third_party/blink/renderer/core/execution_context/execution_context.h b/third_party/blink/renderer/core/execution_context/execution_context.h
index 180cda4e10fc4..580f56a58cf74 100644
--- a/third_party/blink/renderer/core/execution_context/execution_context.h
+++ b/third_party/blink/renderer/core/execution_context/execution_context.h
@@ -116,8 +116,6 @@ enum ReasonForCallingCanExecuteScripts {
 
 enum ReferrerPolicySource { kPolicySourceHttpHeader, kPolicySourceMetaTag };
 
-CORE_EXPORT bool AllowWebgl(ExecutionContext* context);
-
 // An environment in which script can execute. This class exposes the common
 // properties of script execution environments on the web (i.e, common between
 // script executing in a window and script executing in a worker), such as:
diff --git a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
index 8783d3560f727..74a289a88a953 100644
--- a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
+++ b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
@@ -248,13 +248,6 @@ void WebGLRenderingContextBase::InitializeWebGLContextLimits(
   }
 }
 
-bool WebGLRenderingContextBase::AllowWebglForHost(blink::CanvasRenderingContextHost* host) {
-  if (!host)
-    return false;
-  blink::ExecutionContext* context = host->GetTopExecutionContext();
-  return blink::AllowWebgl(context);
-}
-
 unsigned WebGLRenderingContextBase::CurrentMaxGLContexts() {
   base::AutoLock locker(WebGLContextLimitLock());
   DCHECK(webgl_context_limits_initialized_);
@@ -528,6 +521,25 @@ static String ExtractWebGLContextCreationError(
     const Platform::GraphicsInfo& info) {
   StringBuilder builder;
   builder.Append("Could not create a WebGL context");
+  FormatWebGLStatusString(
+      "VENDOR",
+      info.vendor_id ? String::Format("0x%04x", info.vendor_id) : "0xffff",
+      builder);
+  FormatWebGLStatusString(
+      "DEVICE",
+      info.device_id ? String::Format("0x%04x", info.device_id) : "0xffff",
+      builder);
+  FormatWebGLStatusString("GL_VENDOR", info.vendor_info, builder);
+  FormatWebGLStatusString("GL_RENDERER", info.renderer_info, builder);
+  FormatWebGLStatusString("GL_VERSION", info.driver_version, builder);
+  FormatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", builder);
+  FormatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", builder);
+  FormatWebGLStatusString("AMD switchable", info.amd_switchable ? "yes" : "no",
+                          builder);
+  FormatWebGLStatusString(
+      "Reset notification strategy",
+      String::Format("0x%04x", info.reset_notification_strategy).Utf8().c_str(),
+      builder);
   FormatWebGLStatusString("ErrorMessage", info.error_message.Utf8().c_str(),
                           builder);
   builder.Append('.');
@@ -587,12 +599,6 @@ WebGLRenderingContextBase::CreateWebGraphicsContext3DProvider(
     const CanvasContextCreationAttributesCore& attributes,
     Platform::ContextType context_type,
     Platform::GraphicsInfo* graphics_info) {
-  if (!AllowWebglForHost(host)) {
-    host->HostDispatchEvent(WebGLContextEvent::Create(
-        event_type_names::kWebglcontextcreationerror,
-        "disabled by site settings policy."));
-    return nullptr;
-  }
   if ((context_type == Platform::kWebGL1ContextType &&
        !host->IsWebGL1Enabled()) ||
       (context_type == Platform::kWebGL2ContextType &&
diff --git a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h
index 58a3066ac23a1..2261611fdd586 100644
--- a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h
+++ b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.h
@@ -1936,8 +1936,6 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
                         DOMArrayBufferView* pixels,
                         int64_t offset);
 
-  static bool AllowWebglForHost(blink::CanvasRenderingContextHost* host);
-
   // Record Canvas/OffscreenCanvas.RenderingContextDrawnTo at the first draw
   // call.
   void RecordUKMCanvasDrawnToAtFirstDrawCall();
-- 
2.34.1
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@
0027-Browser-Replace-default-tab-favicon.patch
0028-Browser-Spoof-as-Pixel-4a-by-default.patch
0029-Revert-Guard-for-user-agent-reduction.patch
0030-Revert-Add-webGL-site-setting.patch
0031-Browser-Remove-broken-link-about-entries.patch
0032-Revert-Remove-navigator.connection-info.patch
0033-Browser-Disable-Android-native-autofill-by-default.patch
@@ -58,3 +57,4 @@
0001-Browser-Remove-send-to-devices-option.patch
0001-Browser-Enable-webRTC-by-default.patch
0001-Browser-fix-help-icon-crash.patch
0001-Browser-Enable-webgl-by-default.patch