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 25180a0c68ca0417c0f481618745974ab0a27048..ead8ed34dd2920fff24f79830d27e0c7edd920a8 100644 |
| --- a/chrome/browser/ui/app_list/app_list_view_delegate.cc |
| +++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc |
| @@ -103,6 +103,29 @@ 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) { |
| + // 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 { |
| + 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. |
| +} |
| + |
| } // namespace |
| AppListViewDelegate::AppListViewDelegate(Profile* profile, |
| @@ -148,23 +171,18 @@ AppListViewDelegate::AppListViewDelegate(Profile* profile, |
| if (service) |
| service->AddObserver(this); |
| - // Set up the custom launcher page. There is currently only a single custom |
| - // page allowed, which is specified as a command-line flag. In the future, |
| - // arbitrary extensions may be able to specify their own custom pages. |
| - 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)) { |
| - LOG(ERROR) << "Invalid custom launcher page URL: " |
| - << custom_launcher_page_url.possibly_invalid_spec(); |
| - } else { |
| - std::string extension_id = custom_launcher_page_url.host(); |
| - custom_page_contents_.reset(new apps::CustomLauncherPageContents( |
| - scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id)); |
| - custom_page_contents_->Initialize(profile, custom_launcher_page_url); |
| - } |
| + // Set up the custom launcher pages. |
| + std::vector<GURL> custom_launcher_page_urls; |
| + GetCustomLauncherPageUrls(&custom_launcher_page_urls); |
| + for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); |
| + it != custom_launcher_page_urls.end(); |
| + ++it) { |
| + std::string extension_id = id->host(); |
|
calamity
2014/08/11 05:35:26
it->host()?
Matt Giuca
2014/08/11 06:14:05
Done.
|
| + apps::CustomLauncherPageContents* page_contents = |
| + new apps::CustomLauncherPageContents( |
| + scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id); |
|
calamity
2014/08/11 05:35:26
What happens if this extension_id is invalid?
Matt Giuca
2014/08/11 06:14:05
It has some potentially deep consequences but noth
|
| + page_contents->Initialize(profile, *it); |
| + custom_page_contents_.push_back(page_contents); |
| } |
| } |
| @@ -475,19 +493,25 @@ views::View* AppListViewDelegate::CreateStartPageWebView( |
| return web_view; |
| } |
| -views::View* AppListViewDelegate::CreateCustomPageWebView( |
| +std::vector<views::View*> AppListViewDelegate::CreateCustomPageWebViews( |
| const gfx::Size& size) { |
| - if (!custom_page_contents_) |
| - return NULL; |
| + std::vector<views::View*> web_views; |
| + |
| + for (ScopedVector<apps::CustomLauncherPageContents>::const_iterator it = |
| + custom_page_contents_.begin(); |
| + it != custom_page_contents_.end(); |
| + ++it) { |
| + content::WebContents* web_contents = (*it)->web_contents(); |
| + // TODO(mgiuca): DCHECK_EQ(profile_, web_contents->GetBrowserContext()) |
| + // after http://crbug.com/392763 resolved. |
| + views::WebView* web_view = |
| + new views::WebView(web_contents->GetBrowserContext()); |
| + web_view->SetPreferredSize(size); |
| + web_view->SetWebContents(web_contents); |
| + web_views.push_back(web_view); |
| + } |
| - content::WebContents* web_contents = custom_page_contents_->web_contents(); |
| - // TODO(mgiuca): DCHECK_EQ(profile_, web_contents->GetBrowserContext()) after |
| - // http://crbug.com/392763 resolved. |
| - views::WebView* web_view = |
| - new views::WebView(web_contents->GetBrowserContext()); |
| - web_view->SetPreferredSize(size); |
| - web_view->SetWebContents(web_contents); |
| - return web_view; |
| + return web_views; |
| } |
| #endif |