Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: extension/background.js

Issue 11450020: (Fix #215) better error printing in editor & extension, adds mapping for editor (Closed) Base URL: git@github.com:dart-lang/dart-web-components.git@master
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Glue code that interacts with dwc_compiler.dart to proxy arbitrary content 5 // Glue code that interacts with dwc_compiler.dart to proxy arbitrary content
6 // for urls. 6 // for urls.
7 7
8 8
9 var existingRuleIds = {}; 9 var existingRuleIds = {};
10 var onParse = null; 10 var onParse = null;
11 11
12 // TODO(jacobr): determine whether it is a bug or feature that we need to call 12 // TODO(jacobr): determine whether it is a bug or feature that we need to call
13 // this. Without the next line, stale declarativeWebRequest rules from the 13 // this. Without the next line, stale declarativeWebRequest rules from the
14 // previous time the extension was run conflict with rules from the current 14 // previous time the extension was run conflict with rules from the current
15 // running version causing the extension to sometimes crash due to conflicting 15 // running version causing the extension to sometimes crash due to conflicting
16 // redirect requests. 16 // redirect requests.
17 chrome.declarativeWebRequest.onRequest.removeRules(); 17 chrome.declarativeWebRequest.onRequest.removeRules();
18 18
19 // TODO(jacobr): set the onParse property directly from Dart. 19 // TODO(jacobr): set the onParse property directly from Dart.
20 function setOnParseCallback(cb) { 20 function setOnParseCallback(cb) {
21 onParse = cb; 21 onParse = cb;
22 } 22 }
23 23
24 function proxyUrls(port, requests) { 24 function proxyUrls(port, requests) {
25 // Unfortunately we have to create the data urls from the content script due 25 // Unfortunately we have to create the data urls from the content script due
26 // to chrome security restrictions. 26 // to chrome security restrictions.
27 port.postMessage({type: 'CREATE_DATA_URLS', requests: requests}); 27 port.postMessage({type: 'CREATE_DATA_URLS', requests: requests});
28 } 28 }
29 29
30 function proxyMessages(port, messages) {
31 port.postMessage({type: 'MESSAGES', messages: messages});
32 }
33
30 function onProxyUrls(requests) { 34 function onProxyUrls(requests) {
31 var rulesToAdd = []; 35 var rulesToAdd = [];
32 var ruleIdsToRemove = []; 36 var ruleIdsToRemove = [];
33 for (var i = 0; i < requests.length; i++) { 37 for (var i = 0; i < requests.length; i++) {
34 var request = requests[i]; 38 var request = requests[i];
35 var url = request.url; 39 var url = request.url;
36 var redirectUrl = request.redirectUrl; 40 var redirectUrl = request.redirectUrl;
37 var rule = { 41 var rule = {
38 conditions: [ 42 conditions: [
39 new chrome.declarativeWebRequest.RequestMatcher( 43 new chrome.declarativeWebRequest.RequestMatcher(
(...skipping 26 matching lines...) Expand all
66 port.onMessage.addListener(function(msg) { 70 port.onMessage.addListener(function(msg) {
67 onParse(port, msg.url); 71 onParse(port, msg.url);
68 }); 72 });
69 } else if (port.name == "proxy") { 73 } else if (port.name == "proxy") {
70 // Listen for requests to proxy urls. 74 // Listen for requests to proxy urls.
71 port.onMessage.addListener(function(msg) { 75 port.onMessage.addListener(function(msg) {
72 onProxyUrls(msg.requests); 76 onProxyUrls(msg.requests);
73 }); 77 });
74 } 78 }
75 }); 79 });
OLDNEW
« no previous file with comments | « bin/dwc_browser.dart ('k') | extension/content_script.js » ('j') | lib/src/messages.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698