| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "chrome/browser/extensions/extension_service.h" | 44 #include "chrome/browser/extensions/extension_service.h" |
| 45 #include "chrome/browser/extensions/test_extension_system.h" | 45 #include "chrome/browser/extensions/test_extension_system.h" |
| 46 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 46 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| 47 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 47 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 48 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 48 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 49 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" | 49 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 50 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 50 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 51 #include "chrome/browser/ui/apps/chrome_app_delegate.h" | 51 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
| 52 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 52 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 53 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 53 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
| 54 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 54 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 55 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
| 55 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 56 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| 56 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" | 57 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont
roller.h" |
| 57 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 58 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 58 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 59 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 59 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 60 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 60 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 61 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 61 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 62 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 62 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 63 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
| 63 #include "chrome/browser/ui/browser.h" | 64 #include "chrome/browser/ui/browser.h" |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 ash::ShelfItem app_list; | 493 ash::ShelfItem app_list; |
| 493 app_list.type = ash::TYPE_APP_LIST; | 494 app_list.type = ash::TYPE_APP_LIST; |
| 494 model_->Add(app_list); | 495 model_->Add(app_list); |
| 495 } | 496 } |
| 496 | 497 |
| 497 void InitLauncherController() { | 498 void InitLauncherController() { |
| 498 AddAppListLauncherItem(); | 499 AddAppListLauncherItem(); |
| 499 launcher_controller_.reset( | 500 launcher_controller_.reset( |
| 500 new ChromeLauncherControllerImpl(profile(), model_.get())); | 501 new ChromeLauncherControllerImpl(profile(), model_.get())); |
| 501 launcher_controller_->Init(); | 502 launcher_controller_->Init(); |
| 503 ChromeLauncherController::set_instance(launcher_controller_.get()); |
| 502 } | 504 } |
| 503 | 505 |
| 504 void InitLauncherControllerWithBrowser() { | 506 void InitLauncherControllerWithBrowser() { |
| 505 InitLauncherController(); | 507 InitLauncherController(); |
| 506 chrome::NewTab(browser()); | 508 chrome::NewTab(browser()); |
| 507 browser()->window()->Show(); | 509 browser()->window()->Show(); |
| 508 } | 510 } |
| 509 | 511 |
| 510 void RecreateChromeLauncher() { | 512 void RecreateChromeLauncher() { |
| 511 // Destroy controller first if it exists. | 513 // Destroy controller first if it exists. |
| 512 launcher_controller_.reset(); | 514 launcher_controller_.reset(); |
| 513 model_.reset(new ash::ShelfModel); | 515 model_.reset(new ash::ShelfModel); |
| 514 AddAppListLauncherItem(); | 516 AddAppListLauncherItem(); |
| 515 launcher_controller_.reset( | 517 launcher_controller_.reset( |
| 516 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get())); | 518 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get())); |
| 517 launcher_controller_->Init(); | 519 launcher_controller_->Init(); |
| 520 ChromeLauncherController::set_instance(launcher_controller_.get()); |
| 518 } | 521 } |
| 519 | 522 |
| 520 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { | 523 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { |
| 521 app_service_->MergeDataAndStartSyncing( | 524 app_service_->MergeDataAndStartSyncing( |
| 522 syncer::APP_LIST, init_sync_list, | 525 syncer::APP_LIST, init_sync_list, |
| 523 base::WrapUnique(new syncer::FakeSyncChangeProcessor()), | 526 base::WrapUnique(new syncer::FakeSyncChangeProcessor()), |
| 524 base::WrapUnique(new syncer::SyncErrorFactoryMock())); | 527 base::WrapUnique(new syncer::SyncErrorFactoryMock())); |
| 525 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); | 528 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); |
| 526 } | 529 } |
| 527 | 530 |
| (...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3538 | 3541 |
| 3539 views::Widget* window_none_ = nullptr; | 3542 views::Widget* window_none_ = nullptr; |
| 3540 views::Widget* window_landscape_ = nullptr; | 3543 views::Widget* window_landscape_ = nullptr; |
| 3541 views::Widget* window_portrait_ = nullptr; | 3544 views::Widget* window_portrait_ = nullptr; |
| 3542 views::Widget* window_current_ = nullptr; | 3545 views::Widget* window_current_ = nullptr; |
| 3543 | 3546 |
| 3544 private: | 3547 private: |
| 3545 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); | 3548 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerOrientationTest); |
| 3546 }; | 3549 }; |
| 3547 | 3550 |
| 3551 class ChromeLauncherControllerArcDefaultAppsTest |
| 3552 : public ChromeLauncherControllerImplTest { |
| 3553 public: |
| 3554 ChromeLauncherControllerArcDefaultAppsTest() {} |
| 3555 ~ChromeLauncherControllerArcDefaultAppsTest() override {} |
| 3556 |
| 3557 protected: |
| 3558 void SetUp() override { |
| 3559 ArcAppListPrefs::UseTestDefaultAppsDirectory(); |
| 3560 ChromeLauncherControllerImplTest::SetUp(); |
| 3561 } |
| 3562 |
| 3563 void TestMe() { |
| 3564 arc_test_.SetUp(profile()); |
| 3565 InitLauncherController(); |
| 3566 |
| 3567 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
| 3568 EnableArc(false); |
| 3569 EXPECT_FALSE(arc_test_.arc_auth_service()->IsArcEnabled()); |
| 3570 ASSERT_TRUE(prefs->GetAppIds().size()); |
| 3571 |
| 3572 const std::string app_id = |
| 3573 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); |
| 3574 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3575 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); |
| 3576 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled()); |
| 3577 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3578 |
| 3579 // Stop Arc again. Shelf item should go away. |
| 3580 EnableArc(false); |
| 3581 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3582 |
| 3583 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); |
| 3584 EXPECT_TRUE(arc_test_.arc_auth_service()->IsArcEnabled()); |
| 3585 |
| 3586 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3587 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 3588 |
| 3589 std::string window_app_id("org.chromium.arc.1"); |
| 3590 CreateArcWindow(window_app_id); |
| 3591 arc_test_.app_instance()->SendTaskCreated(1, |
| 3592 arc_test_.fake_default_apps()[0]); |
| 3593 |
| 3594 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3595 EXPECT_FALSE( |
| 3596 launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 3597 } |
| 3598 |
| 3599 private: |
| 3600 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerArcDefaultAppsTest); |
| 3601 }; |
| 3602 |
| 3548 } // namespace | 3603 } // namespace |
| 3549 | 3604 |
| 3550 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { | 3605 TEST_F(ChromeLauncherControllerOrientationTest, ArcOrientationLock) { |
| 3551 ASSERT_TRUE(display::Display::HasInternalDisplay()); | 3606 ASSERT_TRUE(display::Display::HasInternalDisplay()); |
| 3552 | 3607 |
| 3553 extension_service_->AddExtension(arc_support_host_.get()); | 3608 extension_service_->AddExtension(arc_support_host_.get()); |
| 3554 arc_test_.SetUp(profile()); | 3609 arc_test_.SetUp(profile()); |
| 3555 EnableArc(true); | 3610 EnableArc(true); |
| 3556 EnableTabletMode(true); | 3611 EnableTabletMode(true); |
| 3557 | 3612 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3701 EXPECT_FALSE(controller->rotation_locked()); | 3756 EXPECT_FALSE(controller->rotation_locked()); |
| 3702 EXPECT_EQ(display::Display::ROTATE_0, | 3757 EXPECT_EQ(display::Display::ROTATE_0, |
| 3703 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3758 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3704 | 3759 |
| 3705 NotifyOnTaskOrientationLockRequested(task_id_current_, | 3760 NotifyOnTaskOrientationLockRequested(task_id_current_, |
| 3706 OrientationLock::CURRENT); | 3761 OrientationLock::CURRENT); |
| 3707 EXPECT_TRUE(controller->rotation_locked()); | 3762 EXPECT_TRUE(controller->rotation_locked()); |
| 3708 EXPECT_EQ(display::Display::ROTATE_0, | 3763 EXPECT_EQ(display::Display::ROTATE_0, |
| 3709 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); | 3764 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); |
| 3710 } | 3765 } |
| 3766 |
| 3767 TEST_F(ChromeLauncherControllerArcDefaultAppsTest, DefaultApps) { |
| 3768 TestMe(); |
| 3769 } |
| OLD | NEW |