| 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 } | 894 } |
| 895 | 895 |
| 896 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( | 896 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( |
| 897 ash::WmShelf* shelf) {} | 897 ash::WmShelf* shelf) {} |
| 898 | 898 |
| 899 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( | 899 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( |
| 900 ash::WmShelf* shelf) {} | 900 ash::WmShelf* shelf) {} |
| 901 | 901 |
| 902 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( | 902 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( |
| 903 const std::string& app_id) { | 903 const std::string& app_id) { |
| 904 const std::string shelf_app_id = |
| 905 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 904 for (IDToItemControllerMap::const_iterator i = | 906 for (IDToItemControllerMap::const_iterator i = |
| 905 id_to_item_controller_map_.begin(); | 907 id_to_item_controller_map_.begin(); |
| 906 i != id_to_item_controller_map_.end(); ++i) { | 908 i != id_to_item_controller_map_.end(); ++i) { |
| 907 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL) | 909 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL) |
| 908 continue; // Don't include panels | 910 continue; // Don't include panels |
| 909 if (i->second->app_id() == app_id) | 911 if (i->second->app_id() == shelf_app_id) |
| 910 return i->first; | 912 return i->first; |
| 911 } | 913 } |
| 912 return 0; | 914 return 0; |
| 913 } | 915 } |
| 914 | 916 |
| 915 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping( | 917 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping( |
| 916 ash::ShelfID id) const { | 918 ash::ShelfID id) const { |
| 917 return id_to_item_controller_map_.find(id) != | 919 return id_to_item_controller_map_.find(id) != |
| 918 id_to_item_controller_map_.end(); | 920 id_to_item_controller_map_.end(); |
| 919 } | 921 } |
| 920 | 922 |
| 921 const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID( | 923 const std::string& ChromeLauncherControllerImpl::GetAppIDForShelfID( |
| 922 ash::ShelfID id) { | 924 ash::ShelfID id) { |
| 923 LauncherItemController* controller = GetLauncherItemController(id); | 925 LauncherItemController* controller = GetLauncherItemController(id); |
| 924 return controller ? controller->app_id() : base::EmptyString(); | 926 return controller ? controller->app_id() : base::EmptyString(); |
| 925 } | 927 } |
| 926 | 928 |
| 927 void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) { | 929 void ChromeLauncherControllerImpl::PinAppWithID(const std::string& app_id) { |
| 928 if (GetPinnableForAppID(app_id, profile_) == | 930 const std::string shelf_app_id = |
| 931 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 932 if (GetPinnableForAppID(shelf_app_id, profile_) == |
| 929 AppListControllerDelegate::PIN_EDITABLE) | 933 AppListControllerDelegate::PIN_EDITABLE) |
| 930 DoPinAppWithID(app_id); | 934 DoPinAppWithID(shelf_app_id); |
| 931 else | 935 else |
| 932 NOTREACHED(); | 936 NOTREACHED(); |
| 933 } | 937 } |
| 934 | 938 |
| 935 bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) { | 939 bool ChromeLauncherControllerImpl::IsAppPinned(const std::string& app_id) { |
| 940 const std::string shelf_app_id = |
| 941 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 936 for (IDToItemControllerMap::const_iterator i = | 942 for (IDToItemControllerMap::const_iterator i = |
| 937 id_to_item_controller_map_.begin(); | 943 id_to_item_controller_map_.begin(); |
| 938 i != id_to_item_controller_map_.end(); ++i) { | 944 i != id_to_item_controller_map_.end(); ++i) { |
| 939 if (IsPinned(i->first) && i->second->app_id() == app_id) | 945 if (IsPinned(i->first) && i->second->app_id() == shelf_app_id) |
| 940 return true; | 946 return true; |
| 941 } | 947 } |
| 942 return false; | 948 return false; |
| 943 } | 949 } |
| 944 | 950 |
| 945 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { | 951 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { |
| 946 if (GetPinnableForAppID(app_id, profile_) == | 952 const std::string shelf_app_id = |
| 953 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 954 if (GetPinnableForAppID(shelf_app_id, profile_) == |
| 947 AppListControllerDelegate::PIN_EDITABLE) | 955 AppListControllerDelegate::PIN_EDITABLE) |
| 948 DoUnpinAppWithID(app_id, true /* update_prefs */); | 956 DoUnpinAppWithID(shelf_app_id, true /* update_prefs */); |
| 949 else | 957 else |
| 950 NOTREACHED(); | 958 NOTREACHED(); |
| 951 } | 959 } |
| 952 | 960 |
| 953 /////////////////////////////////////////////////////////////////////////////// | 961 /////////////////////////////////////////////////////////////////////////////// |
| 954 // LauncherAppUpdater::Delegate: | 962 // LauncherAppUpdater::Delegate: |
| 955 | 963 |
| 956 void ChromeLauncherControllerImpl::OnAppInstalled( | 964 void ChromeLauncherControllerImpl::OnAppInstalled( |
| 957 content::BrowserContext* browser_context, | 965 content::BrowserContext* browser_context, |
| 958 const std::string& app_id) { | 966 const std::string& app_id) { |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 if (index == -1) | 1705 if (index == -1) |
| 1698 continue; | 1706 continue; |
| 1699 ash::ShelfItem item = model_->items()[index]; | 1707 ash::ShelfItem item = model_->items()[index]; |
| 1700 item.image = image; | 1708 item.image = image; |
| 1701 if (arc_deferred_launcher_) | 1709 if (arc_deferred_launcher_) |
| 1702 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1710 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1703 model_->Set(index, item); | 1711 model_->Set(index, item); |
| 1704 // It's possible we're waiting on more than one item, so don't break. | 1712 // It's possible we're waiting on more than one item, so don't break. |
| 1705 } | 1713 } |
| 1706 } | 1714 } |
| OLD | NEW |