OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 <html> | 2 // Use of this source code is governed by a BSD-style license that can be |
3 <head> | 3 // found in the LICENSE file. |
4 <script> | 4 |
5 var pref = chrome.experimental.contentSettings.global.referrersEnabled; | 5 |
6 var pref = chrome.experimental.privacy.websites.thirdPartyCookiesAllowed; | |
7 | |
8 function $(id) { | |
9 return document.getElementById(id); | |
10 } | |
6 | 11 |
7 /** | 12 /** |
8 * Returns whether the |levelOfControl| means that the extension can change the | 13 * Returns whether the |levelOfControl| means that the extension can change the |
9 * preference value. | 14 * preference value. |
10 * | 15 * |
11 * @param levelOfControl{string} | 16 * @param levelOfControl{string} |
12 */ | 17 */ |
13 function settingIsControllable(levelOfControl) { | 18 function settingIsControllable(levelOfControl) { |
14 return (levelOfControl == "controllable_by_this_extension" || | 19 return (levelOfControl == "controllable_by_this_extension" || |
15 levelOfControl == "controlled_by_this_extension"); | 20 levelOfControl == "controlled_by_this_extension"); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 updateUI(settings); | 68 updateUI(settings); |
64 } | 69 } |
65 | 70 |
66 /* | 71 /* |
67 * Initializes the UI. | 72 * Initializes the UI. |
68 */ | 73 */ |
69 function init() { | 74 function init() { |
70 chrome.extension.isAllowedIncognitoAccess(function(allowed) { | 75 chrome.extension.isAllowedIncognitoAccess(function(allowed) { |
71 if (allowed) { | 76 if (allowed) { |
72 pref.get({'incognito': true}, updateUIFromGet); | 77 pref.get({'incognito': true}, updateUIFromGet); |
73 document.getElementById("incognito").style.display = "block"; | 78 $("incognito").style.display = "block"; |
Bernhard Bauer
2011/10/18 13:21:44
I know I'm pretty inconsistent in that regard myse
Mike West
2011/10/18 13:47:00
Excellent point. Done.
| |
74 document.getElementById("incognito-forbidden").style.display = "none"; | 79 $("incognito-forbidden").style.display = "none"; |
75 } | 80 } |
76 }); | 81 }); |
77 pref.get({}, updateUIFromGet); | 82 pref.get({}, updateUIFromGet); |
78 pref.onChange.addListener(updateUIFromOnChange); | 83 pref.onChange.addListener(updateUIFromOnChange); |
84 | |
85 $('regularValue').addEventListener('click', function () { | |
86 setPrefValue(this.checked, false); | |
87 }); | |
88 $('useSeparateIncognitoSettings').addEventListener('click', function () { | |
89 setUseSeparateIncognitoSettings(this.checked); | |
90 }); | |
91 $('incognitoValue').addEventListener('click', function () { | |
92 setPrefValue(this.checked, true); | |
93 }); | |
79 } | 94 } |
80 | 95 |
81 /** | 96 /** |
82 * Called from the UI to change the preference value. | 97 * Called from the UI to change the preference value. |
83 * | 98 * |
84 * @param enabled{boolean} The new preference value. | 99 * @param enabled{boolean} The new preference value. |
85 * @param incognito{boolean} Whether the value is specific to incognito mode. | 100 * @param incognito{boolean} Whether the value is specific to incognito mode. |
86 */ | 101 */ |
87 function setPrefValue(enabled, incognito) { | 102 function setPrefValue(enabled, incognito) { |
88 var scope = incognito ? 'incognito_session_only' : 'regular'; | 103 var scope = incognito ? 'incognito_session_only' : 'regular'; |
(...skipping 12 matching lines...) Expand all Loading... | |
101 pref.clear({'incognito': true}); | 116 pref.clear({'incognito': true}); |
102 } else { | 117 } else { |
103 // Explicitly set the value for incognito mode. | 118 // Explicitly set the value for incognito mode. |
104 pref.get({'incognito': true}, function(settings) { | 119 pref.get({'incognito': true}, function(settings) { |
105 pref.set({'incognito': true, 'value': settings.value}); | 120 pref.set({'incognito': true, 'value': settings.value}); |
106 }); | 121 }); |
107 } | 122 } |
108 document.getElementById("incognitoValue").disabled = !value; | 123 document.getElementById("incognitoValue").disabled = !value; |
109 } | 124 } |
110 | 125 |
111 </script> | 126 // Call `init` to kick things off. |
112 </head> | 127 document.addEventListener('DOMContentLoaded', init); |
113 <body onload="init()"> | |
114 | |
115 <div style="width: 300px"> | |
116 <input type="checkbox" onclick="setPrefValue(this.checked)" id="regularValue" /> Enable referrers | |
117 | |
118 <div id="incognito" style="display:none"> | |
119 <input type="checkbox" onclick="setUseSeparateIncognitoSettings(this.checked)" i d="useSeparateIncognitoSettings" /> Use separate setting for incognito mode: | |
120 <br> | |
121 <input type="checkbox" onclick="setPrefValue(this.checked, true)" id="incognitoV alue" disabled="disabled"/> Enable referrers in incognito sessions | |
122 </div> | |
123 <div id="incognito-forbidden"> | |
124 Select "Allow in incognito" to access incognito preferences | |
125 </div> | |
126 </div> | |
127 | |
128 </body> | |
129 </html> | |
OLD | NEW |