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

Side by Side Diff: Source/devtools/front_end/ExtensionServer.js

Issue 91603003: DevTools: allow injecting stylesheets as themes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/ExtensionAPI.js ('k') | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 this._lastRequestId = 0; 43 this._lastRequestId = 0;
44 this._registeredExtensions = {}; 44 this._registeredExtensions = {};
45 this._status = new WebInspector.ExtensionStatus(); 45 this._status = new WebInspector.ExtensionStatus();
46 46
47 var commands = WebInspector.extensionAPI.Commands; 47 var commands = WebInspector.extensionAPI.Commands;
48 48
49 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi nd(this)); 49 this._registerHandler(commands.AddAuditCategory, this._onAddAuditCategory.bi nd(this));
50 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t his)); 50 this._registerHandler(commands.AddAuditResult, this._onAddAuditResult.bind(t his));
51 this._registerHandler(commands.AddConsoleMessage, this._onAddConsoleMessage. bind(this)); 51 this._registerHandler(commands.AddConsoleMessage, this._onAddConsoleMessage. bind(this));
52 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders. bind(this)); 52 this._registerHandler(commands.AddRequestHeaders, this._onAddRequestHeaders. bind(this));
53 this._registerHandler(commands.ApplyStyleSheet, this._onApplyStyleSheet.bind (this));
53 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this)); 54 this._registerHandler(commands.CreatePanel, this._onCreatePanel.bind(this));
54 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane. bind(this)); 55 this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane. bind(this));
55 this._registerHandler(commands.CreateStatusBarButton, this._onCreateStatusBa rButton.bind(this)); 56 this._registerHandler(commands.CreateStatusBarButton, this._onCreateStatusBa rButton.bind(this));
56 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn spectedPage.bind(this)); 57 this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnIn spectedPage.bind(this));
57 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard Event.bind(this)); 58 this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboard Event.bind(this));
58 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this)); 59 this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this));
59 this._registerHandler(commands.GetConsoleMessages, this._onGetConsoleMessage s.bind(this)); 60 this._registerHandler(commands.GetConsoleMessages, this._onGetConsoleMessage s.bind(this));
60 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi nd(this)); 61 this._registerHandler(commands.GetPageResources, this._onGetPageResources.bi nd(this));
61 this._registerHandler(commands.GetRequestContent, this._onGetRequestContent. bind(this)); 62 this._registerHandler(commands.GetRequestContent, this._onGetRequestContent. bind(this));
62 this._registerHandler(commands.GetResourceContent, this._onGetResourceConten t.bind(this)); 63 this._registerHandler(commands.GetResourceContent, this._onGetResourceConten t.bind(this));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 for (var extension in this._extraHeaders) { 189 for (var extension in this._extraHeaders) {
189 var headers = this._extraHeaders[extension]; 190 var headers = this._extraHeaders[extension];
190 for (name in headers) { 191 for (name in headers) {
191 if (typeof headers[name] === "string") 192 if (typeof headers[name] === "string")
192 allHeaders[name] = headers[name]; 193 allHeaders[name] = headers[name];
193 } 194 }
194 } 195 }
195 NetworkAgent.setExtraHTTPHeaders(allHeaders); 196 NetworkAgent.setExtraHTTPHeaders(allHeaders);
196 }, 197 },
197 198
199 _onApplyStyleSheet: function(message)
200 {
201 if (!WebInspector.experimentsSettings.applyCustomStylesheet.isEnabled())
202 return;
203 var styleSheet = document.createElement("style");
204 styleSheet.textContent = message.styleSheet;
205 document.head.appendChild(styleSheet);
206 },
207
198 _onCreatePanel: function(message, port) 208 _onCreatePanel: function(message, port)
199 { 209 {
200 var id = message.id; 210 var id = message.id;
201 // The ids are generated on the client API side and must be unique, so t he check below 211 // The ids are generated on the client API side and must be unique, so t he check below
202 // shouldn't be hit unless someone is bypassing the API. 212 // shouldn't be hit unless someone is bypassing the API.
203 if (id in this._clientObjects || id in WebInspector.panels) 213 if (id in this._clientObjects || id in WebInspector.panels)
204 return this._status.E_EXISTS(id); 214 return this._status.E_EXISTS(id);
205 215
206 var page = this._expandResourcePath(port._extensionOrigin, message.page) ; 216 var page = this._expandResourcePath(port._extensionOrigin, message.page) ;
207 var panelDescriptor = new WebInspector.PanelDescriptor(id, message.title , undefined, undefined, new WebInspector.ExtensionPanel(id, page)); 217 var panelDescriptor = new WebInspector.PanelDescriptor(id, message.title , undefined, undefined, new WebInspector.ExtensionPanel(id, page));
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 937
928 WebInspector.extensionServer = new WebInspector.ExtensionServer(); 938 WebInspector.extensionServer = new WebInspector.ExtensionServer();
929 939
930 window.addExtension = function(page, name) 940 window.addExtension = function(page, name)
931 { 941 {
932 WebInspector.extensionServer._addExtension({ 942 WebInspector.extensionServer._addExtension({
933 startPage: page, 943 startPage: page,
934 name: name, 944 name: name,
935 }); 945 });
936 } 946 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ExtensionAPI.js ('k') | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698