Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 970 // extensions) | 970 // extensions) |
| 971 var devtools_descriptor = Object.getOwnPropertyDescriptor(chrome, "devtools" ); | 971 var devtools_descriptor = Object.getOwnPropertyDescriptor(chrome, "devtools" ); |
| 972 if (!devtools_descriptor || devtools_descriptor.get) | 972 if (!devtools_descriptor || devtools_descriptor.get) |
| 973 Object.defineProperty(chrome, "devtools", { value: {}, enumerable: true }); | 973 Object.defineProperty(chrome, "devtools", { value: {}, enumerable: true }); |
| 974 // Only expose tabId on chrome.devtools.inspectedWindow, not webInspector.in spectedWindow. | 974 // Only expose tabId on chrome.devtools.inspectedWindow, not webInspector.in spectedWindow. |
| 975 chrome.devtools.inspectedWindow = {}; | 975 chrome.devtools.inspectedWindow = {}; |
| 976 chrome.devtools.inspectedWindow.__defineGetter__("tabId", getTabId); | 976 chrome.devtools.inspectedWindow.__defineGetter__("tabId", getTabId); |
| 977 chrome.devtools.inspectedWindow.__proto__ = coreAPI.inspectedWindow; | 977 chrome.devtools.inspectedWindow.__proto__ = coreAPI.inspectedWindow; |
| 978 chrome.devtools.network = coreAPI.network; | 978 chrome.devtools.network = coreAPI.network; |
| 979 chrome.devtools.panels = coreAPI.panels; | 979 chrome.devtools.panels = coreAPI.panels; |
| 980 chrome.devtools.panels.themeName = themeName; | |
|
caseq
2016/06/21 09:50:09
Let's either make it a function, a getter or an im
pfeldman
2016/06/27 15:13:21
I can't make it immutable for the backwards compat
| |
| 980 | 981 |
| 981 // default to expose experimental APIs for now. | 982 // default to expose experimental APIs for now. |
| 982 if (extensionInfo.exposeExperimentalAPIs !== false) { | 983 if (extensionInfo.exposeExperimentalAPIs !== false) { |
| 983 chrome.experimental = chrome.experimental || {}; | 984 chrome.experimental = chrome.experimental || {}; |
| 984 chrome.experimental.devtools = chrome.experimental.devtools || {}; | 985 chrome.experimental.devtools = chrome.experimental.devtools || {}; |
| 985 | 986 |
| 986 var properties = Object.getOwnPropertyNames(coreAPI); | 987 var properties = Object.getOwnPropertyNames(coreAPI); |
| 987 for (var i = 0; i < properties.length; ++i) { | 988 for (var i = 0; i < properties.length; ++i) { |
| 988 var descriptor = Object.getOwnPropertyDescriptor(coreAPI, properties [i]); | 989 var descriptor = Object.getOwnPropertyDescriptor(coreAPI, properties [i]); |
| 989 Object.defineProperty(chrome.experimental.devtools, properties[i], d escriptor); | 990 Object.defineProperty(chrome.experimental.devtools, properties[i], d escriptor); |
| 990 } | 991 } |
| 991 chrome.experimental.devtools.inspectedWindow = chrome.devtools.inspected Window; | 992 chrome.experimental.devtools.inspectedWindow = chrome.devtools.inspected Window; |
| 992 } | 993 } |
| 993 if (extensionInfo.exposeWebInspectorNamespace) | 994 if (extensionInfo.exposeWebInspectorNamespace) |
| 994 window.webInspector = coreAPI; | 995 window.webInspector = coreAPI; |
| 995 } | 996 } |
| 996 | 997 |
| 997 /** | 998 /** |
| 998 * @param {!ExtensionDescriptor} extensionInfo | 999 * @param {!ExtensionDescriptor} extensionInfo |
| 999 * @param {string} inspectedTabId | 1000 * @param {string} inspectedTabId |
| 1001 * @param {string} themeName | |
| 1000 * @return {string} | 1002 * @return {string} |
| 1001 */ | 1003 */ |
| 1002 function buildPlatformExtensionAPI(extensionInfo, inspectedTabId) | 1004 function buildPlatformExtensionAPI(extensionInfo, inspectedTabId, themeName) |
| 1003 { | 1005 { |
| 1004 return "var extensionInfo = " + JSON.stringify(extensionInfo) + ";" + | 1006 return "var extensionInfo = " + JSON.stringify(extensionInfo) + ";" + |
| 1005 "var tabId = " + inspectedTabId + ";" + | 1007 "var tabId = " + inspectedTabId + ";" + |
| 1008 "var themeName = '" + themeName + "';" + | |
| 1006 platformExtensionAPI.toString(); | 1009 platformExtensionAPI.toString(); |
| 1007 } | 1010 } |
| 1008 | 1011 |
| 1009 /** | 1012 /** |
| 1010 * @param {!ExtensionDescriptor} extensionInfo | 1013 * @param {!ExtensionDescriptor} extensionInfo |
| 1011 * @param {string} inspectedTabId | 1014 * @param {string} inspectedTabId |
| 1015 * @param {string} themeName | |
| 1012 * @return {string} | 1016 * @return {string} |
| 1013 */ | 1017 */ |
| 1014 function buildExtensionAPIInjectedScript(extensionInfo, inspectedTabId) | 1018 function buildExtensionAPIInjectedScript(extensionInfo, inspectedTabId, themeNam e) |
| 1015 { | 1019 { |
| 1016 return "(function(injectedScriptId){ " + | 1020 return "(function(injectedScriptId){ " + |
| 1017 "var extensionServer;" + | 1021 "var extensionServer;" + |
| 1018 defineCommonExtensionSymbols.toString() + ";" + | 1022 defineCommonExtensionSymbols.toString() + ";" + |
| 1019 injectedExtensionAPI.toString() + ";" + | 1023 injectedExtensionAPI.toString() + ";" + |
| 1020 buildPlatformExtensionAPI(extensionInfo, inspectedTabId) + ";" + | 1024 buildPlatformExtensionAPI(extensionInfo, inspectedTabId, themeName) + "; " + |
| 1021 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + | 1025 "platformExtensionAPI(injectedExtensionAPI(injectedScriptId));" + |
| 1022 "return {};" + | 1026 "return {};" + |
| 1023 "})"; | 1027 "})"; |
| 1024 } | 1028 } |
| OLD | NEW |