Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
| 12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/profiles/profile_info_cache.h" | 16 #include "chrome/browser/profiles/profile_info_cache.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/search/hotword_service.h" | 18 #include "chrome/browser/search/hotword_service.h" |
| 18 #include "chrome/browser/search/hotword_service_factory.h" | 19 #include "chrome/browser/search/hotword_service_factory.h" |
| 19 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 20 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 20 #include "chrome/browser/ui/app_list/app_list_service.h" | 21 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 21 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 22 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 22 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 23 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 23 #include "chrome/browser/ui/app_list/search/search_controller.h" | 24 #include "chrome/browser/ui/app_list/search/search_controller.h" |
| 24 #include "chrome/browser/ui/app_list/start_page_service.h" | 25 #include "chrome/browser/ui/app_list/start_page_service.h" |
| 25 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
| 26 #include "chrome/browser/ui/chrome_pages.h" | 27 #include "chrome/browser/ui/chrome_pages.h" |
| 27 #include "chrome/browser/ui/host_desktop.h" | 28 #include "chrome/browser/ui/host_desktop.h" |
| 28 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 29 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 29 #include "chrome/browser/web_applications/web_app.h" | 30 #include "chrome/browser/web_applications/web_app.h" |
| 31 #include "chrome/common/chrome_switches.h" | |
| 30 #include "chrome/common/extensions/extension_constants.h" | 32 #include "chrome/common/extensions/extension_constants.h" |
| 31 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 32 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
| 33 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/page_navigator.h" | 36 #include "content/public/browser/page_navigator.h" |
| 35 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
| 38 #include "content/public/browser/web_contents.h" | |
| 36 #include "extensions/browser/extension_registry.h" | 39 #include "extensions/browser/extension_registry.h" |
| 40 #include "extensions/common/constants.h" | |
| 37 #include "grit/theme_resources.h" | 41 #include "grit/theme_resources.h" |
| 38 #include "ui/app_list/app_list_switches.h" | 42 #include "ui/app_list/app_list_switches.h" |
| 39 #include "ui/app_list/app_list_view_delegate_observer.h" | 43 #include "ui/app_list/app_list_view_delegate_observer.h" |
| 40 #include "ui/app_list/search_box_model.h" | 44 #include "ui/app_list/search_box_model.h" |
| 41 #include "ui/app_list/speech_ui_model.h" | 45 #include "ui/app_list/speech_ui_model.h" |
| 42 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
| 47 #include "ui/views/controls/webview/webview.h" | |
| 43 | 48 |
| 44 #if defined(TOOLKIT_VIEWS) | 49 #if defined(TOOLKIT_VIEWS) |
| 45 #include "ui/views/controls/webview/webview.h" | 50 #include "ui/views/controls/webview/webview.h" |
| 46 #endif | 51 #endif |
| 47 | 52 |
| 48 #if defined(USE_AURA) | 53 #if defined(USE_AURA) |
| 49 #include "ui/keyboard/keyboard_util.h" | 54 #include "ui/keyboard/keyboard_util.h" |
| 50 #endif | 55 #endif |
| 51 | 56 |
| 52 #if defined(USE_ASH) | 57 #if defined(USE_ASH) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 142 |
| 138 #if defined(GOOGLE_CHROME_BUILD) | 143 #if defined(GOOGLE_CHROME_BUILD) |
| 139 speech_ui_->set_logo( | 144 speech_ui_->set_logo( |
| 140 *ui::ResourceBundle::GetSharedInstance(). | 145 *ui::ResourceBundle::GetSharedInstance(). |
| 141 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); | 146 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); |
| 142 #endif | 147 #endif |
| 143 | 148 |
| 144 OnProfileChanged(); // sets model_ | 149 OnProfileChanged(); // sets model_ |
| 145 if (service) | 150 if (service) |
| 146 service->AddObserver(this); | 151 service->AddObserver(this); |
| 152 | |
| 153 // Set up the custom launcher page. There is currently only a single custom | |
| 154 // page allowed, which is specified as a command-line flag. In the future, | |
| 155 // arbitrary extensions may be able to specify their own custom pages. | |
| 156 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 157 if (command_line->HasSwitch(switches::kCustomLauncherPage)) { | |
|
calamity
2014/06/25 06:38:40
Worth making this do nothing if !IsExperimentalApp
Matt Giuca
2014/06/25 07:21:42
Done.
| |
| 158 GURL custom_launcher_page_url( | |
| 159 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); | |
| 160 if (!custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { | |
| 161 LOG(ERROR) << "Invalid custom launcher page URL: " | |
| 162 << custom_launcher_page_url.spec(); | |
| 163 } else { | |
| 164 content::WebContents::CreateParams params(profile_); | |
| 165 custom_page_web_contents_.reset(content::WebContents::Create(params)); | |
| 166 custom_page_web_contents_->GetController().LoadURL( | |
| 167 custom_launcher_page_url, | |
| 168 content::Referrer(), | |
| 169 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | |
| 170 std::string()); | |
| 171 } | |
| 172 } | |
| 147 } | 173 } |
| 148 | 174 |
| 149 AppListViewDelegate::~AppListViewDelegate() { | 175 AppListViewDelegate::~AppListViewDelegate() { |
| 150 app_list::StartPageService* service = | 176 app_list::StartPageService* service = |
| 151 app_list::StartPageService::Get(profile_); | 177 app_list::StartPageService::Get(profile_); |
| 152 if (service) | 178 if (service) |
| 153 service->RemoveObserver(this); | 179 service->RemoveObserver(this); |
| 154 g_browser_process-> | 180 g_browser_process-> |
| 155 profile_manager()->GetProfileInfoCache().RemoveObserver(this); | 181 profile_manager()->GetProfileInfoCache().RemoveObserver(this); |
| 156 | 182 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 content::WebContents* web_contents = service->GetStartPageContents(); | 470 content::WebContents* web_contents = service->GetStartPageContents(); |
| 445 if (!web_contents) | 471 if (!web_contents) |
| 446 return NULL; | 472 return NULL; |
| 447 | 473 |
| 448 views::WebView* web_view = new views::WebView( | 474 views::WebView* web_view = new views::WebView( |
| 449 web_contents->GetBrowserContext()); | 475 web_contents->GetBrowserContext()); |
| 450 web_view->SetPreferredSize(size); | 476 web_view->SetPreferredSize(size); |
| 451 web_view->SetWebContents(web_contents); | 477 web_view->SetWebContents(web_contents); |
| 452 return web_view; | 478 return web_view; |
| 453 } | 479 } |
| 480 | |
| 481 views::View* AppListViewDelegate::CreateCustomPageWebView( | |
| 482 const gfx::Size& size) { | |
| 483 if (!custom_page_web_contents_) | |
| 484 return NULL; | |
| 485 | |
| 486 views::WebView* web_view = new views::WebView( | |
| 487 custom_page_web_contents_->GetBrowserContext()); | |
| 488 web_view->SetPreferredSize(size); | |
| 489 web_view->SetWebContents(custom_page_web_contents_.get()); | |
| 490 return web_view; | |
| 491 } | |
| 454 #endif | 492 #endif |
| 455 | 493 |
| 456 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { | 494 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { |
| 457 app_list::StartPageService* service = | 495 app_list::StartPageService* service = |
| 458 app_list::StartPageService::Get(profile_); | 496 app_list::StartPageService::Get(profile_); |
| 459 return service && service->GetSpeechRecognitionContents(); | 497 return service && service->GetSpeechRecognitionContents(); |
| 460 } | 498 } |
| 461 | 499 |
| 462 const app_list::AppListViewDelegate::Users& | 500 const app_list::AppListViewDelegate::Users& |
| 463 AppListViewDelegate::GetUsers() const { | 501 AppListViewDelegate::GetUsers() const { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 494 | 532 |
| 495 void AppListViewDelegate::AddObserver( | 533 void AppListViewDelegate::AddObserver( |
| 496 app_list::AppListViewDelegateObserver* observer) { | 534 app_list::AppListViewDelegateObserver* observer) { |
| 497 observers_.AddObserver(observer); | 535 observers_.AddObserver(observer); |
| 498 } | 536 } |
| 499 | 537 |
| 500 void AppListViewDelegate::RemoveObserver( | 538 void AppListViewDelegate::RemoveObserver( |
| 501 app_list::AppListViewDelegateObserver* observer) { | 539 app_list::AppListViewDelegateObserver* observer) { |
| 502 observers_.RemoveObserver(observer); | 540 observers_.RemoveObserver(observer); |
| 503 } | 541 } |
| OLD | NEW |