Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script> | |
| 5 var settings = { | |
| 6 "cookies": ["allow", "session_only", "block"], | |
| 7 "images": ["allow", "block"], | |
| 8 "javascript": ["allow", "block"], | |
| 9 "plugins": ["allow", "block"], | |
| 10 "popups": ["allow", "block"], | |
| 11 // "location": ["allow", "ask", "block"], | |
| 12 "notifications": ["allow", "ask", "block"], | |
| 13 }; | |
| 14 | |
| 15 var incognito; | |
| 16 var url; | |
| 17 | |
| 18 function init() { | |
| 19 chrome.tabs.getSelected(undefined, function(tab) { | |
| 20 incognito = tab.incognito; | |
| 21 url = tab.url; | |
| 22 var types = ["cookies", "images", "javascript", "plugins", "popups", | |
| 23 "notifications"]; | |
| 24 types.forEach(function(type) { | |
| 25 chrome.experimental.contentSettings[type].get({ | |
| 26 'topLevelUrl': url, | |
| 27 'embeddedUrl': url, | |
| 28 'incognito': incognito | |
| 29 }, | |
| 30 function(details) { | |
| 31 document.getElementById(type).value = details.setting; | |
| 32 }); | |
| 33 }); | |
| 34 }); | |
| 35 } | |
| 36 | |
| 37 function settingChanged(element) { | |
| 38 var type = element.id; | |
| 39 var setting = element.value; | |
| 40 var pattern = { | |
| 41 'pattern': url | |
| 42 }; | |
| 43 console.log(type+" setting for "+pattern+": "+setting); | |
| 44 chrome.experimental.contentSettings[type].set({ | |
| 45 'topLevelPattern': pattern, | |
| 46 'embeddedPattern': pattern, | |
| 47 'setting': setting, | |
| 48 'scope': (incognito ? 'incognito_session_only' : 'regular') | |
| 49 }); | |
| 50 } | |
| 51 </script> | |
| 52 </head> | |
| 53 <body onload="init()"> | |
| 54 | |
| 55 <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.
| |
| 56 <tr><td>Cookies: </td><td><select id="cookies" onchange="settingChanged(this);"> | |
| 57 <option value="allow">Allow</option> | |
| 58 <option value="session_only">Session only</option> | |
| 59 <option value="block">Block</option> | |
| 60 </select></td></tr> | |
| 61 <tr><td>Images: </td><td><select id="images" onchange="settingChanged(this);"> | |
| 62 <option value="allow">Allow</option> | |
| 63 <option value="block">Block</option> | |
| 64 </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.
| |
| 65 <tr><td>Javascript: </td><td><select id="javascript" onchange="settingChanged(th is);"> | |
| 66 <option value="allow">Allow</option> | |
| 67 <option value="block">Block</option> | |
| 68 </select></li> | |
| 69 <tr><td>Plug-ins: </td><td><select id="plugins" onchange="settingChanged(this);" > | |
| 70 <option value="allow">Allow</option> | |
| 71 <option value="ask">Click-to-play</option> | |
| 72 <option value="block">Block</option> | |
| 73 </select></li> | |
| 74 <tr><td>Pop-ups: </td><td><select id="popups" onchange="settingChanged(this);"> | |
| 75 <option value="allow">Allow</option> | |
| 76 <option value="block">Block</option> | |
| 77 </select></li> | |
| 78 <tr><td>Location: </td><td><select id="location" onchange="settingChanged(this); " disabled> | |
| 79 <option value="allow">Allow</option> | |
| 80 <option value="ask">Ask</option> | |
| 81 <option value="block">Block</option> | |
| 82 </select></li> | |
| 83 <tr><td>Notifications: </td><td><select id="notifications" onchange="settingChan ged(this);"> | |
| 84 <option value="allow">Allow</option> | |
| 85 <option value="ask">Ask</option> | |
| 86 <option value="block">Block</option> | |
| 87 </select></li> | |
| 88 </table> | |
| 89 | |
| 90 | |
| 91 </body> | |
| 92 </html> | |
| OLD | NEW |