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 "apps/custom_launcher_page_contents.h" | 9 #include "apps/custom_launcher_page_contents.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 app_list::StartPageService::Get(profile_); | 446 app_list::StartPageService::Get(profile_); |
447 if (service) { | 447 if (service) { |
448 service->AppListShown(); | 448 service->AppListShown(); |
449 if (service->HotwordEnabled()) { | 449 if (service->HotwordEnabled()) { |
450 HotwordService* hotword_service = | 450 HotwordService* hotword_service = |
451 HotwordServiceFactory::GetForProfile(profile_); | 451 HotwordServiceFactory::GetForProfile(profile_); |
452 if (hotword_service) | 452 if (hotword_service) |
453 hotword_service->RequestHotwordSession(this); | 453 hotword_service->RequestHotwordSession(this); |
454 } | 454 } |
455 } | 455 } |
456 AttachLauncherPageEventDispatcher(); | |
457 } | |
458 | |
459 void AppListViewDelegate::ViewReinitializedForProfileChange() { | |
460 AttachLauncherPageEventDispatcher(); | |
461 } | |
462 | |
463 void AppListViewDelegate::AttachLauncherPageEventDispatcher() { | |
464 std::vector<GURL> custom_launcher_page_urls; | |
465 GetCustomLauncherPageUrls(profile_, &custom_launcher_page_urls); | |
466 | |
467 // Only the first custom launcher page gets events dispatched to it. | |
468 if (!custom_launcher_page_urls.empty()) { | |
469 chrome::HostDesktopType desktop = chrome::GetHostDesktopTypeForNativeWindow( | |
470 controller_->GetAppListWindow()); | |
tapted
2014/11/03 00:31:20
(overridden by later comments, but worth noting:
calamity
2014/11/06 02:36:31
Acknowledged.
| |
471 launcher_page_event_dispatcher_.reset( | |
472 new app_list::LauncherPageEventDispatcherViews( | |
473 desktop, profile_, custom_launcher_page_urls[0].host())); | |
474 } | |
456 } | 475 } |
457 | 476 |
458 void AppListViewDelegate::Dismiss() { | 477 void AppListViewDelegate::Dismiss() { |
459 controller_->DismissView(); | 478 controller_->DismissView(); |
460 } | 479 } |
461 | 480 |
462 void AppListViewDelegate::ViewClosing() { | 481 void AppListViewDelegate::ViewClosing() { |
463 controller_->ViewClosing(); | 482 controller_->ViewClosing(); |
464 | 483 |
484 launcher_page_event_dispatcher_.reset(); | |
tapted
2014/11/03 00:31:20
This lifetime is really confusing. Why can't the e
calamity
2014/11/06 02:36:31
Done.
| |
485 | |
465 if (!profile_) | 486 if (!profile_) |
466 return; | 487 return; |
467 | 488 |
468 app_list::StartPageService* service = | 489 app_list::StartPageService* service = |
469 app_list::StartPageService::Get(profile_); | 490 app_list::StartPageService::Get(profile_); |
470 if (service) { | 491 if (service) { |
471 service->AppListHidden(); | 492 service->AppListHidden(); |
472 if (service->HotwordEnabled()) { | 493 if (service->HotwordEnabled()) { |
473 HotwordService* hotword_service = | 494 HotwordService* hotword_service = |
474 HotwordServiceFactory::GetForProfile(profile_); | 495 HotwordServiceFactory::GetForProfile(profile_); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 | 716 |
696 // SigninManagerFactory is not a leaky singleton (unlike this class), and | 717 // SigninManagerFactory is not a leaky singleton (unlike this class), and |
697 // its destructor will check that it has no remaining observers. | 718 // its destructor will check that it has no remaining observers. |
698 scoped_observer_.RemoveAll(); | 719 scoped_observer_.RemoveAll(); |
699 SigninManagerFactory::GetInstance()->RemoveObserver(this); | 720 SigninManagerFactory::GetInstance()->RemoveObserver(this); |
700 break; | 721 break; |
701 default: | 722 default: |
702 NOTREACHED(); | 723 NOTREACHED(); |
703 } | 724 } |
704 } | 725 } |
OLD | NEW |