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/ash/chrome_shell_delegate.h" | 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 manager->Enable(context); | 382 manager->Enable(context); |
383 else | 383 else |
384 manager->Disable(); | 384 manager->Disable(); |
385 } | 385 } |
386 | 386 |
387 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); | 387 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); |
388 }; | 388 }; |
389 | 389 |
390 } // namespace | 390 } // namespace |
391 | 391 |
392 ChromeShellDelegate::ChromeShellDelegate() | 392 ChromeShellDelegate::ChromeShellDelegate() { |
393 : shelf_delegate_(NULL) { | |
394 PlatformInit(); | 393 PlatformInit(); |
395 } | 394 } |
396 | 395 |
397 ChromeShellDelegate::~ChromeShellDelegate() { | 396 ChromeShellDelegate::~ChromeShellDelegate() {} |
398 } | |
399 | 397 |
400 service_manager::Connector* ChromeShellDelegate::GetShellConnector() const { | 398 service_manager::Connector* ChromeShellDelegate::GetShellConnector() const { |
401 return content::ServiceManagerConnection::GetForProcess()->GetConnector(); | 399 return content::ServiceManagerConnection::GetForProcess()->GetConnector(); |
402 } | 400 } |
403 | 401 |
404 bool ChromeShellDelegate::IsMultiProfilesEnabled() const { | 402 bool ChromeShellDelegate::IsMultiProfilesEnabled() const { |
405 if (!profiles::IsMultipleProfilesEnabled()) | 403 if (!profiles::IsMultipleProfilesEnabled()) |
406 return false; | 404 return false; |
407 // If there is a user manager, we need to see that we can at least have 2 | 405 // If there is a user manager, we need to see that we can at least have 2 |
408 // simultaneous users to allow this feature. | 406 // simultaneous users to allow this feature. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 displayer.browser(), url_to_open, | 490 displayer.browser(), url_to_open, |
493 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | | 491 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | |
494 ui::PAGE_TRANSITION_FROM_API)); | 492 ui::PAGE_TRANSITION_FROM_API)); |
495 | 493 |
496 // Since the ScopedTabbedBrowserDisplayer does not guarantee that the | 494 // Since the ScopedTabbedBrowserDisplayer does not guarantee that the |
497 // browser will be shown on the active desktop, we ensure the visibility. | 495 // browser will be shown on the active desktop, we ensure the visibility. |
498 multi_user_util::MoveWindowToCurrentDesktop( | 496 multi_user_util::MoveWindowToCurrentDesktop( |
499 displayer.browser()->window()->GetNativeWindow()); | 497 displayer.browser()->window()->GetNativeWindow()); |
500 } | 498 } |
501 | 499 |
502 ash::ShelfDelegate* ChromeShellDelegate::CreateShelfDelegate( | 500 void ChromeShellDelegate::ShelfInit() { |
503 ash::ShelfModel* model) { | 501 if (!launcher_controller_) { |
504 if (!shelf_delegate_) { | 502 launcher_controller_ = base::MakeUnique<ChromeLauncherControllerImpl>( |
505 shelf_delegate_ = new ChromeLauncherControllerImpl(nullptr, model); | 503 nullptr, ash::Shell::Get()->shelf_model()); |
506 shelf_delegate_->Init(); | 504 launcher_controller_->Init(); |
507 } | 505 } |
508 return shelf_delegate_; | 506 } |
507 | |
508 void ChromeShellDelegate::ShelfShutdown() { | |
509 launcher_controller_.reset(); | |
509 } | 510 } |
510 | 511 |
511 ui::MenuModel* ChromeShellDelegate::CreateContextMenu( | 512 ui::MenuModel* ChromeShellDelegate::CreateContextMenu( |
512 ash::WmShelf* wm_shelf, | 513 ash::WmShelf* wm_shelf, |
513 const ash::ShelfItem* item) { | 514 const ash::ShelfItem* item) { |
514 // Don't show context menu for exclusive app runtime mode. | 515 // Don't show context menu for exclusive app runtime mode. |
515 if (chrome::IsRunningInAppMode()) | 516 if (chrome::IsRunningInAppMode()) |
516 return nullptr; | 517 return nullptr; |
517 | 518 |
518 // No context menu before |shelf_delegate_| is created. This is possible | 519 return LauncherContextMenu::Create(launcher_controller_.get(), item, |
James Cook
2017/04/19 00:23:47
Does this still need a null check for launcher_con
msw
2017/04/19 20:56:06
I restored the null check and comment.
| |
519 // now because CreateShelfDelegate is called by session state change | 520 wm_shelf); |
520 // via mojo asynchronously. Context menu could be triggered when the | |
521 // mojo message is still in-fly and crashes. | |
522 if (!shelf_delegate_) | |
523 return nullptr; | |
524 | |
525 return LauncherContextMenu::Create(shelf_delegate_, item, wm_shelf); | |
526 } | 521 } |
527 | 522 |
528 ash::GPUSupport* ChromeShellDelegate::CreateGPUSupport() { | 523 ash::GPUSupport* ChromeShellDelegate::CreateGPUSupport() { |
529 // Chrome uses real GPU support. | 524 // Chrome uses real GPU support. |
530 return new ash::GPUSupportImpl; | 525 return new ash::GPUSupportImpl; |
531 } | 526 } |
532 | 527 |
533 base::string16 ChromeShellDelegate::GetProductName() const { | 528 base::string16 ChromeShellDelegate::GetProductName() const { |
534 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 529 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
535 } | 530 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 Profile* profile = content::Details<Profile>(details).ptr(); | 606 Profile* profile = content::Details<Profile>(details).ptr(); |
612 if (!chromeos::ProfileHelper::IsSigninProfile(profile) && | 607 if (!chromeos::ProfileHelper::IsSigninProfile(profile) && |
613 !profile->IsGuestSession() && !profile->IsSupervised()) { | 608 !profile->IsGuestSession() && !profile->IsSupervised()) { |
614 // Start the error notifier services to show auth/sync notifications. | 609 // Start the error notifier services to show auth/sync notifications. |
615 SigninErrorNotifierFactory::GetForProfile(profile); | 610 SigninErrorNotifierFactory::GetForProfile(profile); |
616 SyncErrorNotifierFactory::GetForProfile(profile); | 611 SyncErrorNotifierFactory::GetForProfile(profile); |
617 } | 612 } |
618 // Do not use chrome::NOTIFICATION_PROFILE_ADDED because the | 613 // Do not use chrome::NOTIFICATION_PROFILE_ADDED because the |
619 // profile is not fully initialized by user_manager. Use | 614 // profile is not fully initialized by user_manager. Use |
620 // chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED instead. | 615 // chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED instead. |
621 if (shelf_delegate_) | 616 if (launcher_controller_) |
622 shelf_delegate_->OnUserProfileReadyToSwitch(profile); | 617 launcher_controller_->OnUserProfileReadyToSwitch(profile); |
623 break; | 618 break; |
624 } | 619 } |
625 case chrome::NOTIFICATION_SESSION_STARTED: | 620 case chrome::NOTIFICATION_SESSION_STARTED: |
626 // InitAfterFirstSessionStart() should only be called once upon system | 621 // InitAfterFirstSessionStart() should only be called once upon system |
627 // start. | 622 // start. |
628 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() < 2) | 623 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() < 2) |
629 InitAfterFirstSessionStart(); | 624 InitAfterFirstSessionStart(); |
630 break; | 625 break; |
631 default: | 626 default: |
632 NOTREACHED() << "Unexpected notification " << type; | 627 NOTREACHED() << "Unexpected notification " << type; |
633 } | 628 } |
634 } | 629 } |
635 | 630 |
636 void ChromeShellDelegate::PlatformInit() { | 631 void ChromeShellDelegate::PlatformInit() { |
637 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 632 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
638 content::NotificationService::AllSources()); | 633 content::NotificationService::AllSources()); |
639 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, | 634 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, |
640 content::NotificationService::AllSources()); | 635 content::NotificationService::AllSources()); |
641 } | 636 } |
OLD | NEW |