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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); | 286 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); |
287 items.push_back( | 287 items.push_back( |
288 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); | 288 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); |
289 return items; | 289 return items; |
290 } | 290 } |
291 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override { | 291 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override { |
292 return NULL; | 292 return NULL; |
293 } | 293 } |
294 bool IsDraggable() override { return false; } | 294 bool IsDraggable() override { return false; } |
295 bool CanPin() const override { | 295 bool CanPin() const override { |
296 return GetPinnableForAppID(app_id(), launcher_controller()->GetProfile()) == | 296 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) == |
297 AppListControllerDelegate::PIN_EDITABLE; | 297 AppListControllerDelegate::PIN_EDITABLE; |
298 } | 298 } |
299 bool ShouldShowTooltip() override { return false; } | 299 bool ShouldShowTooltip() override { return false; } |
300 | 300 |
301 private: | 301 private: |
302 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); | 302 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); |
303 }; | 303 }; |
304 | 304 |
305 } // namespace | 305 } // namespace |
306 | 306 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 InitLauncherController(); | 510 InitLauncherController(); |
511 chrome::NewTab(browser()); | 511 chrome::NewTab(browser()); |
512 browser()->window()->Show(); | 512 browser()->window()->Show(); |
513 } | 513 } |
514 | 514 |
515 void RecreateChromeLauncher() { | 515 void RecreateChromeLauncher() { |
516 // Destroy controller first if it exists. | 516 // Destroy controller first if it exists. |
517 launcher_controller_.reset(); | 517 launcher_controller_.reset(); |
518 model_.reset(new ash::ShelfModel); | 518 model_.reset(new ash::ShelfModel); |
519 AddAppListLauncherItem(); | 519 AddAppListLauncherItem(); |
520 launcher_controller_.reset( | 520 launcher_controller_ = |
521 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get())); | 521 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_.get()); |
522 launcher_controller_->Init(); | 522 launcher_controller_->Init(); |
523 } | 523 } |
524 | 524 |
525 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { | 525 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { |
526 app_service_->MergeDataAndStartSyncing( | 526 app_service_->MergeDataAndStartSyncing( |
527 syncer::APP_LIST, init_sync_list, | 527 syncer::APP_LIST, init_sync_list, |
528 base::MakeUnique<syncer::FakeSyncChangeProcessor>(), | 528 base::MakeUnique<syncer::FakeSyncChangeProcessor>(), |
529 base::MakeUnique<syncer::SyncErrorFactoryMock>()); | 529 base::MakeUnique<syncer::SyncErrorFactoryMock>()); |
530 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); | 530 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); |
531 } | 531 } |
532 | 532 |
533 void StopAppSyncService() { app_service_->StopSyncing(syncer::APP_LIST); } | 533 void StopAppSyncService() { app_service_->StopSyncing(syncer::APP_LIST); } |
534 | 534 |
535 void SetAppIconLoader(std::unique_ptr<AppIconLoader> loader) { | 535 void SetAppIconLoader(std::unique_ptr<AppIconLoader> loader) { |
536 std::vector<std::unique_ptr<AppIconLoader>> loaders; | 536 std::vector<std::unique_ptr<AppIconLoader>> loaders; |
537 loaders.push_back(std::move(loader)); | 537 loaders.push_back(std::move(loader)); |
538 launcher_controller_->SetAppIconLoadersForTest(loaders); | 538 launcher_controller_->SetAppIconLoadersForTest(loaders); |
539 } | 539 } |
540 | 540 |
541 void SetAppIconLoaders(std::unique_ptr<AppIconLoader> loader1, | 541 void SetAppIconLoaders(std::unique_ptr<AppIconLoader> loader1, |
542 std::unique_ptr<AppIconLoader> loader2) { | 542 std::unique_ptr<AppIconLoader> loader2) { |
543 std::vector<std::unique_ptr<AppIconLoader>> loaders; | 543 std::vector<std::unique_ptr<AppIconLoader>> loaders; |
544 loaders.push_back(std::move(loader1)); | 544 loaders.push_back(std::move(loader1)); |
545 loaders.push_back(std::move(loader2)); | 545 loaders.push_back(std::move(loader2)); |
546 launcher_controller_->SetAppIconLoadersForTest(loaders); | 546 launcher_controller_->SetAppIconLoadersForTest(loaders); |
547 } | 547 } |
548 | 548 |
549 void SetLauncherControllerHelper(LauncherControllerHelper* helper) { | 549 void SetLauncherControllerHelper(LauncherControllerHelper* helper) { |
550 launcher_controller_->SetLauncherControllerHelperForTest(helper); | 550 launcher_controller_->SetLauncherControllerHelperForTest( |
| 551 base::WrapUnique<LauncherControllerHelper>(helper)); |
551 } | 552 } |
552 | 553 |
553 void InsertPrefValue(base::ListValue* pref_value, | 554 void InsertPrefValue(base::ListValue* pref_value, |
554 int index, | 555 int index, |
555 const std::string& extension_id) { | 556 const std::string& extension_id) { |
556 auto entry = base::MakeUnique<base::DictionaryValue>(); | 557 auto entry = base::MakeUnique<base::DictionaryValue>(); |
557 entry->SetString(ash::launcher::kPinnedAppsPrefAppIDPath, extension_id); | 558 entry->SetString(ash::launcher::kPinnedAppsPrefAppIDPath, extension_id); |
558 pref_value->Insert(index, std::move(entry)); | 559 pref_value->Insert(index, std::move(entry)); |
559 } | 560 } |
560 | 561 |
(...skipping 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3413 model_->Move(1, 3); | 3414 model_->Move(1, 3); |
3414 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); | 3415 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
3415 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 3416 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); |
3416 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 3417 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
3417 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); | 3418 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); |
3418 | 3419 |
3419 launcher_controller_.reset(); | 3420 launcher_controller_.reset(); |
3420 model_.reset(new ash::ShelfModel); | 3421 model_.reset(new ash::ShelfModel); |
3421 | 3422 |
3422 AddAppListLauncherItem(); | 3423 AddAppListLauncherItem(); |
3423 launcher_controller_.reset( | 3424 launcher_controller_ = |
3424 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get())); | 3425 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_.get()); |
3425 helper = new TestLauncherControllerHelper(profile()); | 3426 helper = new TestLauncherControllerHelper(profile()); |
3426 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 3427 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
3427 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); | 3428 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); |
3428 SetLauncherControllerHelper(helper); | 3429 SetLauncherControllerHelper(helper); |
3429 launcher_controller_->Init(); | 3430 launcher_controller_->Init(); |
3430 | 3431 |
3431 // Check ShelfItems are restored after resetting ChromeLauncherControllerImpl. | 3432 // Check ShelfItems are restored after resetting ChromeLauncherControllerImpl. |
3432 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); | 3433 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
3433 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 3434 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); |
3434 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 3435 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
(...skipping 24 matching lines...) Expand all Loading... |
3459 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3460 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
3460 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 3461 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
3461 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 3462 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
3462 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 3463 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
3463 EXPECT_EQ(initial_size + 1, model_->items().size()); | 3464 EXPECT_EQ(initial_size + 1, model_->items().size()); |
3464 | 3465 |
3465 launcher_controller_.reset(); | 3466 launcher_controller_.reset(); |
3466 model_.reset(new ash::ShelfModel); | 3467 model_.reset(new ash::ShelfModel); |
3467 | 3468 |
3468 AddAppListLauncherItem(); | 3469 AddAppListLauncherItem(); |
3469 launcher_controller_.reset( | 3470 launcher_controller_ = |
3470 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get())); | 3471 base::MakeUnique<ChromeLauncherControllerImpl>(profile(), model_.get()); |
3471 helper = new TestLauncherControllerHelper(profile()); | 3472 helper = new TestLauncherControllerHelper(profile()); |
3472 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 3473 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
3473 SetLauncherControllerHelper(helper); | 3474 SetLauncherControllerHelper(helper); |
3474 // app_icon_loader is owned by ChromeLauncherControllerImpl. | 3475 // app_icon_loader is owned by ChromeLauncherControllerImpl. |
3475 app_icon_loader = new TestAppIconLoaderImpl; | 3476 app_icon_loader = new TestAppIconLoaderImpl; |
3476 app_icon_loader->AddSupportedApp("1"); | 3477 app_icon_loader->AddSupportedApp("1"); |
3477 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); | 3478 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
3478 launcher_controller_->Init(); | 3479 launcher_controller_->Init(); |
3479 | 3480 |
3480 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3481 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4009 app_service_->GetPinPosition(extension_misc::kChromeAppId))); | 4010 app_service_->GetPinPosition(extension_misc::kChromeAppId))); |
4010 EXPECT_TRUE( | 4011 EXPECT_TRUE( |
4011 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); | 4012 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); |
4012 EXPECT_TRUE( | 4013 EXPECT_TRUE( |
4013 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); | 4014 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); |
4014 EXPECT_TRUE( | 4015 EXPECT_TRUE( |
4015 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); | 4016 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); |
4016 EXPECT_TRUE( | 4017 EXPECT_TRUE( |
4017 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); | 4018 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); |
4018 } | 4019 } |
OLD | NEW |