Chromium Code Reviews| Index: chrome/common/extensions/docs/examples/api/contentSettings/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 0000000000000000000000000000000000000000..ac9e080b9341cdcce3db33a6646dae126e289e1a |
| --- /dev/null |
| +++ b/chrome/common/extensions/docs/examples/api/contentSettings/popup.html |
| @@ -0,0 +1,92 @@ |
| +<!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()"> |
| + |
| +<table> |
|
battre
2011/06/06 23:45:13
Do this properly with a
<fieldset>
<legend>Conte
Bernhard Bauer
2011/06/07 13:48:13
Done.
|
| +<tr><td>Cookies: </td><td><select id="cookies" onchange="settingChanged(this);"> |
| + <option value="allow">Allow</option> |
| + <option value="session_only">Session only</option> |
| + <option value="block">Block</option> |
| +</select></td></tr> |
| +<tr><td>Images: </td><td><select id="images" onchange="settingChanged(this);"> |
| + <option value="allow">Allow</option> |
| + <option value="block">Block</option> |
| +</select></li> |
|
battre
2011/06/06 23:45:13
This </li> is not correct, also some more cases be
Bernhard Bauer
2011/06/07 13:48:13
Whoops. Done.
|
| +<tr><td>Javascript: </td><td><select id="javascript" onchange="settingChanged(this);"> |
| + <option value="allow">Allow</option> |
| + <option value="block">Block</option> |
| +</select></li> |
| +<tr><td>Plug-ins: </td><td><select id="plugins" onchange="settingChanged(this);"> |
| + <option value="allow">Allow</option> |
| + <option value="ask">Click-to-play</option> |
| + <option value="block">Block</option> |
| + </select></li> |
| +<tr><td>Pop-ups: </td><td><select id="popups" onchange="settingChanged(this);"> |
| + <option value="allow">Allow</option> |
| + <option value="block">Block</option> |
| + </select></li> |
| +<tr><td>Location: </td><td><select id="location" onchange="settingChanged(this);" disabled> |
| + <option value="allow">Allow</option> |
| + <option value="ask">Ask</option> |
| + <option value="block">Block</option> |
| + </select></li> |
| +<tr><td>Notifications: </td><td><select id="notifications" onchange="settingChanged(this);"> |
| + <option value="allow">Allow</option> |
| + <option value="ask">Ask</option> |
| + <option value="block">Block</option> |
| + </select></li> |
| +</table> |
| + |
| + |
| +</body> |
| +</html> |