Chromium Code Reviews| Index: chrome/browser/ui/app_list/app_list_view_delegate.cc |
| 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 7e7a94b65efe7c864bc1d6c9f2d30816f95e35f6..09b507c9de82057a3fc7e6d4d000c8534da20b48 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,14 +109,14 @@ 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() && |
| command_line->HasSwitch(switches::kCustomLauncherPage)) { |
| GURL custom_launcher_page_url( |
| command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); |
| - |
| if (custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { |
| urls->push_back(custom_launcher_page_url); |
| } else { |
| @@ -122,8 +125,29 @@ void GetCustomLauncherPageUrls(std::vector<GURL>* urls) { |
| } |
| } |
| - // 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 " |
| + << extensions::manifest_keys::kLauncherPagePage |
| + << ". Ignoring launcher page."; |
|
Matt Giuca
2014/08/15 04:17:09
This makes a pretty comical error message now:
"la
Matt Giuca
2014/08/15 04:20:00
Done.
|
| + continue; |
| + } |
| + urls->push_back(extension->GetResourceURL(launcher_page_page)); |
| + } |
| } |
| } // namespace |
| @@ -173,7 +197,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) { |