Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 365013003: Experimental app list: Custom launcher pages have app APIs and style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made APIs work by introducing CustomLauncherPageContents. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "apps/custom_launcher_page_contents.h"
9 #include "base/callback.h" 10 #include "base/callback.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/metrics/user_metrics.h" 13 #include "base/metrics/user_metrics.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
16 #include "chrome/browser/profiles/profile_info_cache.h" 18 #include "chrome/browser/profiles/profile_info_cache.h"
17 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/search/hotword_service.h" 20 #include "chrome/browser/search/hotword_service.h"
19 #include "chrome/browser/search/hotword_service_factory.h" 21 #include "chrome/browser/search/hotword_service_factory.h"
20 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 22 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
21 #include "chrome/browser/ui/app_list/app_list_service.h" 23 #include "chrome/browser/ui/app_list/app_list_service.h"
22 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 24 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
23 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 25 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
24 #include "chrome/browser/ui/app_list/search/search_controller.h" 26 #include "chrome/browser/ui/app_list/search/search_controller.h"
25 #include "chrome/browser/ui/app_list/start_page_service.h" 27 #include "chrome/browser/ui/app_list/start_page_service.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // arbitrary extensions may be able to specify their own custom pages. 157 // arbitrary extensions may be able to specify their own custom pages.
156 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 158 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
157 if (app_list::switches::IsExperimentalAppListEnabled() && 159 if (app_list::switches::IsExperimentalAppListEnabled() &&
158 command_line->HasSwitch(switches::kCustomLauncherPage)) { 160 command_line->HasSwitch(switches::kCustomLauncherPage)) {
159 GURL custom_launcher_page_url( 161 GURL custom_launcher_page_url(
160 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); 162 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage));
161 if (!custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { 163 if (!custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) {
162 LOG(ERROR) << "Invalid custom launcher page URL: " 164 LOG(ERROR) << "Invalid custom launcher page URL: "
163 << custom_launcher_page_url.possibly_invalid_spec(); 165 << custom_launcher_page_url.possibly_invalid_spec();
164 } else { 166 } else {
165 content::WebContents::CreateParams params(profile_); 167 custom_page_contents_.reset(new apps::CustomLauncherPageContents());
166 custom_page_web_contents_.reset(content::WebContents::Create(params)); 168 custom_page_contents_->Initialize(profile, custom_launcher_page_url);
167 custom_page_web_contents_->GetController().LoadURL( 169 // This observer will activate the extension when it is navigated to,
168 custom_launcher_page_url, 170 // which allows Dispatcher to give it the proper context and makes it
169 content::Referrer(), 171 // behave like an extension.
170 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 172 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
not at google - send to devlin 2014/07/09 15:14:39 seems like it would be better for CustomLauncherPa
Matt Giuca 2014/07/10 03:45:17 Yeah I agree. I didn't do it for consistency with
171 std::string()); 173 custom_page_contents_->GetWebContents());
174 custom_page_contents_->LoadContents();
172 } 175 }
173 } 176 }
174 } 177 }
175 178
176 AppListViewDelegate::~AppListViewDelegate() { 179 AppListViewDelegate::~AppListViewDelegate() {
177 app_list::StartPageService* service = 180 app_list::StartPageService* service =
178 app_list::StartPageService::Get(profile_); 181 app_list::StartPageService::Get(profile_);
179 if (service) 182 if (service)
180 service->RemoveObserver(this); 183 service->RemoveObserver(this);
181 g_browser_process-> 184 g_browser_process->
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 477
475 views::WebView* web_view = new views::WebView( 478 views::WebView* web_view = new views::WebView(
476 web_contents->GetBrowserContext()); 479 web_contents->GetBrowserContext());
477 web_view->SetPreferredSize(size); 480 web_view->SetPreferredSize(size);
478 web_view->SetWebContents(web_contents); 481 web_view->SetWebContents(web_contents);
479 return web_view; 482 return web_view;
480 } 483 }
481 484
482 views::View* AppListViewDelegate::CreateCustomPageWebView( 485 views::View* AppListViewDelegate::CreateCustomPageWebView(
483 const gfx::Size& size) { 486 const gfx::Size& size) {
484 if (!custom_page_web_contents_) 487 if (!custom_page_contents_)
485 return NULL; 488 return NULL;
486 489
487 views::WebView* web_view = new views::WebView( 490 content::WebContents* web_contents = custom_page_contents_->GetWebContents();
488 custom_page_web_contents_->GetBrowserContext()); 491 views::WebView* web_view =
492 new views::WebView(web_contents->GetBrowserContext());
489 web_view->SetPreferredSize(size); 493 web_view->SetPreferredSize(size);
490 web_view->SetWebContents(custom_page_web_contents_.get()); 494 web_view->SetWebContents(web_contents);
491 return web_view; 495 return web_view;
492 } 496 }
493 #endif 497 #endif
494 498
495 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { 499 bool AppListViewDelegate::IsSpeechRecognitionEnabled() {
496 app_list::StartPageService* service = 500 app_list::StartPageService* service =
497 app_list::StartPageService::Get(profile_); 501 app_list::StartPageService::Get(profile_);
498 return service && service->GetSpeechRecognitionContents(); 502 return service && service->GetSpeechRecognitionContents();
499 } 503 }
500 504
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 537
534 void AppListViewDelegate::AddObserver( 538 void AppListViewDelegate::AddObserver(
535 app_list::AppListViewDelegateObserver* observer) { 539 app_list::AppListViewDelegateObserver* observer) {
536 observers_.AddObserver(observer); 540 observers_.AddObserver(observer);
537 } 541 }
538 542
539 void AppListViewDelegate::RemoveObserver( 543 void AppListViewDelegate::RemoveObserver(
540 app_list::AppListViewDelegateObserver* observer) { 544 app_list::AppListViewDelegateObserver* observer) {
541 observers_.RemoveObserver(observer); 545 observers_.RemoveObserver(observer);
542 } 546 }
OLDNEW
« apps/custom_launcher_page_contents.h ('K') | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698