1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 function settingChanged() {
10 var setting
= this.value
;
11 var pattern
= /^file:/.test(url
) ? url
: url
.replace(/\/[^\/]*?$/, '/*');
12 console
.log(type
+' setting for '+pattern
+': '+setting
);
13 // HACK: [type] is not recognised by the docserver's sample crawler, so
14 // mention an explicit
15 // type: chrome.contentSettings.cookies.set - See http://crbug.com/299634
16 chrome
.contentSettings
[type
].set({
17 'primaryPattern': pattern
,
19 'scope': (incognito
? 'incognito_session_only' : 'regular')
23 document
.addEventListener('DOMContentLoaded', function () {
24 chrome
.tabs
.query({active
: true, currentWindow
: true}, function(tabs
) {
25 var current
= tabs
[0];
26 incognito
= current
.incognito
;
28 var types
= ['cookies', 'images', 'javascript', 'plugins', 'popups',
30 types
.forEach(function(type
) {
31 // HACK: [type] is not recognised by the docserver's sample crawler, so
32 // mention an explicit
33 // type: chrome.contentSettings.cookies.get - See http://crbug.com/299634
34 chrome
.contentSettings
[type
].get({
36 'incognito': incognito
39 document
.getElementById(type
).value
= details
.setting
;
44 var selects
= document
.querySelectorAll('select');
45 for (var i
= 0; i
< selects
.length
; i
++) {
46 selects
[i
].addEventListener('change', settingChanged
);