Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Runtime enablement of WebGL

Add Labs setting for enabling and disabling WebGL. Need to make sure
WebGL has been compiled in before showing runtime enablement settings in
Labs menu. Requesting information from the native side through JNI.

Change-Id: I50e9321babaaf039e25e30f7ead6527169d32e1b
  • Loading branch information...
commit 150ec13fec79c7218cfeea6e00129c21b88f5dd5 1 parent e794ad2
@plafayet plafayet authored Whitehawkx committed
View
16 res/values/strings.xml
@@ -5,9 +5,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -174,7 +174,7 @@
<string name="bookmark_cannot_save_url">This URL can\'t be bookmarked.</string>
<!-- Menu item in the page that displays all bookmarks. It brings up a
dialog that allows the user to bookmark the page that the browser is
- currently on, but is not visible because the bookmarks page is
+ currently on, but is not visible because the bookmarks page is
showing. -->
<string name="bookmark_page">Bookmark last-viewed page</string>
<!-- Menu item in the page that displays all bookmarks. Switches to
@@ -270,7 +270,7 @@
<!-- Context Menu item to show the currently selected address in the Maps
application -->
<string name="contextmenu_map">Map</string>
-
+
<!-- Title of the dialog used for selecting the application that should be
used for sharing a link (e.g. Gmail or another app). See also
contextmenu_sharelink above -->
@@ -651,6 +651,10 @@
<!-- Summary for the fullscreen lab feature [CHAR LIMIT=120] -->
<string name="pref_lab_fullscreen_summary">
Use fullscreen mode to hide the status bar</string>
+ <!-- Title for the WebGL feature [CHAR LIMIT=40] -->
+ <string name="pref_lab_webgl">WebGL</string>
+ <!-- Summary for the WebGL lab feature [CHAR LIMIT=120] -->
+ <string name="pref_lab_webgl_summary">Enables WebGL</string>
<!-- Title for bandwidth management preference [CHAR LIMIT=25] -->
<string name="pref_data_title">Bandwidth management</string>
<!-- Title for search preloading [CHAR LIMIT=40] -->
@@ -747,7 +751,7 @@
<!-- Verb placed in front of a screenshot of a web page that, when clicked,
will add that page to bookmarks -->
<string name="add_bookmark_short">Add</string>
-
+
<!-- This string is for the browser "Go To" UI. -->
<!-- Do not translate. This string is not displayed in UI (no badge is selected for go to). -->
<string name="search_label" translatable="false">Browser</string>
@@ -867,7 +871,7 @@
<string name="webstorage_outofspace_notification_text">Touch to free up space.</string>
<!-- Used in the Browser Settings -->
<string name="webstorage_clear_data_title">Clear stored data</string>
-
+
<!-- Confirmation dialog when the user ask to clear all data for an origin -->
<string name="webstorage_clear_data_dialog_message">Delete all data stored by this website?</string>
<string name="webstorage_clear_data_dialog_ok_button">OK</string>
View
5 res/xml-sw600dp/lab_preferences.xml
@@ -21,4 +21,9 @@
android:defaultValue="false"
android:title="@string/pref_lab_quick_controls"
android:summary="@string/pref_lab_quick_controls_summary" />
+ <CheckBoxPreference
+ android:key="enable_webgl"
+ android:defaultValue="true"
+ android:title="@string/pref_lab_webgl"
+ android:summary="@string/pref_lab_webgl_summary" />
</PreferenceScreen>
View
5 res/xml/lab_preferences.xml
@@ -26,4 +26,9 @@
android:defaultValue="false"
android:title="@string/pref_lab_fullscreen"
android:summary="@string/pref_lab_fullscreen_summary" />
+ <CheckBoxPreference
+ android:key="enable_webgl"
+ android:defaultValue="true"
+ android:title="@string/pref_lab_webgl"
+ android:summary="@string/pref_lab_webgl_summary" />
</PreferenceScreen>
View
16 src/com/android/browser/BrowserSettings.java
@@ -130,6 +130,8 @@
private static String sFactoryResetUrl;
+ private static boolean sWebGLAvailable;
+
public static void initialize(final Context context) {
sInstance = new BrowserSettings(context);
}
@@ -276,6 +278,8 @@ private void syncSetting(WebSettingsClassic settings) {
settings.setSaveFormData(saveFormdata());
settings.setUseWideViewPort(isWideViewport());
settings.setAutoFillProfile(getAutoFillProfile());
+ setIsWebGLAvailable(settings.isWebGLAvailable());
+ settings.setWebGLEnabled(isWebGLAvailable() && isWebGLEnabled());
String ua = mCustomUserAgents.get(settings);
if (ua != null) {
@@ -837,6 +841,10 @@ public float getInvertedContrast() {
return 1 + (mPrefs.getInt(PREF_INVERTED_CONTRAST, 0) / 10f);
}
+ public boolean isWebGLEnabled() {
+ return mPrefs.getBoolean(PREF_ENABLE_WEBGL, true);
+ }
+
// -----------------------------
// getter/setters for privacy_security_preferences.xml
// -----------------------------
@@ -929,6 +937,14 @@ public String getVideoPreloadEnabled() {
return mPrefs.getString(PREF_VIDEO_PRELOAD, getDefaultVideoPreloadSetting());
}
+ private static void setIsWebGLAvailable(boolean available) {
+ sWebGLAvailable = available;
+ }
+
+ public static boolean isWebGLAvailable() {
+ return sWebGLAvailable;
+ }
+
// -----------------------------
// getter/setters for browser recovery
// -----------------------------
View
1  src/com/android/browser/PreferenceKeys.java
@@ -84,6 +84,7 @@
// ----------------------
static final String PREF_ENABLE_QUICK_CONTROLS = "enable_quick_controls";
static final String PREF_FULLSCREEN = "fullscreen";
+ static final String PREF_ENABLE_WEBGL = "enable_webgl";
// ----------------------
// Keys for privacy_security_preferences.xml
View
9 src/com/android/browser/preferences/LabPreferencesFragment.java
@@ -17,8 +17,10 @@
package com.android.browser.preferences;
import android.os.Bundle;
+import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
import com.android.browser.BrowserSettings;
import com.android.browser.PreferenceKeys;
@@ -32,5 +34,12 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the XML preferences file
addPreferencesFromResource(R.xml.lab_preferences);
+
+ if (!BrowserSettings.isWebGLAvailable()) {
+ CheckBoxPreference webGL = (CheckBoxPreference)
+ findPreference(PreferenceKeys.PREF_ENABLE_WEBGL);
+ PreferenceScreen screen = getPreferenceScreen();
+ screen.removePreference(webGL);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.