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 (app_list::switches::IsExperimentalAppListEnabled() && |
| 158 command_line->HasSwitch(switches::kCustomLauncherPage)) { |
| 159 GURL custom_launcher_page_url( |
| 160 command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); |
| 161 if (!custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { |
| 162 LOG(ERROR) << "Invalid custom launcher page URL: " |
| 163 << custom_launcher_page_url.possibly_invalid_spec(); |
| 164 } else { |
| 165 content::WebContents::CreateParams params(profile_); |
| 166 custom_page_web_contents_.reset(content::WebContents::Create(params)); |
| 167 custom_page_web_contents_->GetController().LoadURL( |
| 168 custom_launcher_page_url, |
| 169 content::Referrer(), |
| 170 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 171 std::string()); |
| 172 } |
| 173 } |
147 } | 174 } |
148 | 175 |
149 AppListViewDelegate::~AppListViewDelegate() { | 176 AppListViewDelegate::~AppListViewDelegate() { |
150 app_list::StartPageService* service = | 177 app_list::StartPageService* service = |
151 app_list::StartPageService::Get(profile_); | 178 app_list::StartPageService::Get(profile_); |
152 if (service) | 179 if (service) |
153 service->RemoveObserver(this); | 180 service->RemoveObserver(this); |
154 g_browser_process-> | 181 g_browser_process-> |
155 profile_manager()->GetProfileInfoCache().RemoveObserver(this); | 182 profile_manager()->GetProfileInfoCache().RemoveObserver(this); |
156 | 183 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 content::WebContents* web_contents = service->GetStartPageContents(); | 471 content::WebContents* web_contents = service->GetStartPageContents(); |
445 if (!web_contents) | 472 if (!web_contents) |
446 return NULL; | 473 return NULL; |
447 | 474 |
448 views::WebView* web_view = new views::WebView( | 475 views::WebView* web_view = new views::WebView( |
449 web_contents->GetBrowserContext()); | 476 web_contents->GetBrowserContext()); |
450 web_view->SetPreferredSize(size); | 477 web_view->SetPreferredSize(size); |
451 web_view->SetWebContents(web_contents); | 478 web_view->SetWebContents(web_contents); |
452 return web_view; | 479 return web_view; |
453 } | 480 } |
| 481 |
| 482 views::View* AppListViewDelegate::CreateCustomPageWebView( |
| 483 const gfx::Size& size) { |
| 484 if (!custom_page_web_contents_) |
| 485 return NULL; |
| 486 |
| 487 views::WebView* web_view = new views::WebView( |
| 488 custom_page_web_contents_->GetBrowserContext()); |
| 489 web_view->SetPreferredSize(size); |
| 490 web_view->SetWebContents(custom_page_web_contents_.get()); |
| 491 return web_view; |
| 492 } |
454 #endif | 493 #endif |
455 | 494 |
456 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { | 495 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { |
457 app_list::StartPageService* service = | 496 app_list::StartPageService* service = |
458 app_list::StartPageService::Get(profile_); | 497 app_list::StartPageService::Get(profile_); |
459 return service && service->GetSpeechRecognitionContents(); | 498 return service && service->GetSpeechRecognitionContents(); |
460 } | 499 } |
461 | 500 |
462 const app_list::AppListViewDelegate::Users& | 501 const app_list::AppListViewDelegate::Users& |
463 AppListViewDelegate::GetUsers() const { | 502 AppListViewDelegate::GetUsers() const { |
(...skipping 30 matching lines...) Expand all Loading... |
494 | 533 |
495 void AppListViewDelegate::AddObserver( | 534 void AppListViewDelegate::AddObserver( |
496 app_list::AppListViewDelegateObserver* observer) { | 535 app_list::AppListViewDelegateObserver* observer) { |
497 observers_.AddObserver(observer); | 536 observers_.AddObserver(observer); |
498 } | 537 } |
499 | 538 |
500 void AppListViewDelegate::RemoveObserver( | 539 void AppListViewDelegate::RemoveObserver( |
501 app_list::AppListViewDelegateObserver* observer) { | 540 app_list::AppListViewDelegateObserver* observer) { |
502 observers_.RemoveObserver(observer); | 541 observers_.RemoveObserver(observer); |
503 } | 542 } |
OLD | NEW |