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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "apps/custom_launcher_page_contents.h" | 11 #include "apps/custom_launcher_page_contents.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/metrics/user_metrics.h" | 15 #include "base/metrics/user_metrics.h" |
16 #include "base/profiler/scoped_tracker.h" | 16 #include "base/profiler/scoped_tracker.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chrome_notification_types.h" | |
21 #include "chrome/browser/lifetime/scoped_keep_alive.h" | |
22 #include "chrome/browser/profiles/profile_attributes_entry.h" | |
23 #include "chrome/browser/profiles/profile_attributes_storage.h" | |
24 #include "chrome/browser/profiles/profile_manager.h" | |
25 #include "chrome/browser/search/hotword_service.h" | 20 #include "chrome/browser/search/hotword_service.h" |
26 #include "chrome/browser/search/hotword_service_factory.h" | 21 #include "chrome/browser/search/hotword_service_factory.h" |
27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
28 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 23 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
29 #include "chrome/browser/ui/app_list/app_list_service.h" | 24 #include "chrome/browser/ui/app_list/app_list_service.h" |
30 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 25 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
31 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 26 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
32 #include "chrome/browser/ui/app_list/launcher_page_event_dispatcher.h" | 27 #include "chrome/browser/ui/app_list/launcher_page_event_dispatcher.h" |
33 #include "chrome/browser/ui/app_list/search/search_controller_factory.h" | 28 #include "chrome/browser/ui/app_list/search/search_controller_factory.h" |
34 #include "chrome/browser/ui/app_list/search/search_resource_manager.h" | 29 #include "chrome/browser/ui/app_list/search/search_resource_manager.h" |
35 #include "chrome/browser/ui/app_list/start_page_service.h" | 30 #include "chrome/browser/ui/app_list/start_page_service.h" |
36 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | 31 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
37 #include "chrome/browser/ui/browser_finder.h" | 32 #include "chrome/browser/ui/browser_finder.h" |
38 #include "chrome/browser/ui/chrome_pages.h" | 33 #include "chrome/browser/ui/chrome_pages.h" |
39 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 34 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
40 #include "chrome/browser/web_applications/web_app.h" | 35 #include "chrome/browser/web_applications/web_app.h" |
41 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/extensions/extension_constants.h" | 37 #include "chrome/common/extensions/extension_constants.h" |
43 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
44 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
45 #include "components/prefs/pref_service.h" | 40 #include "components/prefs/pref_service.h" |
46 #include "components/signin/core/browser/signin_manager.h" | |
47 #include "components/user_prefs/user_prefs.h" | 41 #include "components/user_prefs/user_prefs.h" |
48 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
49 #include "content/public/browser/notification_service.h" | |
50 #include "content/public/browser/page_navigator.h" | 43 #include "content/public/browser/page_navigator.h" |
51 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
52 #include "content/public/browser/render_widget_host.h" | 45 #include "content/public/browser/render_widget_host.h" |
53 #include "content/public/browser/render_widget_host_view.h" | 46 #include "content/public/browser/render_widget_host_view.h" |
54 #include "content/public/browser/speech_recognition_session_preamble.h" | 47 #include "content/public/browser/speech_recognition_session_preamble.h" |
55 #include "content/public/browser/user_metrics.h" | 48 #include "content/public/browser/user_metrics.h" |
56 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
57 #include "extensions/browser/extension_registry.h" | 50 #include "extensions/browser/extension_registry.h" |
58 #include "extensions/common/constants.h" | 51 #include "extensions/common/constants.h" |
59 #include "extensions/common/extension_set.h" | 52 #include "extensions/common/extension_set.h" |
60 #include "extensions/common/manifest_constants.h" | 53 #include "extensions/common/manifest_constants.h" |
61 #include "extensions/common/manifest_handlers/launcher_page_info.h" | 54 #include "extensions/common/manifest_handlers/launcher_page_info.h" |
62 #include "grit/theme_resources.h" | 55 #include "grit/theme_resources.h" |
63 #include "ui/app_list/app_list_switches.h" | 56 #include "ui/app_list/app_list_switches.h" |
64 #include "ui/app_list/app_list_view_delegate_observer.h" | |
65 #include "ui/app_list/search_box_model.h" | 57 #include "ui/app_list/search_box_model.h" |
66 #include "ui/app_list/search_controller.h" | 58 #include "ui/app_list/search_controller.h" |
67 #include "ui/app_list/speech_ui_model.h" | 59 #include "ui/app_list/speech_ui_model.h" |
68 #include "ui/base/resource/resource_bundle.h" | 60 #include "ui/base/resource/resource_bundle.h" |
69 #include "ui/views/controls/webview/webview.h" | 61 #include "ui/views/controls/webview/webview.h" |
70 | 62 |
71 #if defined(USE_AURA) | 63 #if defined(USE_AURA) |
72 #include "ui/keyboard/keyboard_util.h" | 64 #include "ui/keyboard/keyboard_util.h" |
73 #endif | 65 #endif |
74 | 66 |
(...skipping 25 matching lines...) Expand all Loading... |
100 base::Callback<void(const base::FilePath&)> callback, | 92 base::Callback<void(const base::FilePath&)> callback, |
101 std::unique_ptr<web_app::ShortcutInfo> info) { | 93 std::unique_ptr<web_app::ShortcutInfo> info) { |
102 content::BrowserThread::PostTaskAndReplyWithResult( | 94 content::BrowserThread::PostTaskAndReplyWithResult( |
103 content::BrowserThread::FILE, FROM_HERE, | 95 content::BrowserThread::FILE, FROM_HERE, |
104 base::Bind(web_app::CreateShortcutInWebAppDir, app_data_dir, | 96 base::Bind(web_app::CreateShortcutInWebAppDir, app_data_dir, |
105 base::Passed(&info)), | 97 base::Passed(&info)), |
106 callback); | 98 callback); |
107 } | 99 } |
108 #endif | 100 #endif |
109 | 101 |
110 void PopulateUsers(const base::FilePath& active_profile_path, | |
111 app_list::AppListViewDelegate::Users* users) { | |
112 users->clear(); | |
113 std::vector<ProfileAttributesEntry*> entries = g_browser_process-> | |
114 profile_manager()->GetProfileAttributesStorage(). | |
115 GetAllProfilesAttributesSortedByName(); | |
116 for (const auto entry : entries) { | |
117 app_list::AppListViewDelegate::User user; | |
118 user.name = entry->GetName(); | |
119 user.email = entry->GetUserName(); | |
120 user.profile_path = entry->GetPath(); | |
121 user.active = active_profile_path == user.profile_path; | |
122 users->push_back(user); | |
123 } | |
124 } | |
125 | |
126 // Gets a list of URLs of the custom launcher pages to show in the launcher. | 102 // Gets a list of URLs of the custom launcher pages to show in the launcher. |
127 // Returns a URL for each installed launcher page. If --custom-launcher-page is | 103 // Returns a URL for each installed launcher page. If --custom-launcher-page is |
128 // specified and valid, also includes that URL. | 104 // specified and valid, also includes that URL. |
129 void GetCustomLauncherPageUrls(content::BrowserContext* browser_context, | 105 void GetCustomLauncherPageUrls(content::BrowserContext* browser_context, |
130 std::vector<GURL>* urls) { | 106 std::vector<GURL>* urls) { |
131 // First, check the command line. | 107 // First, check the command line. |
132 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 108 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
133 if (app_list::switches::IsExperimentalAppListEnabled() && | 109 if (app_list::switches::IsExperimentalAppListEnabled() && |
134 command_line->HasSwitch(app_list::switches::kCustomLauncherPage)) { | 110 command_line->HasSwitch(app_list::switches::kCustomLauncherPage)) { |
135 GURL custom_launcher_page_url(command_line->GetSwitchValueASCII( | 111 GURL custom_launcher_page_url(command_line->GetSwitchValueASCII( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 146 } |
171 } | 147 } |
172 | 148 |
173 } // namespace | 149 } // namespace |
174 | 150 |
175 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) | 151 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) |
176 : controller_(controller), | 152 : controller_(controller), |
177 profile_(NULL), | 153 profile_(NULL), |
178 model_(NULL), | 154 model_(NULL), |
179 is_voice_query_(false), | 155 is_voice_query_(false), |
180 template_url_service_observer_(this), | 156 template_url_service_observer_(this) { |
181 scoped_observer_(this) { | |
182 CHECK(controller_); | 157 CHECK(controller_); |
183 // The SigninManagerFactor and the SigninManagers are observed to keep the | |
184 // profile switcher menu up to date, with the correct list of profiles and the | |
185 // correct email address (or none for signed out users) for each. | |
186 SigninManagerFactory::GetInstance()->AddObserver(this); | |
187 | |
188 // Start observing all already-created SigninManagers. | |
189 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
190 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles(); | |
191 | |
192 for (std::vector<Profile*>::iterator i = profiles.begin(); | |
193 i != profiles.end(); | |
194 ++i) { | |
195 SigninManagerBase* manager = | |
196 SigninManagerFactory::GetForProfileIfExists(*i); | |
197 if (manager) { | |
198 DCHECK(!scoped_observer_.IsObserving(manager)); | |
199 scoped_observer_.Add(manager); | |
200 } | |
201 } | |
202 | |
203 profile_manager->GetProfileAttributesStorage().AddObserver(this); | |
204 speech_ui_.reset(new app_list::SpeechUIModel); | 158 speech_ui_.reset(new app_list::SpeechUIModel); |
205 | 159 |
206 #if defined(GOOGLE_CHROME_BUILD) | 160 #if defined(GOOGLE_CHROME_BUILD) |
207 gfx::ImageSkia* image; | 161 gfx::ImageSkia* image; |
208 { | 162 { |
209 // TODO(tapted): Remove ScopedTracker below once crbug.com/431326 is fixed. | 163 // TODO(tapted): Remove ScopedTracker below once crbug.com/431326 is fixed. |
210 tracked_objects::ScopedTracker tracking_profile( | 164 tracked_objects::ScopedTracker tracking_profile( |
211 FROM_HERE_WITH_EXPLICIT_FUNCTION("431326 GetImageSkiaNamed()")); | 165 FROM_HERE_WITH_EXPLICIT_FUNCTION("431326 GetImageSkiaNamed()")); |
212 image = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 166 image = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
213 IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH); | 167 IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH); |
214 } | 168 } |
215 | 169 |
216 speech_ui_->set_logo(*image); | 170 speech_ui_->set_logo(*image); |
217 #endif | 171 #endif |
218 | |
219 registrar_.Add(this, | |
220 chrome::NOTIFICATION_APP_TERMINATING, | |
221 content::NotificationService::AllSources()); | |
222 } | 172 } |
223 | 173 |
224 AppListViewDelegate::~AppListViewDelegate() { | 174 AppListViewDelegate::~AppListViewDelegate() { |
225 // Note that the destructor is not always called. E.g. on Mac, this is owned | |
226 // by a leaky singleton. Essential shutdown work must be done by observing | |
227 // chrome::NOTIFICATION_APP_TERMINATING. | |
228 SetProfile(NULL); | 175 SetProfile(NULL); |
229 g_browser_process->profile_manager()->GetProfileAttributesStorage(). | |
230 RemoveObserver(this); | |
231 | |
232 SigninManagerFactory* factory = SigninManagerFactory::GetInstance(); | |
233 if (factory) | |
234 factory->RemoveObserver(this); | |
235 } | 176 } |
236 | 177 |
237 void AppListViewDelegate::SetProfile(Profile* new_profile) { | 178 void AppListViewDelegate::SetProfile(Profile* new_profile) { |
238 if (profile_ == new_profile) | 179 if (profile_ == new_profile) |
239 return; | 180 return; |
240 | 181 |
241 if (profile_) { | 182 if (profile_) { |
242 // Note: |search_resource_manager_| has a reference to |speech_ui_| so must | 183 // Note: |search_resource_manager_| has a reference to |speech_ui_| so must |
243 // be destroyed first. | 184 // be destroyed first. |
244 search_resource_manager_.reset(); | 185 search_resource_manager_.reset(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 225 |
285 model_ = app_list::AppListSyncableServiceFactory::GetForProfile(profile_) | 226 model_ = app_list::AppListSyncableServiceFactory::GetForProfile(profile_) |
286 ->GetModel(); | 227 ->GetModel(); |
287 | 228 |
288 #if defined(USE_ASH) | 229 #if defined(USE_ASH) |
289 app_sync_ui_state_watcher_.reset( | 230 app_sync_ui_state_watcher_.reset( |
290 new AppSyncUIStateWatcher(profile_, model_)); | 231 new AppSyncUIStateWatcher(profile_, model_)); |
291 #endif | 232 #endif |
292 | 233 |
293 SetUpSearchUI(); | 234 SetUpSearchUI(); |
294 SetUpProfileSwitcher(); | |
295 SetUpCustomLauncherPages(); | 235 SetUpCustomLauncherPages(); |
296 OnTemplateURLServiceChanged(); | 236 OnTemplateURLServiceChanged(); |
297 } | 237 } |
298 | 238 |
299 // Clear search query. | 239 // Clear search query. |
300 model_->search_box()->SetText(base::string16()); | 240 model_->search_box()->SetText(base::string16()); |
301 } | 241 } |
302 | 242 |
303 void AppListViewDelegate::SetUpSearchUI() { | 243 void AppListViewDelegate::SetUpSearchUI() { |
304 app_list::StartPageService* start_page_service = | 244 app_list::StartPageService* start_page_service = |
305 app_list::StartPageService::Get(profile_); | 245 app_list::StartPageService::Get(profile_); |
306 if (start_page_service) | 246 if (start_page_service) |
307 start_page_service->AddObserver(this); | 247 start_page_service->AddObserver(this); |
308 | 248 |
309 speech_ui_->SetSpeechRecognitionState(start_page_service | 249 speech_ui_->SetSpeechRecognitionState(start_page_service |
310 ? start_page_service->state() | 250 ? start_page_service->state() |
311 : app_list::SPEECH_RECOGNITION_OFF, | 251 : app_list::SPEECH_RECOGNITION_OFF, |
312 false); | 252 false); |
313 | 253 |
314 search_resource_manager_.reset(new app_list::SearchResourceManager( | 254 search_resource_manager_.reset(new app_list::SearchResourceManager( |
315 profile_, | 255 profile_, |
316 model_->search_box(), | 256 model_->search_box(), |
317 speech_ui_.get())); | 257 speech_ui_.get())); |
318 | 258 |
319 search_controller_ = CreateSearchController(profile_, model_, controller_); | 259 search_controller_ = CreateSearchController(profile_, model_, controller_); |
320 } | 260 } |
321 | 261 |
322 void AppListViewDelegate::SetUpProfileSwitcher() { | |
323 // If a profile change is observed when there is no app list, there is nothing | |
324 // to update until SetProfile() calls this function again. | |
325 if (!profile_) | |
326 return; | |
327 | |
328 #if defined(USE_ASH) | |
329 // Don't populate the app list users if we are on the ash desktop. | |
330 return; | |
331 #endif // USE_ASH | |
332 | |
333 // Populate the app list users. | |
334 PopulateUsers(profile_->GetPath(), &users_); | |
335 | |
336 FOR_EACH_OBSERVER( | |
337 app_list::AppListViewDelegateObserver, observers_, OnProfilesChanged()); | |
338 } | |
339 | |
340 void AppListViewDelegate::SetUpCustomLauncherPages() { | 262 void AppListViewDelegate::SetUpCustomLauncherPages() { |
341 std::vector<GURL> custom_launcher_page_urls; | 263 std::vector<GURL> custom_launcher_page_urls; |
342 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls); | 264 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls); |
343 if (custom_launcher_page_urls.empty()) | 265 if (custom_launcher_page_urls.empty()) |
344 return; | 266 return; |
345 | 267 |
346 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); | 268 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); |
347 it != custom_launcher_page_urls.end(); | 269 it != custom_launcher_page_urls.end(); |
348 ++it) { | 270 ++it) { |
349 std::string extension_id = it->host(); | 271 std::string extension_id = it->host(); |
(...skipping 30 matching lines...) Expand all Loading... |
380 } | 302 } |
381 } | 303 } |
382 | 304 |
383 void AppListViewDelegate::OnHotwordRecognized( | 305 void AppListViewDelegate::OnHotwordRecognized( |
384 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) { | 306 const scoped_refptr<content::SpeechRecognitionSessionPreamble>& preamble) { |
385 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, | 307 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, |
386 speech_ui_->state()); | 308 speech_ui_->state()); |
387 StartSpeechRecognitionForHotword(preamble); | 309 StartSpeechRecognitionForHotword(preamble); |
388 } | 310 } |
389 | 311 |
390 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) { | |
391 scoped_observer_.Add(manager); | |
392 } | |
393 | |
394 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) { | |
395 if (scoped_observer_.IsObserving(manager)) | |
396 scoped_observer_.Remove(manager); | |
397 } | |
398 | |
399 void AppListViewDelegate::GoogleSigninFailed( | |
400 const GoogleServiceAuthError& error) { | |
401 SetUpProfileSwitcher(); | |
402 } | |
403 | |
404 void AppListViewDelegate::GoogleSigninSucceeded(const std::string& account_id, | |
405 const std::string& username, | |
406 const std::string& password) { | |
407 SetUpProfileSwitcher(); | |
408 } | |
409 | |
410 void AppListViewDelegate::GoogleSignedOut(const std::string& account_id, | |
411 const std::string& username) { | |
412 SetUpProfileSwitcher(); | |
413 } | |
414 | |
415 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) { | |
416 SetUpProfileSwitcher(); | |
417 } | |
418 | |
419 void AppListViewDelegate::OnProfileWasRemoved( | |
420 const base::FilePath& profile_path, | |
421 const base::string16& profile_name) { | |
422 SetUpProfileSwitcher(); | |
423 } | |
424 | |
425 void AppListViewDelegate::OnProfileNameChanged( | |
426 const base::FilePath& profile_path, | |
427 const base::string16& old_profile_name) { | |
428 SetUpProfileSwitcher(); | |
429 } | |
430 | |
431 bool AppListViewDelegate::ForceNativeDesktop() const { | 312 bool AppListViewDelegate::ForceNativeDesktop() const { |
432 return controller_->ForceNativeDesktop(); | 313 return controller_->ForceNativeDesktop(); |
433 } | 314 } |
434 | 315 |
435 void AppListViewDelegate::SetProfileByPath(const base::FilePath& profile_path) { | 316 void AppListViewDelegate::SetProfileByPath(const base::FilePath& profile_path) { |
436 DCHECK(model_); | 317 DCHECK(model_); |
437 // The profile must be loaded before this is called. | 318 // The profile must be loaded before this is called. |
438 SetProfile( | 319 SetProfile( |
439 g_browser_process->profile_manager()->GetProfileByPath(profile_path)); | 320 g_browser_process->profile_manager()->GetProfileByPath(profile_path)); |
440 } | 321 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 // the launcher to open. | 441 // the launcher to open. |
561 // TODO(amistry): This only works on ChromeOS since Chrome hides the | 442 // TODO(amistry): This only works on ChromeOS since Chrome hides the |
562 // launcher instead of destroying it. Make this work on Chrome. | 443 // launcher instead of destroying it. Make this work on Chrome. |
563 if (hotword_service->IsAlwaysOnEnabled()) | 444 if (hotword_service->IsAlwaysOnEnabled()) |
564 hotword_service->RequestHotwordSession(nullptr); | 445 hotword_service->RequestHotwordSession(nullptr); |
565 } | 446 } |
566 } | 447 } |
567 } | 448 } |
568 } | 449 } |
569 | 450 |
570 void AppListViewDelegate::OpenHelp() { | |
571 chrome::ScopedTabbedBrowserDisplayer displayer(profile_); | |
572 content::OpenURLParams params(GURL(chrome::kAppLauncherHelpURL), | |
573 content::Referrer(), | |
574 NEW_FOREGROUND_TAB, | |
575 ui::PAGE_TRANSITION_LINK, | |
576 false); | |
577 displayer.browser()->OpenURL(params); | |
578 } | |
579 | |
580 void AppListViewDelegate::OpenFeedback() { | |
581 Browser* browser = chrome::FindTabbedBrowser(profile_, false); | |
582 chrome::ShowFeedbackPage(browser, std::string(), | |
583 chrome::kAppLauncherCategoryTag); | |
584 } | |
585 | |
586 void AppListViewDelegate::StartSpeechRecognition() { | 451 void AppListViewDelegate::StartSpeechRecognition() { |
587 StartSpeechRecognitionForHotword(nullptr); | 452 StartSpeechRecognitionForHotword(nullptr); |
588 } | 453 } |
589 | 454 |
590 void AppListViewDelegate::StopSpeechRecognition() { | 455 void AppListViewDelegate::StopSpeechRecognition() { |
591 app_list::StartPageService* service = | 456 app_list::StartPageService* service = |
592 app_list::StartPageService::Get(profile_); | 457 app_list::StartPageService::Get(profile_); |
593 if (service) | 458 if (service) |
594 service->StopSpeechRecognition(); | 459 service->StopSpeechRecognition(); |
595 } | 460 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 launcher_page_event_dispatcher_->PopSubpage(); | 596 launcher_page_event_dispatcher_->PopSubpage(); |
732 } | 597 } |
733 #endif | 598 #endif |
734 | 599 |
735 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { | 600 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { |
736 app_list::StartPageService* service = | 601 app_list::StartPageService* service = |
737 app_list::StartPageService::Get(profile_); | 602 app_list::StartPageService::Get(profile_); |
738 return service && service->GetSpeechRecognitionContents(); | 603 return service && service->GetSpeechRecognitionContents(); |
739 } | 604 } |
740 | 605 |
741 const app_list::AppListViewDelegate::Users& | |
742 AppListViewDelegate::GetUsers() const { | |
743 return users_; | |
744 } | |
745 | |
746 bool AppListViewDelegate::ShouldCenterWindow() const { | 606 bool AppListViewDelegate::ShouldCenterWindow() const { |
747 // Some ChromeOS devices (those that support TouchView mode) turn this flag on | 607 // Some ChromeOS devices (those that support TouchView mode) turn this flag on |
748 // by default, which ensures that the app list is consistently centered on | 608 // by default, which ensures that the app list is consistently centered on |
749 // those devices. This avoids having the app list change shape and position as | 609 // those devices. This avoids having the app list change shape and position as |
750 // the user enters and exits TouchView mode. | 610 // the user enters and exits TouchView mode. |
751 if (app_list::switches::IsCenteredAppListEnabled()) | 611 if (app_list::switches::IsCenteredAppListEnabled()) |
752 return true; | 612 return true; |
753 | 613 |
754 // keyboard depends upon Aura. | 614 // keyboard depends upon Aura. |
755 #if defined(USE_AURA) | 615 #if defined(USE_AURA) |
756 // If the virtual keyboard is enabled, use the new app list position. The old | 616 // If the virtual keyboard is enabled, use the new app list position. The old |
757 // position is too tall, and doesn't fit in the left-over screen space. | 617 // position is too tall, and doesn't fit in the left-over screen space. |
758 if (keyboard::IsKeyboardEnabled()) | 618 if (keyboard::IsKeyboardEnabled()) |
759 return true; | 619 return true; |
760 #endif | 620 #endif |
761 | 621 |
762 return false; | 622 return false; |
763 } | 623 } |
764 | 624 |
765 void AppListViewDelegate::AddObserver( | |
766 app_list::AppListViewDelegateObserver* observer) { | |
767 observers_.AddObserver(observer); | |
768 } | |
769 | |
770 void AppListViewDelegate::RemoveObserver( | |
771 app_list::AppListViewDelegateObserver* observer) { | |
772 observers_.RemoveObserver(observer); | |
773 } | |
774 | |
775 #if !defined(OS_CHROMEOS) | 625 #if !defined(OS_CHROMEOS) |
776 base::string16 AppListViewDelegate::GetMessageTitle() const { | 626 base::string16 AppListViewDelegate::GetMessageTitle() const { |
777 return l10n_util::GetStringUTF16(IDS_APP_LIST_MESSAGE_TITLE); | 627 return l10n_util::GetStringUTF16(IDS_APP_LIST_MESSAGE_TITLE); |
778 } | 628 } |
779 | 629 |
780 base::string16 AppListViewDelegate::GetMessageText( | 630 base::string16 AppListViewDelegate::GetMessageText( |
781 size_t* message_break) const { | 631 size_t* message_break) const { |
782 return l10n_util::GetStringFUTF16(IDS_APP_LIST_MESSAGE_TEXT, base::string16(), | 632 return l10n_util::GetStringFUTF16(IDS_APP_LIST_MESSAGE_TEXT, base::string16(), |
783 message_break); | 633 message_break); |
784 } | 634 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 template_url_service->search_terms_data()) == | 671 template_url_service->search_terms_data()) == |
822 SEARCH_ENGINE_GOOGLE; | 672 SEARCH_ENGINE_GOOGLE; |
823 | 673 |
824 model_->SetSearchEngineIsGoogle(is_google); | 674 model_->SetSearchEngineIsGoogle(is_google); |
825 | 675 |
826 app_list::StartPageService* start_page_service = | 676 app_list::StartPageService* start_page_service = |
827 app_list::StartPageService::Get(profile_); | 677 app_list::StartPageService::Get(profile_); |
828 if (start_page_service) | 678 if (start_page_service) |
829 start_page_service->set_search_engine_is_google(is_google); | 679 start_page_service->set_search_engine_is_google(is_google); |
830 } | 680 } |
831 | |
832 void AppListViewDelegate::Observe(int type, | |
833 const content::NotificationSource& source, | |
834 const content::NotificationDetails& details) { | |
835 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); | |
836 | |
837 FOR_EACH_OBSERVER(app_list::AppListViewDelegateObserver, observers_, | |
838 OnShutdown()); | |
839 | |
840 SetProfile(nullptr); // Ensures launcher page web contents are torn down. | |
841 | |
842 // SigninManagerFactory is not a leaky singleton (unlike this class), and | |
843 // its destructor will check that it has no remaining observers. | |
844 scoped_observer_.RemoveAll(); | |
845 SigninManagerFactory::GetInstance()->RemoveObserver(this); | |
846 } | |
OLD | NEW |