OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Adds filter script and css to all existing tabs. | 6 * Adds filter script and css to all existing tabs. |
7 * | 7 * |
8 * TODO(wnwen): Verify content scripts are not being injected multiple times. | 8 * TODO(wnwen): Verify content scripts are not being injected multiple times. |
9 */ | 9 */ |
10 function injectContentScripts() { | 10 function injectContentScripts() { |
11 chrome.windows.getAll({'populate': true}, function(windows) { | 11 chrome.windows.getAll({'populate': true}, function(windows) { |
12 for (var i = 0; i < windows.length; i++) { | 12 for (var i = 0; i < windows.length; i++) { |
13 var tabs = windows[i].tabs; | 13 var tabs = windows[i].tabs; |
14 for (var j = 0; j < tabs.length; j++) { | 14 for (var j = 0; j < tabs.length; j++) { |
15 var url = tabs[j].url; | 15 var url = tabs[j].url; |
16 if (isDisallowedUrl(url)) { | 16 if (isDisallowedUrl(url)) { |
17 continue; | 17 continue; |
18 } | 18 } |
19 chrome.tabs.insertCSS( | |
20 tabs[j].id, | |
21 {file: 'res/cvd.css'}); | |
22 chrome.tabs.executeScript( | 19 chrome.tabs.executeScript( |
23 tabs[j].id, | 20 tabs[j].id, |
24 {file: 'src/common.js'}); | 21 {file: 'src/common.js'}); |
25 chrome.tabs.executeScript( | 22 chrome.tabs.executeScript( |
26 tabs[j].id, | 23 tabs[j].id, |
27 {file: 'src/cvd.js'}); | 24 {file: 'src/cvd.js'}); |
28 } | 25 } |
29 } | 26 } |
30 }); | 27 }); |
31 } | 28 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 sendResponse(msg); | 79 sendResponse(msg); |
83 } | 80 } |
84 }); | 81 }); |
85 | 82 |
86 //TODO(mustaq): Handle uninstall | 83 //TODO(mustaq): Handle uninstall |
87 | 84 |
88 document.addEventListener('storage', function(evt) { | 85 document.addEventListener('storage', function(evt) { |
89 updateTabs(); | 86 updateTabs(); |
90 }, false); | 87 }, false); |
91 })(); | 88 })(); |
OLD | NEW |