Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <style> | |
| 5 dt { | |
| 6 | |
| 7 } | |
| 8 | |
| 9 dd { | |
| 10 | |
| 11 } | |
| 12 </style> | |
| 13 | |
| 14 <script> | |
| 15 var settings = { | |
| 16 "cookies": ["allow", "session_only", "block"], | |
| 17 "images": ["allow", "block"], | |
| 18 "javascript": ["allow", "block"], | |
| 19 "plugins": ["allow", "block"], | |
| 20 "popups": ["allow", "block"], | |
| 21 // "location": ["allow", "ask", "block"], | |
| 22 "notifications": ["allow", "ask", "block"], | |
| 23 }; | |
| 24 | |
| 25 var incognito; | |
| 26 var url; | |
| 27 | |
| 28 function init() { | |
| 29 chrome.tabs.getSelected(undefined, function(tab) { | |
| 30 incognito = tab.incognito; | |
| 31 url = tab.url; | |
| 32 var types = ["cookies", "images", "javascript", "plugins", "popups", | |
| 33 "notifications"]; | |
| 34 types.forEach(function(type) { | |
| 35 chrome.experimental.contentSettings[type].get({ | |
| 36 'topLevelUrl': url, | |
| 37 'embeddedUrl': url, | |
| 38 'incognito': incognito | |
| 39 }, | |
| 40 function(details) { | |
| 41 document.getElementById(type).value = details.setting; | |
| 42 }); | |
| 43 }); | |
| 44 }); | |
| 45 } | |
| 46 | |
| 47 function settingChanged(element) { | |
| 48 var type = element.id; | |
| 49 var setting = element.value; | |
| 50 var pattern = { | |
| 51 'pattern': url | |
| 52 }; | |
| 53 console.log(type+" setting for "+pattern+": "+setting); | |
| 54 chrome.experimental.contentSettings[type].set({ | |
| 55 'topLevelPattern': pattern, | |
| 56 'embeddedPattern': pattern, | |
| 57 'setting': setting, | |
| 58 'scope': (incognito ? 'incognito_session_only' : 'regular') | |
| 59 }); | |
| 60 } | |
| 61 </script> | |
| 62 </head> | |
| 63 <body onload="init()"> | |
| 64 | |
| 65 <fieldset> | |
| 66 <dl> | |
| 67 <dt><label for="cookies">Cookies: </label></dt><dd><select id="cookies" onchange ="settingChanged(this);"> | |
|
battre
2011/06/07 18:16:14
nit: split before <dd> to have <80 character lines
Bernhard Bauer
2011/06/08 14:20:16
Done.
| |
| 68 <option value="allow">Allow</option> | |
| 69 <option value="session_only">Session only</option> | |
| 70 <option value="block">Block</option> | |
| 71 </select></dd> | |
| 72 <dt><label for="images">Images: </label></dt><dd><select id="images" onchange="s ettingChanged(this);"> | |
| 73 <option value="allow">Allow</option> | |
| 74 <option value="block">Block</option> | |
| 75 </select> | |
| 76 <dt><label for="javascript">Javascript: </label></dt><dd><select id="javascript" onchange="settingChanged(this);"> | |
| 77 <option value="allow">Allow</option> | |
| 78 <option value="block">Block</option> | |
| 79 </select></dd> | |
| 80 <dt><label for="plugins">Plug-ins: </label></dt><dd><select id="plugins" onchang e="settingChanged(this);"> | |
| 81 <option value="allow">Allow</option> | |
| 82 <option value="ask">Click-to-play</option> | |
| 83 <option value="block">Block</option> | |
| 84 </select></dd> | |
| 85 <dt><label for="popups">Pop-ups: </label></dt><dd><select id="popups" onchange=" settingChanged(this);"> | |
| 86 <option value="allow">Allow</option> | |
| 87 <option value="block">Block</option> | |
| 88 </select></dd> | |
| 89 <dt><label for="location">Location: </label></dt><dd><select id="location" oncha nge="settingChanged(this);" disabled> | |
| 90 <option value="allow">Allow</option> | |
| 91 <option value="ask">Ask</option> | |
| 92 <option value="block">Block</option> | |
| 93 </select></dd> | |
| 94 <dt><label for="notifications">Notifications: </label></dt><dd><select id="notif ications" onchange="settingChanged(this);"> | |
| 95 <option value="allow">Allow</option> | |
| 96 <option value="ask">Ask</option> | |
| 97 <option value="block">Block</option> | |
| 98 </select></dd> | |
| 99 </dl> | |
| 100 </fieldset> | |
| 101 | |
| 102 | |
| 103 </body> | |
| 104 </html> | |
| OLD | NEW |