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

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: 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();
214 custom_page_contents_.clear(); 215 custom_page_contents_.clear();
tapted 2014/11/06 06:05:45 launcher_page_event_dispatcher_.reset(); before th
calamity 2014/11/07 03:43:29 Done.
215 app_list::StartPageService* start_page_service = 216 app_list::StartPageService* start_page_service =
216 app_list::StartPageService::Get(profile_); 217 app_list::StartPageService::Get(profile_);
217 if (start_page_service) 218 if (start_page_service)
218 start_page_service->RemoveObserver(this); 219 start_page_service->RemoveObserver(this);
219 #if defined(USE_ASH) 220 #if defined(USE_ASH)
220 app_sync_ui_state_watcher_.reset(); 221 app_sync_ui_state_watcher_.reset();
221 #endif 222 #endif
222 model_ = NULL; 223 model_ = NULL;
223 } 224 }
224 225
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 profile_->GetPath(), 280 profile_->GetPath(),
280 &users_); 281 &users_);
281 282
282 FOR_EACH_OBSERVER( 283 FOR_EACH_OBSERVER(
283 app_list::AppListViewDelegateObserver, observers_, OnProfilesChanged()); 284 app_list::AppListViewDelegateObserver, observers_, OnProfilesChanged());
284 } 285 }
285 286
286 void AppListViewDelegate::SetUpCustomLauncherPages() { 287 void AppListViewDelegate::SetUpCustomLauncherPages() {
287 std::vector<GURL> custom_launcher_page_urls; 288 std::vector<GURL> custom_launcher_page_urls;
288 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls); 289 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls);
289 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin(); 290 for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin();
tapted 2014/11/06 06:05:45 nit: I'd probably go for if (custom_launcher_pag
calamity 2014/11/07 03:43:29 Done.
290 it != custom_launcher_page_urls.end(); 291 it != custom_launcher_page_urls.end();
291 ++it) { 292 ++it) {
292 std::string extension_id = it->host(); 293 std::string extension_id = it->host();
293 apps::CustomLauncherPageContents* page_contents = 294 apps::CustomLauncherPageContents* page_contents =
294 new apps::CustomLauncherPageContents( 295 new apps::CustomLauncherPageContents(
295 scoped_ptr<extensions::AppDelegate>( 296 scoped_ptr<extensions::AppDelegate>(
296 new ChromeAppDelegate(scoped_ptr<ScopedKeepAlive>())), 297 new ChromeAppDelegate(scoped_ptr<ScopedKeepAlive>())),
297 extension_id); 298 extension_id);
298 page_contents->Initialize(profile_, *it); 299 page_contents->Initialize(profile_, *it);
299 custom_page_contents_.push_back(page_contents); 300 custom_page_contents_.push_back(page_contents);
300 } 301 }
302
303 // Only the first custom launcher page gets events dispatched to it.
304 if (!custom_launcher_page_urls.empty()) {
305 launcher_page_event_dispatcher_.reset(
306 new app_list::LauncherPageEventDispatcher(
307 profile_, custom_launcher_page_urls[0].host()));
308 }
301 } 309 }
302 310
303 void AppListViewDelegate::OnHotwordStateChanged(bool started) { 311 void AppListViewDelegate::OnHotwordStateChanged(bool started) {
304 if (started) { 312 if (started) {
305 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) { 313 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) {
306 OnSpeechRecognitionStateChanged( 314 OnSpeechRecognitionStateChanged(
307 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING); 315 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING);
308 } 316 }
309 } else { 317 } else {
310 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING) 318 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. 633 // after http://crbug.com/392763 resolved.
626 views::WebView* web_view = 634 views::WebView* web_view =
627 new views::WebView(web_contents->GetBrowserContext()); 635 new views::WebView(web_contents->GetBrowserContext());
628 web_view->SetPreferredSize(size); 636 web_view->SetPreferredSize(size);
629 web_view->SetWebContents(web_contents); 637 web_view->SetWebContents(web_contents);
630 web_views.push_back(web_view); 638 web_views.push_back(web_view);
631 } 639 }
632 640
633 return web_views; 641 return web_views;
634 } 642 }
643
644 void AppListViewDelegate::CustomLauncherPageAnimationChanged(double progress) {
645 launcher_page_event_dispatcher_->ProgressChanged(progress);
tapted 2014/11/06 06:05:45 if (launcher_page_event_dispatcher_) ?
calamity 2014/11/07 03:43:29 Done.
646 }
635 #endif 647 #endif
636 648
637 bool AppListViewDelegate::IsSpeechRecognitionEnabled() { 649 bool AppListViewDelegate::IsSpeechRecognitionEnabled() {
638 app_list::StartPageService* service = 650 app_list::StartPageService* service =
639 app_list::StartPageService::Get(profile_); 651 app_list::StartPageService::Get(profile_);
640 return service && service->GetSpeechRecognitionContents(); 652 return service && service->GetSpeechRecognitionContents();
641 } 653 }
642 654
643 const app_list::AppListViewDelegate::Users& 655 const app_list::AppListViewDelegate::Users&
644 AppListViewDelegate::GetUsers() const { 656 AppListViewDelegate::GetUsers() const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 707
696 // SigninManagerFactory is not a leaky singleton (unlike this class), and 708 // SigninManagerFactory is not a leaky singleton (unlike this class), and
697 // its destructor will check that it has no remaining observers. 709 // its destructor will check that it has no remaining observers.
698 scoped_observer_.RemoveAll(); 710 scoped_observer_.RemoveAll();
699 SigninManagerFactory::GetInstance()->RemoveObserver(this); 711 SigninManagerFactory::GetInstance()->RemoveObserver(this);
700 break; 712 break;
701 default: 713 default:
702 NOTREACHED(); 714 NOTREACHED();
703 } 715 }
704 } 716 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698