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

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

Issue 683703002: Notify launcher page with onTransitionChanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@launcher_page_api_show_state_notify
Patch Set: fix mac compile Created 6 years, 1 month 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
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 "apps/custom_launcher_page_contents.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/metrics/user_metrics.h" 13 #include "base/metrics/user_metrics.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "chrome/browser/apps/scoped_keep_alive.h" 15 #include "chrome/browser/apps/scoped_keep_alive.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/profiles/profile_info_cache.h" 18 #include "chrome/browser/profiles/profile_info_cache.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/search/hotword_service.h" 20 #include "chrome/browser/search/hotword_service.h"
21 #include "chrome/browser/search/hotword_service_factory.h" 21 #include "chrome/browser/search/hotword_service_factory.h"
22 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 22 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
23 #include "chrome/browser/ui/app_list/app_list_service.h" 23 #include "chrome/browser/ui/app_list/app_list_service.h"
24 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 24 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
25 #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"
26 #include "chrome/browser/ui/app_list/launcher_page_event_dispatcher.h"
26 #include "chrome/browser/ui/app_list/search/search_controller_factory.h" 27 #include "chrome/browser/ui/app_list/search/search_controller_factory.h"
27 #include "chrome/browser/ui/app_list/search/search_resource_manager.h" 28 #include "chrome/browser/ui/app_list/search/search_resource_manager.h"
28 #include "chrome/browser/ui/app_list/start_page_service.h" 29 #include "chrome/browser/ui/app_list/start_page_service.h"
29 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 30 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
30 #include "chrome/browser/ui/browser_finder.h" 31 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/chrome_pages.h" 32 #include "chrome/browser/ui/chrome_pages.h"
32 #include "chrome/browser/ui/host_desktop.h" 33 #include "chrome/browser/ui/host_desktop.h"
33 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 34 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
34 #include "chrome/browser/web_applications/web_app.h" 35 #include "chrome/browser/web_applications/web_app.h"
35 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 205
205 void AppListViewDelegate::SetProfile(Profile* new_profile) { 206 void AppListViewDelegate::SetProfile(Profile* new_profile) {
206 if (profile_ == new_profile) 207 if (profile_ == new_profile)
207 return; 208 return;
208 209
209 if (profile_) { 210 if (profile_) {
210 // Note: |search_resource_manager_| has a reference to |speech_ui_| so must 211 // Note: |search_resource_manager_| has a reference to |speech_ui_| so must
211 // be destroyed first. 212 // be destroyed first.
212 search_resource_manager_.reset(); 213 search_resource_manager_.reset();
213 search_controller_.reset(); 214 search_controller_.reset();
215 launcher_page_event_dispatcher_.reset();
214 custom_page_contents_.clear(); 216 custom_page_contents_.clear();
215 app_list::StartPageService* start_page_service = 217 app_list::StartPageService* start_page_service =
216 app_list::StartPageService::Get(profile_); 218 app_list::StartPageService::Get(profile_);
217 if (start_page_service) 219 if (start_page_service)
218 start_page_service->RemoveObserver(this); 220 start_page_service->RemoveObserver(this);
219 #if defined(USE_ASH) 221 #if defined(USE_ASH)
220 app_sync_ui_state_watcher_.reset(); 222 app_sync_ui_state_watcher_.reset();
221 #endif 223 #endif
222 model_ = NULL; 224 model_ = NULL;
223 } 225 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 profile_->GetPath(), 281 profile_->GetPath(),
280 &users_); 282 &users_);
281 283
282 FOR_EACH_OBSERVER( 284 FOR_EACH_OBSERVER(
283 app_list::AppListViewDelegateObserver, observers_, OnProfilesChanged()); 285 app_list::AppListViewDelegateObserver, observers_, OnProfilesChanged());
284 } 286 }
285 287
286 void AppListViewDelegate::SetUpCustomLauncherPages() { 288 void AppListViewDelegate::SetUpCustomLauncherPages() {
287 std::vector<GURL> custom_launcher_page_urls; 289 std::vector<GURL> custom_launcher_page_urls;
288 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls); 290 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls);
291 if (custom_launcher_page_urls.empty())
292 return;
293
289 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); 294 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin();
290 it != custom_launcher_page_urls.end(); 295 it != custom_launcher_page_urls.end();
291 ++it) { 296 ++it) {
292 std::string extension_id = it->host(); 297 std::string extension_id = it->host();
293 apps::CustomLauncherPageContents* page_contents = 298 apps::CustomLauncherPageContents* page_contents =
294 new apps::CustomLauncherPageContents( 299 new apps::CustomLauncherPageContents(
295 scoped_ptr<extensions::AppDelegate>( 300 scoped_ptr<extensions::AppDelegate>(
296 new ChromeAppDelegate(scoped_ptr<ScopedKeepAlive>())), 301 new ChromeAppDelegate(scoped_ptr<ScopedKeepAlive>())),
297 extension_id); 302 extension_id);
298 page_contents->Initialize(profile_, *it); 303 page_contents->Initialize(profile_, *it);
299 custom_page_contents_.push_back(page_contents); 304 custom_page_contents_.push_back(page_contents);
300 } 305 }
306
307 // Only the first custom launcher page gets events dispatched to it.
308 launcher_page_event_dispatcher_.reset(
309 new app_list::LauncherPageEventDispatcher(
310 profile_, custom_launcher_page_urls[0].host()));
301 } 311 }
302 312
303 void AppListViewDelegate::OnHotwordStateChanged(bool started) { 313 void AppListViewDelegate::OnHotwordStateChanged(bool started) {
304 if (started) { 314 if (started) {
305 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) { 315 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) {
306 OnSpeechRecognitionStateChanged( 316 OnSpeechRecognitionStateChanged(
307 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING); 317 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING);
308 } 318 }
309 } else { 319 } else {
310 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING) 320 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING)
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 // after http://crbug.com/392763 resolved. 635 // after http://crbug.com/392763 resolved.
626 views::WebView* web_view = 636 views::WebView* web_view =
627 new views::WebView(web_contents->GetBrowserContext()); 637 new views::WebView(web_contents->GetBrowserContext());
628 web_view->SetPreferredSize(size); 638 web_view->SetPreferredSize(size);
629 web_view->SetWebContents(web_contents); 639 web_view->SetWebContents(web_contents);
630 web_views.push_back(web_view); 640 web_views.push_back(web_view);
631 } 641 }
632 642
633 return web_views; 643 return web_views;
634 } 644 }
645
646 void AppListViewDelegate::CustomLauncherPageAnimationChanged(double progress) {
647 if (launcher_page_event_dispatcher_)
648 launcher_page_event_dispatcher_->ProgressChanged(progress);
649 }
635 #endif 650 #endif
636 651
637 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { 652 bool AppListViewDelegate::IsSpeechRecognitionEnabled() {
638 app_list::StartPageService* service = 653 app_list::StartPageService* service =
639 app_list::StartPageService::Get(profile_); 654 app_list::StartPageService::Get(profile_);
640 return service && service->GetSpeechRecognitionContents(); 655 return service && service->GetSpeechRecognitionContents();
641 } 656 }
642 657
643 const app_list::AppListViewDelegate::Users& 658 const app_list::AppListViewDelegate::Users&
644 AppListViewDelegate::GetUsers() const { 659 AppListViewDelegate::GetUsers() const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 710
696 // SigninManagerFactory is not a leaky singleton (unlike this class), and 711 // SigninManagerFactory is not a leaky singleton (unlike this class), and
697 // its destructor will check that it has no remaining observers. 712 // its destructor will check that it has no remaining observers.
698 scoped_observer_.RemoveAll(); 713 scoped_observer_.RemoveAll();
699 SigninManagerFactory::GetInstance()->RemoveObserver(this); 714 SigninManagerFactory::GetInstance()->RemoveObserver(this);
700 break; 715 break;
701 default: 716 default:
702 NOTREACHED(); 717 NOTREACHED();
703 } 718 }
704 } 719 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | chrome/browser/ui/app_list/launcher_page_event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698