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 // No context menu before |launcher_controller_| is created. This is possible |
519 // now because CreateShelfDelegate is called by session state change | 520 // now because ShelfInit() is called by session state change via mojo |
520 // via mojo asynchronously. Context menu could be triggered when the | 521 // asynchronously. Context menu could be triggered when the mojo message is |
521 // mojo message is still in-fly and crashes. | 522 // still in-fly and crashes. |
522 if (!shelf_delegate_) | 523 if (!launcher_controller_) |
523 return nullptr; | 524 return nullptr; |
524 | 525 |
525 return LauncherContextMenu::Create(shelf_delegate_, item, wm_shelf); | 526 return LauncherContextMenu::Create(launcher_controller_.get(), item, |
| 527 wm_shelf); |
526 } | 528 } |
527 | 529 |
528 ash::GPUSupport* ChromeShellDelegate::CreateGPUSupport() { | 530 ash::GPUSupport* ChromeShellDelegate::CreateGPUSupport() { |
529 // Chrome uses real GPU support. | 531 // Chrome uses real GPU support. |
530 return new ash::GPUSupportImpl; | 532 return new ash::GPUSupportImpl; |
531 } | 533 } |
532 | 534 |
533 base::string16 ChromeShellDelegate::GetProductName() const { | 535 base::string16 ChromeShellDelegate::GetProductName() const { |
534 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 536 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
535 } | 537 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 Profile* profile = content::Details<Profile>(details).ptr(); | 613 Profile* profile = content::Details<Profile>(details).ptr(); |
612 if (!chromeos::ProfileHelper::IsSigninProfile(profile) && | 614 if (!chromeos::ProfileHelper::IsSigninProfile(profile) && |
613 !profile->IsGuestSession() && !profile->IsSupervised()) { | 615 !profile->IsGuestSession() && !profile->IsSupervised()) { |
614 // Start the error notifier services to show auth/sync notifications. | 616 // Start the error notifier services to show auth/sync notifications. |
615 SigninErrorNotifierFactory::GetForProfile(profile); | 617 SigninErrorNotifierFactory::GetForProfile(profile); |
616 SyncErrorNotifierFactory::GetForProfile(profile); | 618 SyncErrorNotifierFactory::GetForProfile(profile); |
617 } | 619 } |
618 // Do not use chrome::NOTIFICATION_PROFILE_ADDED because the | 620 // Do not use chrome::NOTIFICATION_PROFILE_ADDED because the |
619 // profile is not fully initialized by user_manager. Use | 621 // profile is not fully initialized by user_manager. Use |
620 // chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED instead. | 622 // chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED instead. |
621 if (shelf_delegate_) | 623 if (launcher_controller_) |
622 shelf_delegate_->OnUserProfileReadyToSwitch(profile); | 624 launcher_controller_->OnUserProfileReadyToSwitch(profile); |
623 break; | 625 break; |
624 } | 626 } |
625 case chrome::NOTIFICATION_SESSION_STARTED: | 627 case chrome::NOTIFICATION_SESSION_STARTED: |
626 // InitAfterFirstSessionStart() should only be called once upon system | 628 // InitAfterFirstSessionStart() should only be called once upon system |
627 // start. | 629 // start. |
628 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() < 2) | 630 if (user_manager::UserManager::Get()->GetLoggedInUsers().size() < 2) |
629 InitAfterFirstSessionStart(); | 631 InitAfterFirstSessionStart(); |
630 break; | 632 break; |
631 default: | 633 default: |
632 NOTREACHED() << "Unexpected notification " << type; | 634 NOTREACHED() << "Unexpected notification " << type; |
633 } | 635 } |
634 } | 636 } |
635 | 637 |
636 void ChromeShellDelegate::PlatformInit() { | 638 void ChromeShellDelegate::PlatformInit() { |
637 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 639 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
638 content::NotificationService::AllSources()); | 640 content::NotificationService::AllSources()); |
639 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, | 641 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, |
640 content::NotificationService::AllSources()); | 642 content::NotificationService::AllSources()); |
641 } | 643 } |
OLD | NEW |