summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Antoine LaFayette <plafayet@codeaurora.org>2012-03-02 16:56:50 -0500
committerSteve Kondik <shade@chemlab.org>2013-01-20 18:36:32 -0800
commit08fab3352a7cee93121b58ce7b4b2807314dd141 (patch)
treee405dbfcb264a1ad2328579815c09a06e2ce90eb
parent2e5518fe20adbe127e86c9e0d18eb32277d6afeb (diff)
downloadpackages_apps_browser-08fab3352a7cee93121b58ce7b4b2807314dd141.zip
packages_apps_browser-08fab3352a7cee93121b58ce7b4b2807314dd141.tar.gz
packages_apps_browser-08fab3352a7cee93121b58ce7b4b2807314dd141.tar.bz2
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. (cherry-picked commit from a2f7564cd95da42fad70e3c54497df7e7e8b1ea9) Change-Id: Ie11bfa69941c2d75cfec04132908e07391c602fd
-rw-r--r--res/values/strings.xml16
-rw-r--r--res/xml-sw600dp/lab_preferences.xml5
-rw-r--r--res/xml/lab_preferences.xml5
-rw-r--r--src/com/android/browser/BrowserSettings.java16
-rw-r--r--src/com/android/browser/PreferenceKeys.java1
-rw-r--r--src/com/android/browser/preferences/LabPreferencesFragment.java9
6 files changed, 46 insertions, 6 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 411aefb..68839fe 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4,9 +4,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.
@@ -173,7 +173,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
@@ -269,7 +269,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 -->
@@ -653,6 +653,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] -->
@@ -727,7 +731,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>
@@ -847,7 +851,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>
diff --git a/res/xml-sw600dp/lab_preferences.xml b/res/xml-sw600dp/lab_preferences.xml
index a7151e0..95cacb0 100644
--- a/res/xml-sw600dp/lab_preferences.xml
+++ b/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>
diff --git a/res/xml/lab_preferences.xml b/res/xml/lab_preferences.xml
index 3320cee..8fca4c7 100644
--- a/res/xml/lab_preferences.xml
+++ b/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>
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 4073f1c..8ed824e 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -129,6 +129,8 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener,
private static String sFactoryResetUrl;
+ private static boolean sWebGLAvailable;
+
public static void initialize(final Context context) {
sInstance = new BrowserSettings(context);
}
@@ -275,6 +277,8 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener,
settings.setSaveFormData(saveFormdata());
settings.setUseWideViewPort(isWideViewport());
settings.setAutoFillProfile(getAutoFillProfile());
+ setIsWebGLAvailable(settings.isWebGLAvailable());
+ settings.setWebGLEnabled(isWebGLAvailable() && isWebGLEnabled());
String ua = mCustomUserAgents.get(settings);
if (ua != null) {
@@ -841,6 +845,10 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener,
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
// -----------------------------
@@ -917,6 +925,14 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener,
return mPrefs.getString(PREF_LINK_PREFETCH, getDefaultLinkPrefetchSetting());
}
+ private static void setIsWebGLAvailable(boolean available) {
+ sWebGLAvailable = available;
+ }
+
+ public static boolean isWebGLAvailable() {
+ return sWebGLAvailable;
+ }
+
// -----------------------------
// getter/setters for browser recovery
// -----------------------------
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index 1828032..2de1073 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -83,6 +83,7 @@ public interface PreferenceKeys {
// ----------------------
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
diff --git a/src/com/android/browser/preferences/LabPreferencesFragment.java b/src/com/android/browser/preferences/LabPreferencesFragment.java
index 222b5fa..8d33c95 100644
--- a/src/com/android/browser/preferences/LabPreferencesFragment.java
+++ b/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 class LabPreferencesFragment extends PreferenceFragment {
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);
+ }
}
}