diff options
author | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 17:51:22 +0000 |
---|---|---|
committer | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 17:51:22 +0000 |
commit | 009187e9e312224df3360c43c073f3927decc823 (patch) | |
tree | fd6261e977a5203fde09baaee7d230fce705aa1a | |
parent | 637d547712237471390ac9e70697d8f4494ddba2 (diff) | |
download | chromium_src-009187e9e312224df3360c43c073f3927decc823.zip chromium_src-009187e9e312224df3360c43c073f3927decc823.tar.gz chromium_src-009187e9e312224df3360c43c073f3927decc823.tar.bz2 |
Added 'launcher_page' field to extension manifest.json format.
Adds a new manifest section which allows extensions (currently, only
platform apps) to provide a page in the experimental app launcher, eg:
"launcher_page": {
"page": "index.html"
}
All installed apps with a valid launcher_page section will be given a
page in the launcher.
This feature is currently only available on dev channel and whitelisted
(currently to a few testing apps; this list will expand in the future,
and can be overridden with --whitelisted-extension-id=ID).
Updated CustomLauncherPageBrowserTest to use its manifest to install the
launcher page, rather than using --custom-launcher-page.
BUG=399131,404000
Review URL: https://codereview.chromium.org/475543004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289931 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 54 insertions, 11 deletions
diff --git a/chrome/browser/apps/custom_launcher_page_browsertest_views.cc b/chrome/browser/apps/custom_launcher_page_browsertest_views.cc index 667244c..ac4c0eb 100644 --- a/chrome/browser/apps/custom_launcher_page_browsertest_views.cc +++ b/chrome/browser/apps/custom_launcher_page_browsertest_views.cc @@ -7,8 +7,8 @@ #include "base/command_line.h" #include "chrome/browser/apps/app_browsertest_util.h" #include "chrome/browser/ui/app_list/app_list_service.h" -#include "chrome/common/chrome_switches.h" #include "extensions/common/extension.h" +#include "extensions/common/switches.h" #include "ui/app_list/app_list_switches.h" namespace { @@ -16,9 +16,8 @@ namespace { // The path of the test application within the "platform_apps" directory. const char kCustomLauncherPagePath[] = "custom_launcher_page"; -// The app ID and URL of the test application. -const char kCustomLauncherPageUrl[] = - "chrome-extension://lmadimbbgapmngbiclpjjngmdickadpl/main.html"; +// The app ID of the test application. +const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl"; } // namespace @@ -36,8 +35,10 @@ class CustomLauncherPageBrowserTest // Custom launcher pages only work in the experimental app list. command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); - command_line->AppendSwitchASCII(switches::kCustomLauncherPage, - kCustomLauncherPageUrl); + + // The test app must be whitelisted to use launcher_page. + command_line->AppendSwitchASCII( + extensions::switches::kWhitelistedExtensionID, kCustomLauncherPageID); } // Open the launcher. Ignores the Extension argument (this will simply diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.cc b/chrome/browser/ui/app_list/app_list_view_delegate.cc index 7e7a94b..be225de 100644 --- a/chrome/browser/ui/app_list/app_list_view_delegate.cc +++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc @@ -40,6 +40,9 @@ #include "content/public/browser/web_contents.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/constants.h" +#include "extensions/common/extension_set.h" +#include "extensions/common/manifest.h" +#include "extensions/common/manifest_constants.h" #include "grit/theme_resources.h" #include "ui/app_list/app_list_switches.h" #include "ui/app_list/app_list_view_delegate_observer.h" @@ -106,7 +109,8 @@ void PopulateUsers(const ProfileInfoCache& profile_info, // Gets a list of URLs of the custom launcher pages to show in the launcher. // Returns a URL for each installed launcher page. If --custom-launcher-page is // specified and valid, also includes that URL. -void GetCustomLauncherPageUrls(std::vector<GURL>* urls) { +void GetCustomLauncherPageUrls(content::BrowserContext* browser_context, + std::vector<GURL>* urls) { // First, check the command line. base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (app_list::switches::IsExperimentalAppListEnabled() && @@ -117,13 +121,35 @@ void GetCustomLauncherPageUrls(std::vector<GURL>* urls) { if (custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { urls->push_back(custom_launcher_page_url); } else { + // TODO(mgiuca): Add a proper manifest parser to catch this error properly + // and display it on the extensions page. LOG(ERROR) << "Invalid custom launcher page URL: " << custom_launcher_page_url.possibly_invalid_spec(); } } - // TODO(mgiuca): Search the list of installed extensions and add any with a - // 'launcher_page' attribute in its manifest. + // Search the list of installed extensions for ones with 'launcher_page'. + extensions::ExtensionRegistry* extension_registry = + extensions::ExtensionRegistry::Get(browser_context); + const extensions::ExtensionSet& enabled_extensions = + extension_registry->enabled_extensions(); + for (extensions::ExtensionSet::const_iterator it = enabled_extensions.begin(); + it != enabled_extensions.end(); + ++it) { + const extensions::Extension* extension = it->get(); + const extensions::Manifest* manifest = extension->manifest(); + if (!manifest->HasKey(extensions::manifest_keys::kLauncherPage)) + continue; + std::string launcher_page_page; + if (!manifest->GetString(extensions::manifest_keys::kLauncherPagePage, + &launcher_page_page)) { + LOG(ERROR) << "Extension " << extension->id() << ": " + << extensions::manifest_keys::kLauncherPage + << " has no 'page' attribute; will be ignored."; + continue; + } + urls->push_back(extension->GetResourceURL(launcher_page_page)); + } } } // namespace @@ -173,7 +199,7 @@ AppListViewDelegate::AppListViewDelegate(Profile* profile, // Set up the custom launcher pages. std::vector<GURL> custom_launcher_page_urls; - GetCustomLauncherPageUrls(&custom_launcher_page_urls); + GetCustomLauncherPageUrls(profile, &custom_launcher_page_urls); for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); it != custom_launcher_page_urls.end(); ++it) { diff --git a/chrome/common/extensions/api/_manifest_features.json b/chrome/common/extensions/api/_manifest_features.json index 8bdb323..16156237 100644 --- a/chrome/common/extensions/api/_manifest_features.json +++ b/chrome/common/extensions/api/_manifest_features.json @@ -224,6 +224,16 @@ "channel": "stable", "extension_types": "all" }, + "launcher_page": { + "channel": "stable", + "min_manifest_version": 2, + "extension_types": ["platform_app"], + "whitelist": [ + "07BD6A765FFC289FF755D7CAB2893A40EC337FEC", // http://crbug.com/404000 + "896B85CC7E913E11C34892C1425A093C0701D386", // http://crbug.com/404000 + "11A01C82EF355E674E4F9728A801F5C3CB40D83F" // http://crbug.com/404000 + ] + }, "manifest_version": { "channel": "stable", "extension_types": "all" diff --git a/chrome/test/data/extensions/platform_apps/custom_launcher_page/manifest.json b/chrome/test/data/extensions/platform_apps/custom_launcher_page/manifest.json index 5850b28..175bc5e 100644 --- a/chrome/test/data/extensions/platform_apps/custom_launcher_page/manifest.json +++ b/chrome/test/data/extensions/platform_apps/custom_launcher_page/manifest.json @@ -4,10 +4,12 @@ "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv7Qi8BghDr2b2Wdg5vv7vGWQxWpo6dD4Jt3okhb3oOF0zmnhr1G/e16J8WxtygaF2mshjVP11/j/yu8n7AsrFw5hwi3ROwmsB8T1vB+rHGh9NfF/iX8w1z2rLkXlPemHof7nzC67Y3TRrl0ONqIO4ef9z4NEnnzQ0EeIX51924G5pj9YjTderWIso9+8mehelDwMgBZu66T1jTuxq4SOEvuDe9IKXwJfVPfhTf0f8YAH+NUdleKY+2zR7u8BDK42OkhhKs4XB3ZHDTr+n7KObXYXJukpr/eNqbXyU4lsUlJobFDzygZxjEOw87HhP9fK3V0v+eYrQ4+9JctqxorT5wIDAQAB", "version": "1", "manifest_version": 2, - // Currently necessary to give it an app context. "app": { "background": { "scripts": ["dummy.js"] } + }, + "launcher_page": { + "page": "main.html" } } diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc index 95d6d8b..fbf3229 100644 --- a/extensions/common/manifest_constants.cc +++ b/extensions/common/manifest_constants.cc @@ -68,6 +68,8 @@ const char kKioskMode[] = "kiosk_mode"; const char kLanguage[] = "language"; const char kLaunch[] = "app.launch"; const char kLaunchContainer[] = "app.launch.container"; +const char kLauncherPage[] = "launcher_page"; +const char kLauncherPagePage[] = "launcher_page.page"; const char kLaunchHeight[] = "app.launch.height"; const char kLaunchLocalPath[] = "app.launch.local_path"; const char kLaunchWebURL[] = "app.launch.web_url"; diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h index 9852e88..f9246cb 100644 --- a/extensions/common/manifest_constants.h +++ b/extensions/common/manifest_constants.h @@ -77,6 +77,8 @@ extern const char kKioskMode[]; extern const char kLanguage[]; extern const char kLaunch[]; extern const char kLaunchContainer[]; +extern const char kLauncherPage[]; +extern const char kLauncherPagePage[]; extern const char kLaunchHeight[]; extern const char kLaunchLocalPath[]; extern const char kLaunchWebURL[]; |