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