Chromium Code Reviews| 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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 902 | 902 |
| 903 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( | 903 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( |
| 904 const std::string& app_id) { | 904 const std::string& app_id) { |
| 905 // Get shelf id for app_id and empty launch_id. | 905 // Get shelf id for app_id and empty launch_id. |
| 906 return GetShelfIDForAppIDAndLaunchID(app_id, ""); | 906 return GetShelfIDForAppIDAndLaunchID(app_id, ""); |
| 907 } | 907 } |
| 908 | 908 |
| 909 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID( | 909 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID( |
| 910 const std::string& app_id, | 910 const std::string& app_id, |
| 911 const std::string& launch_id) { | 911 const std::string& launch_id) { |
| 912 const std::string shelf_app_id = | |
| 913 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | |
| 912 for (const auto& id_to_item_controller_pair : id_to_item_controller_map_) { | 914 for (const auto& id_to_item_controller_pair : id_to_item_controller_map_) { |
| 913 if (id_to_item_controller_pair.second->type() == | 915 if (id_to_item_controller_pair.second->type() == |
| 914 LauncherItemController::TYPE_APP_PANEL) | 916 LauncherItemController::TYPE_APP_PANEL) |
| 915 continue; // Don't include panels | 917 continue; // Don't include panels |
| 916 if (id_to_item_controller_pair.second->app_id() == app_id && | 918 if (id_to_item_controller_pair.second->app_id() == shelf_app_id && |
| 917 id_to_item_controller_pair.second->launch_id() == launch_id) { | 919 id_to_item_controller_pair.second->launch_id() == launch_id) { |
| 918 return id_to_item_controller_pair.first; | 920 return id_to_item_controller_pair.first; |
| 919 } | 921 } |
| 920 } | 922 } |
| 921 return 0; | 923 return 0; |
| 922 } | 924 } |
| 923 | 925 |
| 924 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping( | 926 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping( |
| 925 ash::ShelfID id) const { | 927 ash::ShelfID id) const { |
| 926 return id_to_item_controller_map_.find(id) != | 928 return id_to_item_controller_map_.find(id) != |
| 927 id_to_item_controller_map_.end(); | 929 id_to_item_controller_map_.end(); |
| 928 } | 930 } |
| 929 | 931 |
| 930 const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID( | 932 const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID( |
| 931 ash::ShelfID id) { | 933 ash::ShelfID id) { |
| 932 LauncherItemController* controller = GetLauncherItemController(id); | 934 LauncherItemController* controller = GetLauncherItemController(id); |
| 933 return controller ? controller->app_id() : base::EmptyString(); | 935 return controller ? controller->app_id() : base::EmptyString(); |
| 934 } | 936 } |
| 935 | 937 |
| 936 void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) { | 938 void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) { |
| 937 if (GetPinnableForAppID(app_id, profile_) == | 939 const std::string shelf_app_id = |
| 940 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | |
| 941 if (GetPinnableForAppID(shelf_app_id, profile_) == | |
| 938 AppListControllerDelegate::PIN_EDITABLE) | 942 AppListControllerDelegate::PIN_EDITABLE) |
| 939 DoPinAppWithID(app_id); | 943 DoPinAppWithID(shelf_app_id); |
| 940 else | 944 else |
| 941 NOTREACHED(); | 945 NOTREACHED(); |
| 942 } | 946 } |
| 943 | 947 |
| 944 bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) { | 948 bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) { |
| 949 const std::string shelf_app_id = | |
| 950 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | |
| 945 for (IDToItemControllerMap::const_iterator i = | 951 for (IDToItemControllerMap::const_iterator i = |
| 946 id_to_item_controller_map_.begin(); | 952 id_to_item_controller_map_.begin(); |
| 947 i != id_to_item_controller_map_.end(); ++i) { | 953 i != id_to_item_controller_map_.end(); ++i) { |
| 948 if (IsPinned(i->first) && i->second->app_id() == app_id) | 954 if (IsPinned(i->first) && i->second->app_id() == shelf_app_id) |
| 949 return true; | 955 return true; |
| 950 } | 956 } |
| 951 return false; | 957 return false; |
| 952 } | 958 } |
| 953 | 959 |
| 954 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { | 960 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { |
| 955 if (GetPinnableForAppID(app_id, profile_) == | 961 const std::string shelf_app_id = |
| 962 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | |
| 963 if (GetPinnableForAppID(shelf_app_id, profile_) == | |
|
Mr4D (OOO till 08-26)
2016/09/19 17:30:19
The danger of having several app_id's. We might co
| |
| 956 AppListControllerDelegate::PIN_EDITABLE) | 964 AppListControllerDelegate::PIN_EDITABLE) |
| 957 DoUnpinAppWithID(app_id, true /* update_prefs */); | 965 DoUnpinAppWithID(shelf_app_id, true /* update_prefs */); |
| 958 else | 966 else |
| 959 NOTREACHED(); | 967 NOTREACHED(); |
| 960 } | 968 } |
| 961 | 969 |
| 962 /////////////////////////////////////////////////////////////////////////////// | 970 /////////////////////////////////////////////////////////////////////////////// |
| 963 // LauncherAppUpdater::Delegate: | 971 // LauncherAppUpdater::Delegate: |
| 964 | 972 |
| 965 void ChromeLauncherControllerImpl::OnAppInstalled( | 973 void ChromeLauncherControllerImpl::OnAppInstalled( |
| 966 content::BrowserContext* browser_context, | 974 content::BrowserContext* browser_context, |
| 967 const std::string& app_id) { | 975 const std::string& app_id) { |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1711 if (index == -1) | 1719 if (index == -1) |
| 1712 continue; | 1720 continue; |
| 1713 ash::ShelfItem item = model_->items()[index]; | 1721 ash::ShelfItem item = model_->items()[index]; |
| 1714 item.image = image; | 1722 item.image = image; |
| 1715 if (arc_deferred_launcher_) | 1723 if (arc_deferred_launcher_) |
| 1716 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1724 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1717 model_->Set(index, item); | 1725 model_->Set(index, item); |
| 1718 // It's possible we're waiting on more than one item, so don't break. | 1726 // It's possible we're waiting on more than one item, so don't break. |
| 1719 } | 1727 } |
| 1720 } | 1728 } |
| OLD | NEW |