summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/examples
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 14:17:38 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-09 14:17:38 +0000
commitfa062426cde3d551d07a82a9e6a9ee2dfc15e6a4 (patch)
tree4baf4ceac1ddfffa7234c86e20776173c43fc6a7 /chrome/common/extensions/docs/examples
parent9f39293c0507c538c944de86ca6ce002c6feb2b2 (diff)
downloadchromium_src-fa062426cde3d551d07a82a9e6a9ee2dfc15e6a4.zip
chromium_src-fa062426cde3d551d07a82a9e6a9ee2dfc15e6a4.tar.gz
chromium_src-fa062426cde3d551d07a82a9e6a9ee2dfc15e6a4.tar.bz2
Content settings extension API
BUG=71067 TEST= Review URL: http://codereview.chromium.org/7029031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88526 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs/examples')
-rw-r--r--chrome/common/extensions/docs/examples/api/contentSettings.zipbin0 -> 12584 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/contentSettings/contentSettings.pngbin0 -> 2471 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/contentSettings/manifest.json10
-rw-r--r--chrome/common/extensions/docs/examples/api/contentSettings/popup.html101
-rw-r--r--chrome/common/extensions/docs/examples/api/preferences/enableReferrer.zipbin7273 -> 7263 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/tabs/screenshot.zipbin6610 -> 6609 bytes
-rw-r--r--chrome/common/extensions/docs/examples/extensions/benchmark.zipbin258732 -> 258809 bytes
7 files changed, 111 insertions, 0 deletions
diff --git a/chrome/common/extensions/docs/examples/api/contentSettings.zip b/chrome/common/extensions/docs/examples/api/contentSettings.zip
new file mode 100644
index 0000000..d10841d
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/contentSettings.zip
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/contentSettings/contentSettings.png b/chrome/common/extensions/docs/examples/api/contentSettings/contentSettings.png
new file mode 100644
index 0000000..346e1fd
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/contentSettings/contentSettings.png
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/contentSettings/manifest.json b/chrome/common/extensions/docs/examples/api/contentSettings/manifest.json
new file mode 100644
index 0000000..432dbe8
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/contentSettings/manifest.json
@@ -0,0 +1,10 @@
+{
+ "name" : "Content settings",
+ "version" : "0.1",
+ "description" : "Shows the content settings for the current site.",
+ "permissions": [ "experimental", "contentSettings", "tabs" ],
+ "browser_action": {
+ "default_icon": "contentSettings.png",
+ "popup": "popup.html"
+ }
+}
diff --git a/chrome/common/extensions/docs/examples/api/contentSettings/popup.html b/chrome/common/extensions/docs/examples/api/contentSettings/popup.html
new file mode 100644
index 0000000..eebb9c4
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/contentSettings/popup.html
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+var settings = {
+ "cookies": ["allow", "session_only", "block"],
+ "images": ["allow", "block"],
+ "javascript": ["allow", "block"],
+ "plugins": ["allow", "block"],
+ "popups": ["allow", "block"],
+ // "location": ["allow", "ask", "block"],
+ "notifications": ["allow", "ask", "block"],
+};
+
+var incognito;
+var url;
+
+function init() {
+ chrome.tabs.getSelected(undefined, function(tab) {
+ incognito = tab.incognito;
+ url = tab.url;
+ var types = ["cookies", "images", "javascript", "plugins", "popups",
+ "notifications"];
+ types.forEach(function(type) {
+ chrome.experimental.contentSettings[type].get({
+ 'topLevelUrl': url,
+ 'embeddedUrl': url,
+ 'incognito': incognito
+ },
+ function(details) {
+ document.getElementById(type).value = details.setting;
+ });
+ });
+ });
+}
+
+function settingChanged(element) {
+ var type = element.id;
+ var setting = element.value;
+ var pattern = {
+ 'pattern': url
+ };
+ console.log(type+" setting for "+pattern+": "+setting);
+ chrome.experimental.contentSettings[type].set({
+ 'topLevelPattern': pattern,
+ 'embeddedPattern': pattern,
+ 'setting': setting,
+ 'scope': (incognito ? 'incognito_session_only' : 'regular')
+ });
+}
+</script>
+</head>
+<body onload="init()">
+
+<fieldset>
+<dl>
+<dt><label for="cookies">Cookies: </label></dt>
+<dd><select id="cookies" onchange="settingChanged(this);">
+ <option value="allow">Allow</option>
+ <option value="session_only">Session only</option>
+ <option value="block">Block</option>
+</select></dd>
+<dt><label for="images">Images: </label></dt>
+<dd><select id="images" onchange="settingChanged(this);">
+ <option value="allow">Allow</option>
+ <option value="block">Block</option>
+</select>
+<dt><label for="javascript">Javascript: </label></dt>
+<dd><select id="javascript" onchange="settingChanged(this);">
+ <option value="allow">Allow</option>
+ <option value="block">Block</option>
+</select></dd>
+<dt><label for="plugins">Plug-ins: </label></dt>
+<dd><select id="plugins" onchange="settingChanged(this);">
+ <option value="allow">Allow</option>
+ <option value="ask">Click-to-play</option>
+ <option value="block">Block</option>
+ </select></dd>
+<dt><label for="popups">Pop-ups: </label></dt>
+<dd><select id="popups" onchange="settingChanged(this);">
+ <option value="allow">Allow</option>
+ <option value="block">Block</option>
+ </select></dd>
+<dt><label for="location">Location: </label></dt>
+<dd><select id="location" onchange="settingChanged(this);" disabled>
+ <option value="allow">Allow</option>
+ <option value="ask">Ask</option>
+ <option value="block">Block</option>
+ </select></dd>
+<dt><label for="notifications">Notifications: </label></dt>
+<dd><select id="notifications" onchange="settingChanged(this);">
+ <option value="allow">Allow</option>
+ <option value="ask">Ask</option>
+ <option value="block">Block</option>
+ </select></dd>
+</dl>
+</fieldset>
+
+
+</body>
+</html>
diff --git a/chrome/common/extensions/docs/examples/api/preferences/enableReferrer.zip b/chrome/common/extensions/docs/examples/api/preferences/enableReferrer.zip
index 1f4b896..1436291 100644
--- a/chrome/common/extensions/docs/examples/api/preferences/enableReferrer.zip
+++ b/chrome/common/extensions/docs/examples/api/preferences/enableReferrer.zip
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/tabs/screenshot.zip b/chrome/common/extensions/docs/examples/api/tabs/screenshot.zip
index f642666..1894439 100644
--- a/chrome/common/extensions/docs/examples/api/tabs/screenshot.zip
+++ b/chrome/common/extensions/docs/examples/api/tabs/screenshot.zip
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark.zip b/chrome/common/extensions/docs/examples/extensions/benchmark.zip
index 3623358..24244ec 100644
--- a/chrome/common/extensions/docs/examples/extensions/benchmark.zip
+++ b/chrome/common/extensions/docs/examples/extensions/benchmark.zip
Binary files differ