diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 14:33:19 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 14:33:19 +0000 |
commit | fe13bf66690fa7bc1ff25c4714b9c72c3777ee2d (patch) | |
tree | 94e1f4559ffd7999e6c8e18f5744217beb93e97b /chrome/browser | |
parent | 5b885310bd6498cde3e3c3f821db56f2bd9e6e26 (diff) | |
download | chromium_src-fe13bf66690fa7bc1ff25c4714b9c72c3777ee2d.zip chromium_src-fe13bf66690fa7bc1ff25c4714b9c72c3777ee2d.tar.gz chromium_src-fe13bf66690fa7bc1ff25c4714b9c72c3777ee2d.tar.bz2 |
Re-land 57460 - Add hidden component app for web store.
Fixed ExtensionStartupTest which was essentially counting the number of component extensions. Now it doesn't.
Original review here: http://codereview.chromium.org/3116040
This patch adds a component which does not appear on the NTP, but does enforce that gallery urls are isolated in their own process. This is in anticipation of exposing extension api bindings to the gallery so it can install/detect/uninstall extensions & apps.
Note that this patch works correctly with the --apps-gallery-url. If specified, the replacement url will be inserted into the component app's extent
BUG=27431
TBR=aa
Review URL: http://codereview.chromium.org/3104039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_resources.grd | 1 | ||||
-rw-r--r-- | chrome/browser/dom_ui/app_launcher_handler.cc | 13 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_startup_browsertest.cc | 18 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 15 | ||||
-rw-r--r-- | chrome/browser/profile_impl.cc | 4 | ||||
-rw-r--r-- | chrome/browser/resources/webstore_app/manifest.json | 20 |
6 files changed, 61 insertions, 10 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 24b9baf..648ba2b 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -62,6 +62,7 @@ without changes to the corresponding grd file. eadeae--> <include name="IDR_TRANSLATE_JS" file="resources\translate.js" type="BINDATA" /> <include name="IDR_BUGREPORT_HTML" file="resources\bug_report.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_BUGREPORT_HTML_INVALID" file="resources\bug_report_invalid.html" flattenhtml="true" type="BINDATA" /> + <include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" /> <if expr="pp_ifdef('chromeos')"> <include name="IDR_ABOUT_SYS_HTML" file="resources\about_sys.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_FILEBROWSE_HTML" file="resources\filebrowse.html" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc index 825be90..d05ebf7 100644 --- a/chrome/browser/dom_ui/app_launcher_handler.cc +++ b/chrome/browser/dom_ui/app_launcher_handler.cc @@ -16,6 +16,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" +#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" @@ -109,11 +110,13 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) { const ExtensionList* extensions = extensions_service_->extensions(); for (ExtensionList::const_iterator it = extensions->begin(); it != extensions->end(); ++it) { - if ((*it)->is_app()) { - DictionaryValue* app_info = new DictionaryValue(); - CreateAppInfo(*it, app_info); - list->Append(app_info); - } + // Don't include the WebStore component app. The WebStore launcher + // gets special treatment in ntp/apps.js. + if ((*it)->is_app() && (*it)->id() != extension_misc::kWebStoreAppId) { + DictionaryValue* app_info = new DictionaryValue(); + CreateAppInfo(*it, app_info); + list->Append(app_info); + } } dictionary.Set("apps", list); diff --git a/chrome/browser/extensions/extension_startup_browsertest.cc b/chrome/browser/extensions/extension_startup_browsertest.cc index 9ca4d081..5342bc1 100644 --- a/chrome/browser/extensions/extension_startup_browsertest.cc +++ b/chrome/browser/extensions/extension_startup_browsertest.cc @@ -32,9 +32,11 @@ class ExtensionStartupTestBase : public InProcessBrowserTest { public: ExtensionStartupTestBase() : enable_extensions_(false) { #if defined(OS_CHROMEOS) - num_expected_extensions_ = 3; + // Chromeos disallows extensions with NPAPI plug-ins, so it's count is one + // less + num_expected_extensions_ = 2; #else - num_expected_extensions_ = 4; + num_expected_extensions_ = 3; #endif } @@ -86,8 +88,14 @@ class ExtensionStartupTestBase : public InProcessBrowserTest { ui_test_utils::WaitForNotification(NotificationType::EXTENSIONS_READY); ASSERT_TRUE(service->is_ready()); + // Count the number of non-component extensions. + int found_extensions = 0; + for (size_t i = 0; i < service->extensions()->size(); i++) + if (service->extensions()->at(i)->location() != Extension::COMPONENT) + found_extensions++; + ASSERT_EQ(static_cast<uint32>(num_expected_extensions), - service->extensions()->size()); + static_cast<uint32>(found_extensions)); ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); UserScriptMaster* master = browser()->profile()->GetUserScriptMaster(); @@ -146,7 +154,6 @@ class ExtensionsStartupTest : public ExtensionStartupTestBase { }; IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, Test) { - // 1 component extension and 2 or 3 others, depending on the platform. WaitForServicesToStart(num_expected_extensions_, true); TestInjection(true, true); } @@ -160,11 +167,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, Test) { // Tests that disallowing file access on an extension prevents it from injecting // script into a page with a file URL. IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) { - // 1 component extension and 2 or 3 others, depending on the platform. WaitForServicesToStart(num_expected_extensions_, true); ExtensionsService* service = browser()->profile()->GetExtensionsService(); for (size_t i = 0; i < service->extensions()->size(); ++i) { + if (service->extensions()->at(i)->location() == Extension::COMPONENT) + continue; if (service->AllowFileAccess(service->extensions()->at(i))) { service->SetAllowFileAccess(service->extensions()->at(i), false); ui_test_utils::WaitForNotification( diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 169f15f..3fb4a91 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -530,6 +530,21 @@ void ExtensionsService::LoadComponentExtensions() { return; } + // In order for the --apps-gallery-url switch to work with the gallery + // process isolation, we must insert any provided value into the component + // app's launch url and web extent. + if (extension->id() == extension_misc::kWebStoreAppId ) { + GURL gallery_url(CommandLine::ForCurrentProcess() + ->GetSwitchValueASCII(switches::kAppsGalleryURL)); + if (gallery_url.is_valid()) { + extension->set_launch_web_url(gallery_url.spec()); + URLPattern pattern(URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS); + pattern.Parse(gallery_url.spec()); + pattern.set_path(pattern.path() + '*'); + extension->web_extent().AddPattern(pattern); + } + } + OnExtensionLoaded(extension.release(), false); // Don't allow privilege // increase. } diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc index 64027a1..677cf69 100644 --- a/chrome/browser/profile_impl.cc +++ b/chrome/browser/profile_impl.cc @@ -391,6 +391,10 @@ void ProfileImpl::InitExtensions() { component_extensions.push_back( std::make_pair("bookmark_manager", IDR_BOOKMARKS_MANIFEST)); + // Web Store. + component_extensions.push_back( + std::make_pair("web_store", IDR_WEBSTORE_MANIFEST)); + // Some sample apps to make our lives easier while we are developing extension // apps. This way we don't have to constantly install these over and over. if (Extension::AppsAreEnabled() && IncludeDefaultApps()) { diff --git a/chrome/browser/resources/webstore_app/manifest.json b/chrome/browser/resources/webstore_app/manifest.json new file mode 100644 index 0000000..0b94ace --- /dev/null +++ b/chrome/browser/resources/webstore_app/manifest.json @@ -0,0 +1,20 @@ +{ + "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtl3tO0osjuzRsf6xtD2SKxPlTfuoy7AWoObysitBPvH5fE1NaAA1/2JkPWkVDhdLBWLaIBPYeXbzlHp3y4Vv/4XG+aN5qFE3z+1RU/NqkzVYHtIpVScf3DjTYtKVL66mzVGijSoAIwbFCC3LpGdaoe6Q1rSRDp76wR6jjFzsYwQIDAQAB", + "name": "Chrome Web Store", + "version": "0.1", + "description": "Web Store", + "icons": { + }, + "app": { + "launch": { + "web_url": "https://chrome.google.com/extensions" + }, + "urls": [ + "https://chrome.google.com/extensions", + "https://clients2.google.com/service/update2", + "https://clients2.googleusercontent.com/crx" + ] + }, + "permissions": [ + ] +} |