diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 23:56:06 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 23:56:06 +0000 |
commit | 15397b4b6bc600a8f4bf36a794d07dd057072e17 (patch) | |
tree | cdeebdde2f0f6e140595aea8e342f09b26bf8e43 | |
parent | e769f770492fce71f9211ae19745687acd0bf871 (diff) | |
download | chromium_src-15397b4b6bc600a8f4bf36a794d07dd057072e17.zip chromium_src-15397b4b6bc600a8f4bf36a794d07dd057072e17.tar.gz chromium_src-15397b4b6bc600a8f4bf36a794d07dd057072e17.tar.bz2 |
Hack to restrict runtime API to dev channel rather than experimental.
BUG=124167
TEST=no
Review URL: https://chromiumcodereview.appspot.com/10310182
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137566 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 112 insertions, 46 deletions
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc index 3142565..64106fe 100644 --- a/chrome/browser/extensions/api/runtime/runtime_api.cc +++ b/chrome/browser/extensions/api/runtime/runtime_api.cc @@ -15,7 +15,7 @@ namespace { -const char kOnInstalledEvent[] = "experimental.runtime.onInstalled"; +const char kOnInstalledEvent[] = "runtime.onInstalled"; const char kNoBackgroundPageError[] = "You do not have a background page."; const char kPageLoadError[] = "Background page failed to load."; diff --git a/chrome/browser/extensions/api/runtime/runtime_api.h b/chrome/browser/extensions/api/runtime/runtime_api.h index c2096d3..9b2f10e 100644 --- a/chrome/browser/extensions/api/runtime/runtime_api.h +++ b/chrome/browser/extensions/api/runtime/runtime_api.h @@ -24,7 +24,7 @@ class RuntimeEventRouter { class RuntimeGetBackgroundPageFunction : public AsyncExtensionFunction { protected: virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.runtime.getBackgroundPage"); + DECLARE_EXTENSION_FUNCTION_NAME("runtime.getBackgroundPage"); private: void OnPageLoaded(ExtensionHost*); }; diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 13d5825..d221c40 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -87,6 +87,7 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/chrome_version_info.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_error_utils.h" #include "chrome/common/extensions/extension_file_util.h" @@ -2379,6 +2380,10 @@ void ExtensionService::Observe(int type, if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) break; + // Extensions need to know the channel for API restrictions. + process->Send(new ExtensionMsg_SetChannel( + chrome::VersionInfo::GetChannel())); + // Valid extension function names, used to setup bindings in renderer. std::vector<std::string> function_names; ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index 163dc9d..a5f8d18 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -145,7 +145,6 @@ 'renderer/resources/extensions/devtools_custom_bindings.js', 'renderer/resources/extensions/event.js', 'renderer/resources/extensions/experimental.offscreenTabs_custom_bindings.js', - 'renderer/resources/extensions/experimental.runtime_custom_bindings.js', 'renderer/resources/extensions/extension_custom_bindings.js', 'renderer/resources/extensions/file_browser_handler_custom_bindings.js', 'renderer/resources/extensions/file_browser_private_custom_bindings.js', @@ -158,6 +157,7 @@ 'renderer/resources/extensions/page_actions_custom_bindings.js', 'renderer/resources/extensions/page_capture_custom_bindings.js', 'renderer/resources/extensions/platform_app.js', + 'renderer/resources/extensions/runtime_custom_bindings.js', 'renderer/resources/extensions/schema_generated_bindings.js', 'renderer/resources/extensions/send_request.js', 'renderer/resources/extensions/set_icon.js', diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json index 4b0ce89..834b60a 100644 --- a/chrome/common/extensions/api/_permission_features.json +++ b/chrome/common/extensions/api/_permission_features.json @@ -181,6 +181,13 @@ "channel": "stable", "extension_types": ["extension", "packaged_app", "platform_app"] }, + // Note: runtime is not actually a permission, but some systems check these + // values to verify restrictions. + "runtime": { + "channel": "dev", + "extension_types": ["extension", "packaged_app", "platform_app"], + "min_manifest_version": 2 + }, "serial": { "channel": "stable", "extension_types": ["platform_app"] diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index a8b8434..b713a27 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -381,8 +381,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_EXPERIMENTAL_RECORD)); RegisterSchema("experimental.rlz", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_RLZ)); - RegisterSchema("experimental.runtime", ReadFromResource( - IDR_EXTENSION_API_JSON_EXPERIMENTAL_RUNTIME)); + RegisterSchema("runtime", ReadFromResource( + IDR_EXTENSION_API_JSON_RUNTIME)); RegisterSchema("experimental.speechInput", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_SPEECHINPUT)); RegisterSchema("extension", ReadFromResource( diff --git a/chrome/common/extensions/api/experimental_runtime.json b/chrome/common/extensions/api/runtime.json index ad37160..573f063 100644 --- a/chrome/common/extensions/api/experimental_runtime.json +++ b/chrome/common/extensions/api/runtime.json @@ -4,7 +4,8 @@ [ { - "namespace": "experimental.runtime", + "namespace": "runtime", + "documentation_permissions_required": ["runtime"], "functions": [ { "name": "getBackgroundPage", diff --git a/chrome/common/extensions/docs/api_index.html b/chrome/common/extensions/docs/api_index.html index b0c1118..5e6da5b 100644 --- a/chrome/common/extensions/docs/api_index.html +++ b/chrome/common/extensions/docs/api_index.html @@ -221,7 +221,7 @@ so that extensions can interact with the browser. Here are the supported chrome.* APIs: </p> <ul> - <li><a href="alarms.html" js="">alarms</a></li><li><a href="bookmarks.html" js="">bookmarks</a></li><li><a href="browserAction.html" js="">browserAction</a></li><li><a href="browsingData.html" js="">browsingData</a></li><li><a href="contentSettings.html" js="">contentSettings</a></li><li><a href="contextMenus.html" js="">contextMenus</a></li><li><a href="cookies.html" js="">cookies</a></li><li><a href="debugger.html" js="">debugger</a></li><li><a href="declarativeWebRequest.html" js="">declarativeWebRequest</a></li><li><a href="events.html" js="">events</a></li><li><a href="extension.html" js="">extension</a></li><li><a href="fileBrowserHandler.html" js="">fileBrowserHandler</a></li><li><a href="history.html" js="">history</a></li><li><a href="i18n.html" js="">i18n</a></li><li><a href="idle.html" js="">idle</a></li><li><a href="management.html" js="">management</a></li><li><a href="omnibox.html" js="">omnibox</a></li><li><a href="pageAction.html" js="">pageAction</a></li><li><a href="pageCapture.html" js="">pageCapture</a></li><li><a href="permissions.html" js="">permissions</a></li><li><a href="privacy.html" js="">privacy</a></li><li><a href="proxy.html" js="">proxy</a></li><li><a href="storage.html" js="">storage</a></li><li><a href="tabs.html" js="">tabs</a></li><li><a href="topSites.html" js="">topSites</a></li><li><a href="tts.html" js="">tts</a></li><li><a href="ttsEngine.html" js="">ttsEngine</a></li><li><a href="types.html" js="">types</a></li><li><a href="webNavigation.html" js="">webNavigation</a></li><li><a href="webRequest.html" js="">webRequest</a></li><li><a href="webstore.html" js="">webstore</a></li><li><a href="windows.html" js="">windows</a></li> + <li><a href="alarms.html" js="">alarms</a></li><li><a href="bookmarks.html" js="">bookmarks</a></li><li><a href="browserAction.html" js="">browserAction</a></li><li><a href="browsingData.html" js="">browsingData</a></li><li><a href="contentSettings.html" js="">contentSettings</a></li><li><a href="contextMenus.html" js="">contextMenus</a></li><li><a href="cookies.html" js="">cookies</a></li><li><a href="debugger.html" js="">debugger</a></li><li><a href="declarative.html" js="">declarative</a></li><li><a href="declarativeWebRequest.html" js="">declarativeWebRequest</a></li><li><a href="extension.html" js="">extension</a></li><li><a href="fileBrowserHandler.html" js="">fileBrowserHandler</a></li><li><a href="history.html" js="">history</a></li><li><a href="i18n.html" js="">i18n</a></li><li><a href="idle.html" js="">idle</a></li><li><a href="management.html" js="">management</a></li><li><a href="omnibox.html" js="">omnibox</a></li><li><a href="pageAction.html" js="">pageAction</a></li><li><a href="pageCapture.html" js="">pageCapture</a></li><li><a href="permissions.html" js="">permissions</a></li><li><a href="privacy.html" js="">privacy</a></li><li><a href="proxy.html" js="">proxy</a></li><li><a href="runtime.html" js="">runtime</a></li><li><a href="storage.html" js="">storage</a></li><li><a href="tabs.html" js="">tabs</a></li><li><a href="topSites.html" js="">topSites</a></li><li><a href="tts.html" js="">tts</a></li><li><a href="ttsEngine.html" js="">ttsEngine</a></li><li><a href="types.html" js="">types</a></li><li><a href="webNavigation.html" js="">webNavigation</a></li><li><a href="webRequest.html" js="">webRequest</a></li><li><a href="webstore.html" js="">webstore</a></li><li><a href="windows.html" js="">windows</a></li> </ul> <h2 id="experimental">Experimental APIs</h2> <p> diff --git a/chrome/common/extensions/docs/examples/api/eventPage/basic.zip b/chrome/common/extensions/docs/examples/api/eventPage/basic.zip Binary files differindex 8a93df3..7176956 100644 --- a/chrome/common/extensions/docs/examples/api/eventPage/basic.zip +++ b/chrome/common/extensions/docs/examples/api/eventPage/basic.zip diff --git a/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js b/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js index e9b2d25..606eb94 100644 --- a/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js +++ b/chrome/common/extensions/docs/examples/api/eventPage/basic/background.js @@ -18,7 +18,7 @@ sendMessage(); chrome.browserAction.setBadgeText({text: "ON"}); console.log("Loaded."); -chrome.experimental.runtime.onInstalled.addListener(function() { +chrome.runtime.onInstalled.addListener(function() { console.log("Installed."); // localStorage is persisted, so it's a good place to keep state that you @@ -79,7 +79,7 @@ chrome.alarms.onAlarm.addListener(function() { alert("Time's up!"); }); -chrome.experimental.runtime.onBackgroundPageUnloadingSoon.addListener( +chrome.runtime.onBackgroundPageUnloadingSoon.addListener( function() { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { // After the unload event listener runs, the page will unload, so any diff --git a/chrome/common/extensions/docs/experimental.html b/chrome/common/extensions/docs/experimental.html index 3a6eaed4..9e2a751 100644 --- a/chrome/common/extensions/docs/experimental.html +++ b/chrome/common/extensions/docs/experimental.html @@ -247,7 +247,6 @@ on the following experimental APIs: <a href="experimental.keybinding.html">experimental.keybinding</a></li><li> <a href="experimental.mediaGalleries.html">experimental.mediaGalleries</a></li><li> <a href="experimental.offscreenTabs.html">experimental.offscreenTabs</a></li><li> - <a href="experimental.runtime.html">experimental.runtime</a></li><li> <a href="experimental.speechInput.html">experimental.speechInput</a></li> </ul> <p> diff --git a/chrome/common/extensions/docs/js/api_page_generator.js b/chrome/common/extensions/docs/js/api_page_generator.js index 55f3bba..73772f9 100644 --- a/chrome/common/extensions/docs/js/api_page_generator.js +++ b/chrome/common/extensions/docs/js/api_page_generator.js @@ -47,7 +47,6 @@ var MODULE_SCHEMAS = [ '../api/experimental_offscreen_tabs.json', '../api/experimental_processes.json', '../api/experimental_rlz.json', - '../api/experimental_runtime.json', '../api/experimental_speech_input.json', '../api/extension.json', '../api/file_browser_handler.json', @@ -68,6 +67,7 @@ var MODULE_SCHEMAS = [ '../api/permissions.json', '../api/privacy.json', '../api/proxy.json', + '../api/runtime.json', '../api/storage.json', '../api/system_private.json', '../api/tabs.json', diff --git a/chrome/common/extensions/docs/experimental.runtime.html b/chrome/common/extensions/docs/runtime.html index cf39107..6ae55d6 100644 --- a/chrome/common/extensions/docs/experimental.runtime.html +++ b/chrome/common/extensions/docs/runtime.html @@ -18,7 +18,7 @@ <script type="text/javascript" src="js/api_page_generator.js"></script> <script type="text/javascript" src="js/bootstrap.js"></script> <script type="text/javascript" src="js/sidebar.js"></script> - <meta name="description" content="Documentation for the chrome.experimental.runtime module, which is part of the Google Chrome extension APIs."><title>chrome.experimental.runtime - Google Chrome Extensions - Google Code</title></head> + <meta name="description" content="Documentation for the chrome.runtime module, which is part of the Google Chrome extension APIs."><title>chrome.runtime - Google Chrome Extensions - Google Code</title></head> <body> <div id="devModeWarning" class="displayModeWarning"> You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files. </div> @@ -185,14 +185,14 @@ </script> <div class="g-unit" id="gc-pagecontent"> <div id="pageTitle"> - <h1 class="page_title">chrome.experimental.runtime</h1> + <h1 class="page_title">chrome.runtime</h1> </div> <!-- TABLE OF CONTENTS --> <div id="toc"> <h2>Contents</h2> <ol> <li> - <a href="#apiReference">API reference: chrome.experimental.runtime</a> + <a href="#apiReference">API reference: chrome.runtime</a> <ol> <li> <a href="#global-methods">Methods</a> @@ -218,15 +218,23 @@ </div> <!-- /TABLE OF CONTENTS --> <!-- Standard content lead-in for experimental API pages --> - <p id="classSummary"> - For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. + <p class="warning"> + <!-- Standard content lead-in for APIs that are not yet available on + the stable channel. --> + <em>Warning:</em> This API is still under development. It is only + available for Chrome users on the + <span> + <strong>dev</strong> + <a href="http://www.chromium.org/getting-involved/dev-channel">early + release channel</a>.</span> + <a href="TODO">Learn more</a>. </p> <!-- STATIC CONTENT PLACEHOLDER --> <div id="static"></div> <!-- API PAGE --> <div class="apiPage"> <a name="apiReference"></a> - <h2>API reference: chrome.experimental.runtime</h2> + <h2>API reference: chrome.runtime</h2> <!-- PROPERTIES --> <!-- /apiGroup --> <!-- METHODS --> @@ -239,7 +247,7 @@ <h4>getBackgroundPage</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span>chrome.experimental.runtime.getBackgroundPage</span>(<span class="null"><span>function</span> + <span>chrome.runtime.getBackgroundPage</span>(<span class="null"><span>function</span> <var><span>callback</span></var></span>)</div> <div class="description"> <p>Retrieves the JavaScript 'window' object for the background page running inside the current extension. If the background page is transient, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set.</p> @@ -329,7 +337,7 @@ <h4>onBackgroundPageUnloadingSoon</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span class="subdued">chrome.experimental.runtime.</span><span>onBackgroundPageUnloadingSoon</span><span class="subdued">.addListener</span>(function(<span></span>) <span class="subdued">{...}</span><span></span>); + <span class="subdued">chrome.runtime.</span><span>onBackgroundPageUnloadingSoon</span><span class="subdued">.addListener</span>(function(<span></span>) <span class="subdued">{...}</span><span></span>); </div> <div class="description"> <p>Sent to the transient background page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete.</p> @@ -345,7 +353,7 @@ <h4>onInstalled</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span class="subdued">chrome.experimental.runtime.</span><span>onInstalled</span><span class="subdued">.addListener</span>(function(<span></span>) <span class="subdued">{...}</span><span></span>); + <span class="subdued">chrome.runtime.</span><span>onInstalled</span><span class="subdued">.addListener</span>(function(<span></span>) <span class="subdued">{...}</span><span></span>); </div> <div class="description"> <p>Fired when the extension is first installed.</p> diff --git a/chrome/common/extensions/docs/samples.html b/chrome/common/extensions/docs/samples.html index 34164ef..76665fc 100644 --- a/chrome/common/extensions/docs/samples.html +++ b/chrome/common/extensions/docs/samples.html @@ -217,7 +217,7 @@ "4daa6becd0899a54776d9cf7f09613ed1a9f4d77": "COOKIE API TEST EXTENSION TESTING COOKIE API BACKGROUND_PAGE BROWSER_ACTION COOKIES TABS CHROME.BROWSERACTION.ONCLICKED CHROME.COOKIES.GET CHROME.COOKIES.GETALL CHROME.COOKIES.ONCHANGED CHROME.COOKIES.REMOVE CHROME.EXTENSION.GETURL CHROME.TABS.CREATE CHROME.TABS.UPDATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL", "9e4fd06300ee2b3a171e1f30d1b70f8f10152c2b": "DOWNLOAD SELECTED LINKS SELECT LINKS ON A PAGE AND DOWNLOAD THEM. BROWSER_ACTION EXPERIMENTAL TABS CHROME.EXPERIMENTAL.DOWNLOADS.DOWNLOAD CHROME.TABS.EXECUTESCRIPT CHROME.TABS.QUERY CHROME.WINDOWS.GET CHROME.WINDOWS.GETCURRENT", "028eb5364924344029bcbe1d527f132fc72b34e5": "EMAIL THIS PAGE (BY GOOGLE) THIS EXTENSION ADDS AN EMAIL BUTTON TO THE TOOLBAR WHICH ALLOWS YOU TO EMAIL THE PAGE LINK USING YOUR DEFAULT MAIL CLIENT OR GMAIL. BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS CHROME.BROWSERACTION.ONCLICKED CHROME.EXTENSION.CONNECT CHROME.EXTENSION.ONCONNECT CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.UPDATE", - "26115f23aef245d6757587e3e517bbe4b3bc55fe": "EVENT PAGE EXAMPLE DEMONSTRATES USAGE AND FEATURES OF THE EVENT PAGE ALARMS BACKGROUND_PAGE BOOKMARKS BROWSER_ACTION EXPERIMENTAL KEYBINDING TABS CHROME.ALARMS.CREATE CHROME.ALARMS.ONALARM CHROME.BOOKMARKS.ONREMOVED CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGETEXT CHROME.DECLARATIVEWEBREQUEST.ONREQUEST CHROME.EXPERIMENTAL.KEYBINDING.ONCOMMAND CHROME.EXPERIMENTAL.RUNTIME.ONBACKGROUNDPAGEUNLOADINGSOON CHROME.EXPERIMENTAL.RUNTIME.ONINSTALLED CHROME.EXTENSION.ONMESSAGE CHROME.EXTENSION.SENDMESSAGE CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.QUERY CHROME.TABS.SENDMESSAGE", + "26115f23aef245d6757587e3e517bbe4b3bc55fe": "EVENT PAGE EXAMPLE DEMONSTRATES USAGE AND FEATURES OF THE EVENT PAGE ALARMS BACKGROUND_PAGE BOOKMARKS BROWSER_ACTION EXPERIMENTAL KEYBINDING TABS CHROME.ALARMS.CREATE CHROME.ALARMS.ONALARM CHROME.BOOKMARKS.ONREMOVED CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGETEXT CHROME.DECLARATIVEWEBREQUEST.ONREQUEST CHROME.EXPERIMENTAL.KEYBINDING.ONCOMMAND CHROME.EXTENSION.ONMESSAGE CHROME.EXTENSION.SENDMESSAGE CHROME.RUNTIME.ONBACKGROUNDPAGEUNLOADINGSOON CHROME.RUNTIME.ONINSTALLED CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.QUERY CHROME.TABS.SENDMESSAGE", "763a08e9b06595d785568a8d392b95a2f3700258": "EVENT TRACKING WITH GOOGLE ANALYTICS A SAMPLE EXTENSION WHICH USES GOOGLE ANALYTICS TO TRACK USAGE. BROWSER_ACTION", "4efa12eaaa442b6b7c880e7a38ceeb0cff7e8b77": "FIREPHP FOR CHROME EXTENDS THE DEVELOPER TOOLS, ADDING SUPPORT FOR PARSING FIREPHP MESSAGES FROM SERVER BACKGROUND_PAGE DEVTOOLS_PAGE TABS CHROME.DEVTOOLS.NETWORK.GETHAR CHROME.DEVTOOLS.NETWORK.ONREQUESTFINISHED CHROME.TABS.EXECUTESCRIPT", "31d10fd5e61ca51eb59073b358d4ab5267cbf318": "FONT SETTINGS SAMPLE EXTENSION FOR FONT SETTINGS API BROWSER_ACTION EXPERIMENTAL POPUP CHROME.EXPERIMENTAL.FONTSETTINGS.GETDEFAULTFONTSIZE CHROME.EXPERIMENTAL.FONTSETTINGS.GETFONT CHROME.EXPERIMENTAL.FONTSETTINGS.GETFONTLIST CHROME.EXPERIMENTAL.FONTSETTINGS.SETDEFAULTFONTSIZE CHROME.EXPERIMENTAL.FONTSETTINGS.SETFONT", @@ -322,6 +322,8 @@ </span><span> <a href="javascript:void(0);" onclick="setFilter('chrome.proxy', this)">chrome.proxy</a><span>, </span> </span><span> + <a href="javascript:void(0);" onclick="setFilter('chrome.runtime', this)">chrome.runtime</a><span>, </span> + </span><span> <a href="javascript:void(0);" onclick="setFilter('chrome.storage', this)">chrome.storage</a><span>, </span> </span><span> <a href="javascript:void(0);" onclick="setFilter('chrome.tabs', this)">chrome.tabs</a><span>, </span> @@ -1396,14 +1398,14 @@ </li><li> <code><a href="experimental.keybinding.html#event-onCommand">chrome.experimental.keybinding.onCommand</a></code> </li><li> - <code><a href="experimental.runtime.html#event-onBackgroundPageUnloadingSoon">chrome.experimental.runtime.onBackgroundPageUnloadingSoon</a></code> - </li><li> - <code><a href="experimental.runtime.html#event-onInstalled">chrome.experimental.runtime.onInstalled</a></code> - </li><li> <code><a href="extension.html#event-onMessage">chrome.extension.onMessage</a></code> </li><li> <code><a href="extension.html#method-sendMessage">chrome.extension.sendMessage</a></code> </li><li> + <code><a href="runtime.html#event-onBackgroundPageUnloadingSoon">chrome.runtime.onBackgroundPageUnloadingSoon</a></code> + </li><li> + <code><a href="runtime.html#event-onInstalled">chrome.runtime.onInstalled</a></code> + </li><li> <code><a href="tabs.html#method-create">chrome.tabs.create</a></code> </li><li> <code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code> diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json index 21aee87..9f1472d 100644 --- a/chrome/common/extensions/docs/samples.json +++ b/chrome/common/extensions/docs/samples.json @@ -186,9 +186,6 @@ "chrome.experimental.offscreenTabs.update": "experimental.offscreenTabs.html#method-update", "chrome.experimental.record.captureURLs": "experimental.record.html#method-captureURLs", "chrome.experimental.record.replayURLs": "experimental.record.html#method-replayURLs", - "chrome.experimental.runtime.getBackgroundPage": "experimental.runtime.html#method-getBackgroundPage", - "chrome.experimental.runtime.onBackgroundPageUnloadingSoon": "experimental.runtime.html#event-onBackgroundPageUnloadingSoon", - "chrome.experimental.runtime.onInstalled": "experimental.runtime.html#event-onInstalled", "chrome.experimental.serial.close": "experimental.serial.html#method-close", "chrome.experimental.serial.getPorts": "experimental.serial.html#method-getPorts", "chrome.experimental.serial.open": "experimental.serial.html#method-open", @@ -273,6 +270,9 @@ "chrome.permissions.remove": "permissions.html#method-remove", "chrome.permissions.request": "permissions.html#method-request", "chrome.proxy.onProxyError": "proxy.html#event-onProxyError", + "chrome.runtime.getBackgroundPage": "runtime.html#method-getBackgroundPage", + "chrome.runtime.onBackgroundPageUnloadingSoon": "runtime.html#event-onBackgroundPageUnloadingSoon", + "chrome.runtime.onInstalled": "runtime.html#event-onInstalled", "chrome.storage.StorageArea.clear": "storage.html#method-StorageArea-clear", "chrome.storage.StorageArea.get": "storage.html#method-StorageArea-get", "chrome.storage.StorageArea.getBytesInUse": "storage.html#method-StorageArea-getBytesInUse", @@ -1066,10 +1066,10 @@ "chrome.browserAction.setBadgeText", "chrome.declarativeWebRequest.onRequest", "chrome.experimental.keybinding.onCommand", - "chrome.experimental.runtime.onBackgroundPageUnloadingSoon", - "chrome.experimental.runtime.onInstalled", "chrome.extension.onMessage", "chrome.extension.sendMessage", + "chrome.runtime.onBackgroundPageUnloadingSoon", + "chrome.runtime.onInstalled", "chrome.tabs.create", "chrome.tabs.executeScript", "chrome.tabs.query", @@ -1094,13 +1094,13 @@ "protocols": [ "http://" ], - "search_string": "EVENT PAGE EXAMPLE DEMONSTRATES USAGE AND FEATURES OF THE EVENT PAGE ALARMS BACKGROUND_PAGE BOOKMARKS BROWSER_ACTION EXPERIMENTAL KEYBINDING TABS CHROME.ALARMS.CREATE CHROME.ALARMS.ONALARM CHROME.BOOKMARKS.ONREMOVED CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGETEXT CHROME.DECLARATIVEWEBREQUEST.ONREQUEST CHROME.EXPERIMENTAL.KEYBINDING.ONCOMMAND CHROME.EXPERIMENTAL.RUNTIME.ONBACKGROUNDPAGEUNLOADINGSOON CHROME.EXPERIMENTAL.RUNTIME.ONINSTALLED CHROME.EXTENSION.ONMESSAGE CHROME.EXTENSION.SENDMESSAGE CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.QUERY CHROME.TABS.SENDMESSAGE", + "search_string": "EVENT PAGE EXAMPLE DEMONSTRATES USAGE AND FEATURES OF THE EVENT PAGE ALARMS BACKGROUND_PAGE BOOKMARKS BROWSER_ACTION EXPERIMENTAL KEYBINDING TABS CHROME.ALARMS.CREATE CHROME.ALARMS.ONALARM CHROME.BOOKMARKS.ONREMOVED CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGETEXT CHROME.DECLARATIVEWEBREQUEST.ONREQUEST CHROME.EXPERIMENTAL.KEYBINDING.ONCOMMAND CHROME.EXTENSION.ONMESSAGE CHROME.EXTENSION.SENDMESSAGE CHROME.RUNTIME.ONBACKGROUNDPAGEUNLOADINGSOON CHROME.RUNTIME.ONINSTALLED CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.QUERY CHROME.TABS.SENDMESSAGE", "source_files": [ "background.js", "content.js", "manifest.json" ], - "source_hash": "38978d01b1ba2d4c52e6dcb7b279c921d3c494c1", + "source_hash": "1fdea1f122a967980955e3f644e7563c1d435c61", "zip_path": "examples/api/eventPage/basic.zip" }, { diff --git a/chrome/common/extensions/extension_messages.h b/chrome/common/extensions/extension_messages.h index 03ade29..4b634a6 100644 --- a/chrome/common/extensions/extension_messages.h +++ b/chrome/common/extensions/extension_messages.h @@ -297,10 +297,15 @@ IPC_MESSAGE_ROUTED2(ExtensionMsg_DeliverMessage, int /* target_port_id */, std::string /* message */) +// Dispatch the Port.onDisconnect event for message channels. IPC_MESSAGE_ROUTED2(ExtensionMsg_DispatchOnDisconnect, int /* port_id */, bool /* connection_error */) +// Informs the renderer what channel (dev, beta, stable, etc) is running. +IPC_MESSAGE_CONTROL1(ExtensionMsg_SetChannel, + int /* channel */) + // Messages sent from the renderer to the browser. // A renderer sends this message when an extension process starts an API diff --git a/chrome/common/extensions/extension_permission_set.cc b/chrome/common/extensions/extension_permission_set.cc index 3d570d6b..d1d5b55 100644 --- a/chrome/common/extensions/extension_permission_set.cc +++ b/chrome/common/extensions/extension_permission_set.cc @@ -52,6 +52,7 @@ const char* kNonPermissionModuleNames[] = { "pageAction", "pageActions", "permissions", + "runtime", "test", "types" }; diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd index 93534a1..cf6ed5f 100644 --- a/chrome/common/extensions_api_resources.grd +++ b/chrome/common/extensions_api_resources.grd @@ -38,7 +38,6 @@ <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES" file="extensions\api\experimental_processes.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RECORD" file="extensions\api\experimental_record.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RLZ" file="extensions\api\experimental_rlz.json" type="BINDATA" /> - <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RUNTIME" file="extensions\api\experimental_runtime.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_SPEECHINPUT" file="extensions\api\experimental_speech_input.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXTENSION" file="extensions\api\extension.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER" file="extensions\api\file_browser_handler.json" type="BINDATA" /> @@ -59,6 +58,7 @@ <include name="IDR_EXTENSION_API_JSON_PERMISSIONS" file="extensions\api\permissions.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PRIVACY" file="extensions\api\privacy.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_PROXY" file="extensions\api\proxy.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_RUNTIME" file="extensions\api\runtime.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_STORAGE" file="extensions\api\storage.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_SYSTEMPRIVATE" file="extensions\api\system_private.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_TABS" file="extensions\api\tabs.json" type="BINDATA" /> diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc index 32c0b1d..9706f67 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -10,6 +10,7 @@ #include "base/string_piece.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/chrome_version_info.h" #include "chrome/common/chrome_view_type.h" #include "chrome/common/extensions/api/extension_api.h" #include "chrome/common/extensions/extension.h" @@ -92,8 +93,7 @@ namespace { static const int64 kInitialExtensionIdleHandlerDelayMs = 5*1000; static const int64 kMaxExtensionIdleHandlerDelayMs = 5*60*1000; static const char kEventDispatchFunction[] = "Event.dispatchJSON"; -static const char kOnUnloadEvent[] = - "experimental.runtime.onBackgroundPageUnloadingSoon"; +static const char kOnUnloadEvent[] = "runtime.onBackgroundPageUnloadingSoon"; class ChromeHiddenNativeHandler : public NativeHandler { public: @@ -179,6 +179,22 @@ class LazyBackgroundPageNativeHandler : public ChromeV8Extension { } }; +class ChannelNativeHandler : public NativeHandler { + public: + explicit ChannelNativeHandler(chrome::VersionInfo::Channel channel) + : channel_(channel) { + RouteFunction("IsDevChannel", + base::Bind(&ChannelNativeHandler::IsDevChannel, + base::Unretained(this))); + } + + v8::Handle<v8::Value> IsDevChannel(const v8::Arguments& args) { + return v8::Boolean::New(channel_ <= chrome::VersionInfo::CHANNEL_DEV); + } + + chrome::VersionInfo::Channel channel_; +}; + void InstallAppBindings(ModuleSystem* module_system, v8::Handle<v8::Object> chrome, v8::Handle<v8::Object> chrome_hidden) { @@ -204,7 +220,8 @@ ExtensionDispatcher::ExtensionDispatcher() webrequest_adblock_(false), webrequest_adblock_plus_(false), webrequest_other_(false), - source_map_(&ResourceBundle::GetSharedInstance()) { + source_map_(&ResourceBundle::GetSharedInstance()), + chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); is_extension_process_ = command_line.HasSwitch(switches::kExtensionProcess) || @@ -228,6 +245,7 @@ bool ExtensionDispatcher::OnControlMessageReceived( const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ExtensionDispatcher, message) + IPC_MESSAGE_HANDLER(ExtensionMsg_SetChannel, OnSetChannel) IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnMessageInvoke) IPC_MESSAGE_HANDLER(ExtensionMsg_DispatchOnConnect, OnDispatchOnConnect) IPC_MESSAGE_HANDLER(ExtensionMsg_DeliverMessage, OnDeliverMessage) @@ -292,6 +310,10 @@ void ExtensionDispatcher::OnSetFunctionNames( function_names_.insert(names[i]); } +void ExtensionDispatcher::OnSetChannel(int channel) { + chrome_channel_ = channel; +} + void ExtensionDispatcher::OnMessageInvoke(const std::string& extension_id, const std::string& function_name, const ListValue& args, @@ -525,8 +547,6 @@ void ExtensionDispatcher::PopulateSourceMap() { IDR_MEDIA_GALLERY_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("experimental.offscreen", IDR_EXPERIMENTAL_OFFSCREENTABS_CUSTOM_BINDINGS_JS); - source_map_.RegisterSource("experimental.runtime", - IDR_EXPERIMENTAL_RUNTIME_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("experimental.usb", IDR_EXPERIMENTAL_USB_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("extension", IDR_EXTENSION_CUSTOM_BINDINGS_JS); @@ -544,6 +564,7 @@ void ExtensionDispatcher::PopulateSourceMap() { source_map_.RegisterSource("pageCapture", IDR_PAGE_CAPTURE_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); + source_map_.RegisterSource("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("storage", IDR_STORAGE_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("tabs", IDR_TABS_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("tts", IDR_TTS_CUSTOM_BINDINGS_JS); @@ -621,6 +642,9 @@ void ExtensionDispatcher::DidCreateScriptContext( scoped_ptr<NativeHandler>(new PrintNativeHandler())); module_system->RegisterNativeHandler("lazy_background_page", scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this))); + module_system->RegisterNativeHandler("channel", + scoped_ptr<NativeHandler>(new ChannelNativeHandler( + static_cast<chrome::VersionInfo::Channel>(chrome_channel_)))); int manifest_version = 1; if (extension) diff --git a/chrome/renderer/extensions/extension_dispatcher.h b/chrome/renderer/extensions/extension_dispatcher.h index cb7f60a..086656f 100644 --- a/chrome/renderer/extensions/extension_dispatcher.h +++ b/chrome/renderer/extensions/extension_dispatcher.h @@ -122,6 +122,7 @@ class ExtensionDispatcher : public content::RenderProcessObserver { virtual void WebKitInitialized() OVERRIDE; virtual void IdleNotification() OVERRIDE; + void OnSetChannel(int channel); void OnMessageInvoke(const std::string& extension_id, const std::string& function_name, const base::ListValue& args, @@ -237,6 +238,10 @@ class ExtensionDispatcher : public content::RenderProcessObserver { // Sends API requests to the extension host. scoped_ptr<ExtensionRequestSender> request_sender_; + // The current channel. From VersionInfo::GetChannel(). + // TODO(aa): Remove when we can restrict non-permission APIs to dev-only. + int chrome_channel_; + DISALLOW_COPY_AND_ASSIGN(ExtensionDispatcher); }; diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd index 86594ee..a9256645 100644 --- a/chrome/renderer/renderer_resources.grd +++ b/chrome/renderer/renderer_resources.grd @@ -43,7 +43,6 @@ without changes to the corresponding grd file. fb9 --> <include name="IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS" file="resources\extensions\declarative_webrequest_custom_bindings.js" type="BINDATA" /> <include name="IDR_DEVTOOLS_CUSTOM_BINDINGS_JS" file="resources\extensions\devtools_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXPERIMENTAL_OFFSCREENTABS_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.offscreenTabs_custom_bindings.js" type="BINDATA" /> - <include name="IDR_EXPERIMENTAL_RUNTIME_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.runtime_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXPERIMENTAL_USB_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.usb_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXTENSION_CUSTOM_BINDINGS_JS" file="resources\extensions\extension_custom_bindings.js" type="BINDATA" /> <include name="IDR_FILE_BROWSER_HANDLER_CUSTOM_BINDINGS_JS" file="resources\extensions\file_browser_handler_custom_bindings.js" type="BINDATA" /> @@ -55,6 +54,7 @@ without changes to the corresponding grd file. fb9 --> <include name="IDR_PAGE_ACTIONS_CUSTOM_BINDINGS_JS" file="resources\extensions\page_actions_custom_bindings.js" type="BINDATA" /> <include name="IDR_PAGE_ACTION_CUSTOM_BINDINGS_JS" file="resources\extensions\page_action_custom_bindings.js" type="BINDATA" /> <include name="IDR_PAGE_CAPTURE_CUSTOM_BINDINGS_JS" file="resources\extensions\page_capture_custom_bindings.js" type="BINDATA" /> + <include name="IDR_RUNTIME_CUSTOM_BINDINGS_JS" file="resources\extensions\runtime_custom_bindings.js" type="BINDATA" /> <include name="IDR_STORAGE_CUSTOM_BINDINGS_JS" file="resources\extensions\storage_custom_bindings.js" type="BINDATA" /> <include name="IDR_TABS_CUSTOM_BINDINGS_JS" file="resources\extensions\tabs_custom_bindings.js" type="BINDATA" /> <include name="IDR_TTS_CUSTOM_BINDINGS_JS" file="resources\extensions\tts_custom_bindings.js" type="BINDATA" /> diff --git a/chrome/renderer/resources/extensions/experimental.runtime_custom_bindings.js b/chrome/renderer/resources/extensions/runtime_custom_bindings.js index 7d70ee2..8fb713f 100644 --- a/chrome/renderer/resources/extensions/experimental.runtime_custom_bindings.js +++ b/chrome/renderer/resources/extensions/runtime_custom_bindings.js @@ -9,7 +9,7 @@ var GetExtensionViews = extensionNatives.GetExtensionViews; var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); var sendRequest = require('sendRequest').sendRequest; -chromeHidden.registerCustomHook('experimental.runtime', function(bindingsAPI) { +chromeHidden.registerCustomHook('runtime', function(bindingsAPI) { var apiFunctions = bindingsAPI.apiFunctions; apiFunctions.setCustomCallback('getBackgroundPage', diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js index d28c7d5..29700bb 100644 --- a/chrome/renderer/resources/extensions/schema_generated_bindings.js +++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js @@ -14,7 +14,7 @@ requireNative('apiDefinitions').GetExtensionAPIDefinition; var sendRequest = require('sendRequest').sendRequest; var utils = require('utils'); - + var isDevChannel = requireNative('channel').IsDevChannel; var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); // The object to generate the bindings for "internal" APIs in, so that @@ -338,9 +338,18 @@ manifestVersion <= schemaNode.maximumManifestVersion; } + // Temporary hack to check if the runtime API is supported. + // TODO(aa): Remove when we can restrict non-permission APIs to dev-only. + function isRuntimeAPISupported(schemaNode) { + if (schemaNode.namespace == "runtime") + return isDevChannel(); + return true; + } + function isSchemaNodeSupported(schemaNode, platform, manifestVersion) { return isPlatformSupported(schemaNode, platform) && - isManifestVersionSupported(schemaNode, manifestVersion); + isManifestVersionSupported(schemaNode, manifestVersion) && + isRuntimeAPISupported(schemaNode); } chromeHidden.onLoad.addListener(function(extensionId, diff --git a/chrome/test/data/extensions/api_test/lazy_background_page/on_installed/background.js b/chrome/test/data/extensions/api_test/lazy_background_page/on_installed/background.js index 09ab2f4..5e11ef4 100644 --- a/chrome/test/data/extensions/api_test/lazy_background_page/on_installed/background.js +++ b/chrome/test/data/extensions/api_test/lazy_background_page/on_installed/background.js @@ -2,6 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.experimental.runtime.onInstalled.addListener(function() { +chrome.runtime.onInstalled.addListener(function() { chrome.test.notifyPass(); }); diff --git a/chrome/test/data/extensions/api_test/lazy_background_page/on_unload/background.js b/chrome/test/data/extensions/api_test/lazy_background_page/on_unload/background.js index 4f24c53..c841940 100644 --- a/chrome/test/data/extensions/api_test/lazy_background_page/on_unload/background.js +++ b/chrome/test/data/extensions/api_test/lazy_background_page/on_unload/background.js @@ -3,7 +3,7 @@ // found in the LICENSE file. chrome.browserAction.setTitle({title: "Failure"}); -chrome.experimental.runtime.onBackgroundPageUnloadingSoon.addListener( +chrome.runtime.onBackgroundPageUnloadingSoon.addListener( function() { chrome.browserAction.setTitle({title: "Success"}); }); diff --git a/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js b/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js index 70d6317..0d9972d 100644 --- a/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js +++ b/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_request/background.js @@ -15,7 +15,7 @@ function abortRequest() { window.domAutomationController.send(true); } -chrome.experimental.runtime.onInstalled.addListener(function() { +chrome.runtime.onInstalled.addListener(function() { chrome.test.getConfig(function(config) { testServerPort = config.testServer.port; diff --git a/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_view/background.js b/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_view/background.js index 56ac614..d5c7bc0 100644 --- a/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_view/background.js +++ b/chrome/test/data/extensions/api_test/lazy_background_page/wait_for_view/background.js @@ -2,6 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -chrome.experimental.runtime.onInstalled.addListener(function() { +chrome.runtime.onInstalled.addListener(function() { chrome.tabs.create({url: "extension_page.html"}, chrome.test.callbackPass()); }); |