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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/extensions/ExtensionAPI.js

Issue 2080173003: DevTools: pass theme name to the extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test rebaselined Created 4 years, 5 months 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 // extensions) 971 // extensions)
972 var devtools_descriptor = Object.getOwnPropertyDescriptor(chrome, "devtools" ); 972 var devtools_descriptor = Object.getOwnPropertyDescriptor(chrome, "devtools" );
973 if (!devtools_descriptor || devtools_descriptor.get) 973 if (!devtools_descriptor || devtools_descriptor.get)
974 Object.defineProperty(chrome, "devtools", { value: {}, enumerable: true }); 974 Object.defineProperty(chrome, "devtools", { value: {}, enumerable: true });
975 // Only expose tabId on chrome.devtools.inspectedWindow, not webInspector.in spectedWindow. 975 // Only expose tabId on chrome.devtools.inspectedWindow, not webInspector.in spectedWindow.
976 chrome.devtools.inspectedWindow = {}; 976 chrome.devtools.inspectedWindow = {};
977 chrome.devtools.inspectedWindow.__defineGetter__("tabId", getTabId); 977 chrome.devtools.inspectedWindow.__defineGetter__("tabId", getTabId);
978 chrome.devtools.inspectedWindow.__proto__ = coreAPI.inspectedWindow; 978 chrome.devtools.inspectedWindow.__proto__ = coreAPI.inspectedWindow;
979 chrome.devtools.network = coreAPI.network; 979 chrome.devtools.network = coreAPI.network;
980 chrome.devtools.panels = coreAPI.panels; 980 chrome.devtools.panels = coreAPI.panels;
981 chrome.devtools.panels.themeName = themeName;
981 982
982 // default to expose experimental APIs for now. 983 // default to expose experimental APIs for now.
983 if (extensionInfo.exposeExperimentalAPIs !== false) { 984 if (extensionInfo.exposeExperimentalAPIs !== false) {
984 chrome.experimental = chrome.experimental || {}; 985 chrome.experimental = chrome.experimental || {};
985 chrome.experimental.devtools = chrome.experimental.devtools || {}; 986 chrome.experimental.devtools = chrome.experimental.devtools || {};
986 987
987 var properties = Object.getOwnPropertyNames(coreAPI); 988 var properties = Object.getOwnPropertyNames(coreAPI);
988 for (var i = 0; i < properties.length; ++i) { 989 for (var i = 0; i < properties.length; ++i) {
989 var descriptor = Object.getOwnPropertyDescriptor(coreAPI, properties [i]); 990 var descriptor = Object.getOwnPropertyDescriptor(coreAPI, properties [i]);
990 Object.defineProperty(chrome.experimental.devtools, properties[i], d escriptor); 991 Object.defineProperty(chrome.experimental.devtools, properties[i], d escriptor);
991 } 992 }
992 chrome.experimental.devtools.inspectedWindow = chrome.devtools.inspected Window; 993 chrome.experimental.devtools.inspectedWindow = chrome.devtools.inspected Window;
993 } 994 }
994 if (extensionInfo.exposeWebInspectorNamespace) 995 if (extensionInfo.exposeWebInspectorNamespace)
995 window.webInspector = coreAPI; 996 window.webInspector = coreAPI;
996 } 997 }
997 998
998 /** 999 /**
999 * @param {!ExtensionDescriptor} extensionInfo 1000 * @param {!ExtensionDescriptor} extensionInfo
1000 * @param {string} inspectedTabId 1001 * @param {string} inspectedTabId
1002 * @param {string} themeName
1001 * @return {string} 1003 * @return {string}
1002 */ 1004 */
1003 function buildPlatformExtensionAPI(extensionInfo, inspectedTabId) 1005 function buildPlatformExtensionAPI(extensionInfo, inspectedTabId, themeName)
1004 { 1006 {
1005 return "var extensionInfo = " + JSON.stringify(extensionInfo) + ";" + 1007 return "var extensionInfo = " + JSON.stringify(extensionInfo) + ";" +
1006 "var tabId = " + inspectedTabId + ";" + 1008 "var tabId = " + inspectedTabId + ";" +
1009 "var themeName = '" + themeName + "';" +
1007 platformExtensionAPI.toString(); 1010 platformExtensionAPI.toString();
1008 } 1011 }
1009 1012
1010 /** 1013 /**
1011 * @param {!ExtensionDescriptor} extensionInfo 1014 * @param {!ExtensionDescriptor} extensionInfo
1012 * @param {string} inspectedTabId 1015 * @param {string} inspectedTabId
1016 * @param {string} themeName
1013 * @return {string} 1017 * @return {string}
1014 */ 1018 */
1015 function buildExtensionAPIInjectedScript(extensionInfo, inspectedTabId) 1019 function buildExtensionAPIInjectedScript(extensionInfo, inspectedTabId, themeNam e)
1016 { 1020 {
1017 return "(function(injectedScriptId){ " + 1021 return "(function(injectedScriptId){ " +
1018 "var extensionServer;" + 1022 "var extensionServer;" +
1019 defineCommonExtensionSymbols.toString() + ";" + 1023 defineCommonExtensionSymbols.toString() + ";" +
1020 injectedExtensionAPI.toString() + ";" + 1024 injectedExtensionAPI.toString() + ";" +
1021 buildPlatformExtensionAPI(extensionInfo, inspectedTabId) + ";" + 1025 buildPlatformExtensionAPI(extensionInfo, inspectedTabId, themeName) + "; " +
1022 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + 1026 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" +
1023 "return {};" + 1027 "return {};" +
1024 "})"; 1028 "})";
1025 } 1029 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698