| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) { | 349 void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) { |
| 350 CHECK(id); | 350 CHECK(id); |
| 351 if (IsPinned(id)) { | 351 if (IsPinned(id)) { |
| 352 // Create a new shortcut controller. | 352 // Create a new shortcut controller. |
| 353 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | 353 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); |
| 354 CHECK(iter != id_to_item_controller_map_.end()); | 354 CHECK(iter != id_to_item_controller_map_.end()); |
| 355 SetItemStatus(id, ash::STATUS_CLOSED); | 355 SetItemStatus(id, ash::STATUS_CLOSED); |
| 356 std::string app_id = iter->second->app_id(); | 356 std::string app_id = iter->second->app_id(); |
| 357 iter->second = AppShortcutLauncherItemController::Create(app_id, this); | 357 std::string launch_id = iter->second->launch_id(); |
| 358 iter->second = |
| 359 AppShortcutLauncherItemController::Create(app_id, launch_id, this); |
| 358 iter->second->set_shelf_id(id); | 360 iter->second->set_shelf_id(id); |
| 359 // Existing controller is destroyed and replaced by registering again. | 361 // Existing controller is destroyed and replaced by registering again. |
| 360 SetShelfItemDelegate(id, iter->second); | 362 SetShelfItemDelegate(id, iter->second); |
| 361 } else { | 363 } else { |
| 362 LauncherItemClosed(id); | 364 LauncherItemClosed(id); |
| 363 } | 365 } |
| 364 } | 366 } |
| 365 | 367 |
| 366 void ChromeLauncherControllerImpl::Pin(ash::ShelfID id) { | 368 void ChromeLauncherControllerImpl::Pin(ash::ShelfID id) { |
| 367 DCHECK(HasShelfIDToAppIDMapping(id)); | 369 DCHECK(HasShelfIDToAppIDMapping(id)); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 ash::ShelfID id = GetShelfIDForAppID(app_id); | 495 ash::ShelfID id = GetShelfIDForAppID(app_id); |
| 494 if (id) { | 496 if (id) { |
| 495 LauncherItemController* controller = GetLauncherItemController(id); | 497 LauncherItemController* controller = GetLauncherItemController(id); |
| 496 controller->Activate(source); | 498 controller->Activate(source); |
| 497 return; | 499 return; |
| 498 } | 500 } |
| 499 | 501 |
| 500 // Create a temporary application launcher item and use it to see if there are | 502 // Create a temporary application launcher item and use it to see if there are |
| 501 // running instances. | 503 // running instances. |
| 502 std::unique_ptr<AppShortcutLauncherItemController> app_controller( | 504 std::unique_ptr<AppShortcutLauncherItemController> app_controller( |
| 503 AppShortcutLauncherItemController::Create(app_id, this)); | 505 AppShortcutLauncherItemController::Create(app_id, "", this)); |
| 504 if (!app_controller->GetRunningApplications().empty()) | 506 if (!app_controller->GetRunningApplications().empty()) |
| 505 app_controller->Activate(source); | 507 app_controller->Activate(source); |
| 506 else | 508 else |
| 507 LaunchApp(app_id, source, event_flags); | 509 LaunchApp(app_id, source, event_flags); |
| 508 } | 510 } |
| 509 | 511 |
| 510 extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType( | 512 extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType( |
| 511 ash::ShelfID id) { | 513 ash::ShelfID id) { |
| 512 const Extension* extension = | 514 const Extension* extension = |
| 513 GetExtensionForAppID(GetAppIDForShelfID(id), profile_); | 515 GetExtensionForAppID(GetAppIDForShelfID(id), profile_); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } | 890 } |
| 889 | 891 |
| 890 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( | 892 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( |
| 891 ash::WmShelf* shelf) {} | 893 ash::WmShelf* shelf) {} |
| 892 | 894 |
| 893 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( | 895 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( |
| 894 ash::WmShelf* shelf) {} | 896 ash::WmShelf* shelf) {} |
| 895 | 897 |
| 896 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( | 898 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( |
| 897 const std::string& app_id) { | 899 const std::string& app_id) { |
| 898 for (IDToItemControllerMap::const_iterator i = | 900 // Get shelf id for app_id and empty launch_id. |
| 899 id_to_item_controller_map_.begin(); | 901 return GetShelfIDForAppIDAndLaunchID(app_id, ""); |
| 900 i != id_to_item_controller_map_.end(); ++i) { | 902 } |
| 901 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL) | 903 |
| 904 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID( |
| 905 const std::string& app_id, |
| 906 const std::string& launch_id) { |
| 907 for (const auto& id_to_item_controller_pair : id_to_item_controller_map_) { |
| 908 if (id_to_item_controller_pair.second->type() == |
| 909 LauncherItemController::TYPE_APP_PANEL) |
| 902 continue; // Don't include panels | 910 continue; // Don't include panels |
| 903 if (i->second->app_id() == app_id) | 911 if (id_to_item_controller_pair.second->app_id() == app_id && |
| 904 return i->first; | 912 id_to_item_controller_pair.second->launch_id() == launch_id) { |
| 913 return id_to_item_controller_pair.first; |
| 914 } |
| 905 } | 915 } |
| 906 return 0; | 916 return 0; |
| 907 } | 917 } |
| 908 | 918 |
| 909 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping( | 919 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping( |
| 910 ash::ShelfID id) const { | 920 ash::ShelfID id) const { |
| 911 return id_to_item_controller_map_.find(id) != | 921 return id_to_item_controller_map_.find(id) != |
| 912 id_to_item_controller_map_.end(); | 922 id_to_item_controller_map_.end(); |
| 913 } | 923 } |
| 914 | 924 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } | 1064 } |
| 1055 } | 1065 } |
| 1056 } | 1066 } |
| 1057 | 1067 |
| 1058 ash::ShelfID | 1068 ash::ShelfID |
| 1059 ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType( | 1069 ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType( |
| 1060 const std::string& app_id, | 1070 const std::string& app_id, |
| 1061 int index, | 1071 int index, |
| 1062 ash::ShelfItemType shelf_item_type) { | 1072 ash::ShelfItemType shelf_item_type) { |
| 1063 AppShortcutLauncherItemController* controller = | 1073 AppShortcutLauncherItemController* controller = |
| 1064 AppShortcutLauncherItemController::Create(app_id, this); | 1074 AppShortcutLauncherItemController::Create(app_id, "", this); |
| 1065 ash::ShelfID shelf_id = InsertAppLauncherItem( | 1075 ash::ShelfID shelf_id = InsertAppLauncherItem( |
| 1066 controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type); | 1076 controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type); |
| 1067 return shelf_id; | 1077 return shelf_id; |
| 1068 } | 1078 } |
| 1069 | 1079 |
| 1070 void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) { | 1080 void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) { |
| 1071 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | 1081 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); |
| 1072 CHECK(iter != id_to_item_controller_map_.end()); | 1082 CHECK(iter != id_to_item_controller_map_.end()); |
| 1073 CHECK(iter->second); | 1083 CHECK(iter->second); |
| 1074 const std::string& app_id = iter->second->app_id(); | 1084 const std::string& app_id = iter->second->app_id(); |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 if (index == -1) | 1692 if (index == -1) |
| 1683 continue; | 1693 continue; |
| 1684 ash::ShelfItem item = model_->items()[index]; | 1694 ash::ShelfItem item = model_->items()[index]; |
| 1685 item.image = image; | 1695 item.image = image; |
| 1686 if (arc_deferred_launcher_) | 1696 if (arc_deferred_launcher_) |
| 1687 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1697 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1688 model_->Set(index, item); | 1698 model_->Set(index, item); |
| 1689 // It's possible we're waiting on more than one item, so don't break. | 1699 // It's possible we're waiting on more than one item, so don't break. |
| 1690 } | 1700 } |
| 1691 } | 1701 } |
| OLD | NEW |