| 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 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/browser/chromeos/extensions/gfx_utils.h" | 31 #include "chrome/browser/chromeos/extensions/gfx_utils.h" |
| 32 #include "chrome/browser/defaults.h" | 32 #include "chrome/browser/defaults.h" |
| 33 #include "chrome/browser/extensions/extension_util.h" | 33 #include "chrome/browser/extensions/extension_util.h" |
| 34 #include "chrome/browser/extensions/launch_util.h" | 34 #include "chrome/browser/extensions/launch_util.h" |
| 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
| 38 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 38 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 39 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 39 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 40 #include "chrome/browser/ui/ash/app_sync_ui_state.h" | 40 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| 41 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | |
| 42 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 41 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| 43 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 42 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
| 44 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" | 43 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
| 45 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" | 44 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
| 46 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 45 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 47 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 46 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
| 48 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" | 47 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll
er.h" |
| 49 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 48 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
| 50 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 49 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 51 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" | 50 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h
" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 UnpinAndUpdatePrefs(id, true /* update_prefs */); | 369 UnpinAndUpdatePrefs(id, true /* update_prefs */); |
| 371 } | 370 } |
| 372 | 371 |
| 373 void ChromeLauncherControllerImpl::UnpinAndUpdatePrefs(ash::ShelfID id, | 372 void ChromeLauncherControllerImpl::UnpinAndUpdatePrefs(ash::ShelfID id, |
| 374 bool update_prefs) { | 373 bool update_prefs) { |
| 375 LauncherItemController* controller = GetLauncherItemController(id); | 374 LauncherItemController* controller = GetLauncherItemController(id); |
| 376 CHECK(controller); | 375 CHECK(controller); |
| 377 | 376 |
| 378 if (update_prefs) { | 377 if (update_prefs) { |
| 379 ash::launcher::RemovePinPosition( | 378 ash::launcher::RemovePinPosition( |
| 380 profile(), ash::launcher::AppLauncherId(GetAppIDForShelfID(id))); | 379 profile(), ash::launcher::AppLauncherId(GetAppIDForShelfID(id), |
| 380 GetLaunchIDForShelfID(id))); |
| 381 } | 381 } |
| 382 | 382 |
| 383 if (controller->type() == LauncherItemController::TYPE_APP || | 383 if (controller->type() == LauncherItemController::TYPE_APP || |
| 384 controller->locked()) { | 384 controller->locked()) { |
| 385 UnpinRunningAppInternal(model_->ItemIndexByID(id)); | 385 UnpinRunningAppInternal(model_->ItemIndexByID(id)); |
| 386 } else { | 386 } else { |
| 387 LauncherItemClosed(id); | 387 LauncherItemClosed(id); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 414 ash::ShelfItemType type = model_->items()[index].type; | 414 ash::ShelfItemType type = model_->items()[index].type; |
| 415 std::string app_id; | 415 std::string app_id; |
| 416 return ((type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_PLATFORM_APP || | 416 return ((type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_PLATFORM_APP || |
| 417 type == ash::TYPE_WINDOWED_APP) && | 417 type == ash::TYPE_WINDOWED_APP) && |
| 418 model_->GetShelfItemDelegate(id)->CanPin()); | 418 model_->GetShelfItemDelegate(id)->CanPin()); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) { | 421 void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) { |
| 422 ash::ShelfID id = GetShelfIDForAppID(app_id); | 422 ash::ShelfID id = GetShelfIDForAppID(app_id); |
| 423 if (!IsPinned(id) && !IsWindowedAppInLauncher(app_id)) { | 423 if (!IsPinned(id) && !IsWindowedAppInLauncher(app_id)) { |
| 424 CreateAppShortcutLauncherItemWithType(app_id, model_->item_count(), | 424 CreateAppShortcutLauncherItemWithType(ash::launcher::AppLauncherId(app_id), |
| 425 model_->item_count(), |
| 425 ash::TYPE_WINDOWED_APP); | 426 ash::TYPE_WINDOWED_APP); |
| 426 id = GetShelfIDForAppID(app_id); | 427 id = GetShelfIDForAppID(app_id); |
| 427 } | 428 } |
| 428 CHECK(id); | 429 CHECK(id); |
| 429 id_to_item_controller_map_[id]->lock(); | 430 id_to_item_controller_map_[id]->lock(); |
| 430 } | 431 } |
| 431 | 432 |
| 432 void ChromeLauncherControllerImpl::UnlockV1AppWithID( | 433 void ChromeLauncherControllerImpl::UnlockV1AppWithID( |
| 433 const std::string& app_id) { | 434 const std::string& app_id) { |
| 434 ash::ShelfID id = GetShelfIDForAppID(app_id); | 435 ash::ShelfID id = GetShelfIDForAppID(app_id); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 Profile* profile) { | 834 Profile* profile) { |
| 834 if (user_switch_observer_.get()) | 835 if (user_switch_observer_.get()) |
| 835 user_switch_observer_->OnUserProfileReadyToSwitch(profile); | 836 user_switch_observer_->OnUserProfileReadyToSwitch(profile); |
| 836 } | 837 } |
| 837 | 838 |
| 838 ArcAppDeferredLauncherController* | 839 ArcAppDeferredLauncherController* |
| 839 ChromeLauncherControllerImpl::GetArcDeferredLauncher() { | 840 ChromeLauncherControllerImpl::GetArcDeferredLauncher() { |
| 840 return arc_deferred_launcher_.get(); | 841 return arc_deferred_launcher_.get(); |
| 841 } | 842 } |
| 842 | 843 |
| 844 const std::string& ChromeLauncherControllerImpl::GetLaunchIDForShelfID( |
| 845 ash::ShelfID id) { |
| 846 LauncherItemController* controller = GetLauncherItemController(id); |
| 847 return controller ? controller->launch_id() : base::EmptyString(); |
| 848 } |
| 849 |
| 843 void ChromeLauncherControllerImpl::AttachProfile(Profile* profile_to_attach) { | 850 void ChromeLauncherControllerImpl::AttachProfile(Profile* profile_to_attach) { |
| 844 // The base class implementation updates the helper and app icon loaders. | 851 // The base class implementation updates the helper and app icon loaders. |
| 845 ChromeLauncherController::AttachProfile(profile_to_attach); | 852 ChromeLauncherController::AttachProfile(profile_to_attach); |
| 846 | 853 |
| 847 pref_change_registrar_.Init(profile()->GetPrefs()); | 854 pref_change_registrar_.Init(profile()->GetPrefs()); |
| 848 pref_change_registrar_.Add( | 855 pref_change_registrar_.Add( |
| 849 prefs::kPolicyPinnedLauncherApps, | 856 prefs::kPolicyPinnedLauncherApps, |
| 850 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 857 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
| 851 base::Unretained(this))); | 858 base::Unretained(this))); |
| 852 // Handling of prefs::kArcEnabled change should be called deferred to avoid | 859 // Handling of prefs::kArcEnabled change should be called deferred to avoid |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 1013 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
| 1007 if (app_icon_loader) | 1014 if (app_icon_loader) |
| 1008 app_icon_loader->ClearImage(app_id); | 1015 app_icon_loader->ClearImage(app_id); |
| 1009 } | 1016 } |
| 1010 } | 1017 } |
| 1011 | 1018 |
| 1012 /////////////////////////////////////////////////////////////////////////////// | 1019 /////////////////////////////////////////////////////////////////////////////// |
| 1013 // ChromeLauncherControllerImpl protected: | 1020 // ChromeLauncherControllerImpl protected: |
| 1014 | 1021 |
| 1015 ash::ShelfID ChromeLauncherControllerImpl::CreateAppShortcutLauncherItem( | 1022 ash::ShelfID ChromeLauncherControllerImpl::CreateAppShortcutLauncherItem( |
| 1016 const std::string& app_id, | 1023 const ash::launcher::AppLauncherId& app_launcher_id, |
| 1017 int index) { | 1024 int index) { |
| 1018 return CreateAppShortcutLauncherItemWithType(app_id, index, | 1025 return CreateAppShortcutLauncherItemWithType(app_launcher_id, index, |
| 1019 ash::TYPE_APP_SHORTCUT); | 1026 ash::TYPE_APP_SHORTCUT); |
| 1020 } | 1027 } |
| 1021 | 1028 |
| 1022 const std::string& ChromeLauncherControllerImpl::GetAppIdFromShelfIdForTest( | 1029 const std::string& ChromeLauncherControllerImpl::GetAppIdFromShelfIdForTest( |
| 1023 ash::ShelfID id) { | 1030 ash::ShelfID id) { |
| 1024 return id_to_item_controller_map_[id]->app_id(); | 1031 return id_to_item_controller_map_[id]->app_id(); |
| 1025 } | 1032 } |
| 1026 | 1033 |
| 1027 /////////////////////////////////////////////////////////////////////////////// | 1034 /////////////////////////////////////////////////////////////////////////////// |
| 1028 // ChromeLauncherControllerImpl private: | 1035 // ChromeLauncherControllerImpl private: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1059 if (running_index != app_index) | 1066 if (running_index != app_index) |
| 1060 model_->Move(running_index, app_index); | 1067 model_->Move(running_index, app_index); |
| 1061 running_index++; | 1068 running_index++; |
| 1062 } | 1069 } |
| 1063 } | 1070 } |
| 1064 } | 1071 } |
| 1065 } | 1072 } |
| 1066 | 1073 |
| 1067 ash::ShelfID | 1074 ash::ShelfID |
| 1068 ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType( | 1075 ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType( |
| 1069 const std::string& app_id, | 1076 const ash::launcher::AppLauncherId& app_launcher_id, |
| 1070 int index, | 1077 int index, |
| 1071 ash::ShelfItemType shelf_item_type) { | 1078 ash::ShelfItemType shelf_item_type) { |
| 1072 AppShortcutLauncherItemController* controller = | 1079 AppShortcutLauncherItemController* controller = |
| 1073 AppShortcutLauncherItemController::Create(app_id, "", this); | 1080 AppShortcutLauncherItemController::Create( |
| 1074 ash::ShelfID shelf_id = InsertAppLauncherItem( | 1081 app_launcher_id.app_id(), app_launcher_id.launch_id(), this); |
| 1075 controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type); | 1082 ash::ShelfID shelf_id = |
| 1083 InsertAppLauncherItem(controller, app_launcher_id.app_id(), |
| 1084 ash::STATUS_CLOSED, index, shelf_item_type); |
| 1076 return shelf_id; | 1085 return shelf_id; |
| 1077 } | 1086 } |
| 1078 | 1087 |
| 1079 void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) { | 1088 void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) { |
| 1080 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | 1089 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); |
| 1081 CHECK(iter != id_to_item_controller_map_.end()); | 1090 CHECK(iter != id_to_item_controller_map_.end()); |
| 1082 CHECK(iter->second); | 1091 CHECK(iter->second); |
| 1083 const std::string& app_id = iter->second->app_id(); | 1092 const std::string& app_id = iter->second->app_id(); |
| 1084 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 1093 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
| 1085 if (app_icon_loader) | 1094 if (app_icon_loader) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1096 // If there is an item, do nothing and return. | 1105 // If there is an item, do nothing and return. |
| 1097 if (IsAppPinned(app_id)) | 1106 if (IsAppPinned(app_id)) |
| 1098 return; | 1107 return; |
| 1099 | 1108 |
| 1100 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id); | 1109 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id); |
| 1101 if (shelf_id) { | 1110 if (shelf_id) { |
| 1102 // App item exists, pin it | 1111 // App item exists, pin it |
| 1103 Pin(shelf_id); | 1112 Pin(shelf_id); |
| 1104 } else { | 1113 } else { |
| 1105 // Otherwise, create a shortcut item for it. | 1114 // Otherwise, create a shortcut item for it. |
| 1106 shelf_id = CreateAppShortcutLauncherItem(app_id, model_->item_count()); | 1115 shelf_id = CreateAppShortcutLauncherItem( |
| 1116 ash::launcher::AppLauncherId(app_id), model_->item_count()); |
| 1107 SyncPinPosition(shelf_id); | 1117 SyncPinPosition(shelf_id); |
| 1108 } | 1118 } |
| 1109 } | 1119 } |
| 1110 | 1120 |
| 1111 void ChromeLauncherControllerImpl::DoUnpinAppWithID(const std::string& app_id, | 1121 void ChromeLauncherControllerImpl::DoUnpinAppWithID(const std::string& app_id, |
| 1112 bool update_prefs) { | 1122 bool update_prefs) { |
| 1113 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id); | 1123 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id); |
| 1114 if (shelf_id && IsPinned(shelf_id)) | 1124 if (shelf_id && IsPinned(shelf_id)) |
| 1115 UnpinAndUpdatePrefs(shelf_id, update_prefs); | 1125 UnpinAndUpdatePrefs(shelf_id, update_prefs); |
| 1116 } | 1126 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 DCHECK(shelf_id); | 1160 DCHECK(shelf_id); |
| 1151 if (ignore_persist_pinned_state_change_) | 1161 if (ignore_persist_pinned_state_change_) |
| 1152 return; | 1162 return; |
| 1153 | 1163 |
| 1154 const int max_index = model_->item_count(); | 1164 const int max_index = model_->item_count(); |
| 1155 const int index = model_->ItemIndexByID(shelf_id); | 1165 const int index = model_->ItemIndexByID(shelf_id); |
| 1156 DCHECK_GT(index, 0); | 1166 DCHECK_GT(index, 0); |
| 1157 | 1167 |
| 1158 const std::string& app_id = GetAppIDForShelfID(shelf_id); | 1168 const std::string& app_id = GetAppIDForShelfID(shelf_id); |
| 1159 DCHECK(!app_id.empty()); | 1169 DCHECK(!app_id.empty()); |
| 1170 const std::string& launch_id = GetLaunchIDForShelfID(shelf_id); |
| 1160 | 1171 |
| 1161 std::string app_id_before; | 1172 std::string app_id_before; |
| 1173 std::string launch_id_before; |
| 1162 std::vector<ash::launcher::AppLauncherId> app_launcher_ids_after; | 1174 std::vector<ash::launcher::AppLauncherId> app_launcher_ids_after; |
| 1163 | 1175 |
| 1164 for (int i = index - 1; i > 0; --i) { | 1176 for (int i = index - 1; i > 0; --i) { |
| 1165 const ash::ShelfID shelf_id_before = model_->items()[i].id; | 1177 const ash::ShelfID shelf_id_before = model_->items()[i].id; |
| 1166 if (IsPinned(shelf_id_before)) { | 1178 if (IsPinned(shelf_id_before)) { |
| 1167 app_id_before = GetAppIDForShelfID(shelf_id_before); | 1179 app_id_before = GetAppIDForShelfID(shelf_id_before); |
| 1168 DCHECK(!app_id_before.empty()); | 1180 DCHECK(!app_id_before.empty()); |
| 1181 launch_id_before = GetLaunchIDForShelfID(shelf_id_before); |
| 1169 break; | 1182 break; |
| 1170 } | 1183 } |
| 1171 } | 1184 } |
| 1172 | 1185 |
| 1173 for (int i = index + 1; i < max_index; ++i) { | 1186 for (int i = index + 1; i < max_index; ++i) { |
| 1174 const ash::ShelfID shelf_id_after = model_->items()[i].id; | 1187 const ash::ShelfID shelf_id_after = model_->items()[i].id; |
| 1175 if (IsPinned(shelf_id_after)) { | 1188 if (IsPinned(shelf_id_after)) { |
| 1176 const std::string app_id_after = GetAppIDForShelfID(shelf_id_after); | 1189 const std::string app_id_after = GetAppIDForShelfID(shelf_id_after); |
| 1177 DCHECK(!app_id_after.empty()); | 1190 DCHECK(!app_id_after.empty()); |
| 1191 const std::string launch_id_after = GetLaunchIDForShelfID(shelf_id_after); |
| 1178 app_launcher_ids_after.push_back( | 1192 app_launcher_ids_after.push_back( |
| 1179 ash::launcher::AppLauncherId(app_id_after)); | 1193 ash::launcher::AppLauncherId(app_id_after, launch_id_after)); |
| 1180 } | 1194 } |
| 1181 } | 1195 } |
| 1182 | 1196 |
| 1183 ash::launcher::AppLauncherId app_launcher_id_before = | 1197 ash::launcher::AppLauncherId app_launcher_id_before = |
| 1184 app_id_before.empty() ? ash::launcher::AppLauncherId() | 1198 app_id_before.empty() |
| 1185 : ash::launcher::AppLauncherId(app_id_before); | 1199 ? ash::launcher::AppLauncherId() |
| 1200 : ash::launcher::AppLauncherId(app_id_before, launch_id_before); |
| 1186 | 1201 |
| 1187 ash::launcher::SetPinPosition(profile(), ash::launcher::AppLauncherId(app_id), | 1202 ash::launcher::SetPinPosition(profile(), |
| 1203 ash::launcher::AppLauncherId(app_id, launch_id), |
| 1188 app_launcher_id_before, app_launcher_ids_after); | 1204 app_launcher_id_before, app_launcher_ids_after); |
| 1189 } | 1205 } |
| 1190 | 1206 |
| 1191 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1207 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
| 1192 UpdateAppLaunchersFromPref(); | 1208 UpdateAppLaunchersFromPref(); |
| 1193 } | 1209 } |
| 1194 | 1210 |
| 1195 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1211 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
| 1196 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1212 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1197 FROM_HERE, | 1213 FROM_HERE, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1216 // Skip app list items if it exists. | 1232 // Skip app list items if it exists. |
| 1217 if (model_->items()[0].type == ash::TYPE_APP_LIST) | 1233 if (model_->items()[0].type == ash::TYPE_APP_LIST) |
| 1218 ++index; | 1234 ++index; |
| 1219 | 1235 |
| 1220 // Apply pins in two steps. At the first step, go through the list of apps to | 1236 // Apply pins in two steps. At the first step, go through the list of apps to |
| 1221 // pin, move existing pin to current position specified by |index| or create | 1237 // pin, move existing pin to current position specified by |index| or create |
| 1222 // the new pin at that position. | 1238 // the new pin at that position. |
| 1223 for (const auto& pref_app_launcher_id : pinned_apps) { | 1239 for (const auto& pref_app_launcher_id : pinned_apps) { |
| 1224 // Filter out apps that may be mapped wrongly. | 1240 // Filter out apps that may be mapped wrongly. |
| 1225 // TODO(khmel): b/31703859 is to refactore shelf mapping. | 1241 // TODO(khmel): b/31703859 is to refactore shelf mapping. |
| 1226 const std::string app_launcher_id_str = pref_app_launcher_id.ToString(); | 1242 const std::string app_id = pref_app_launcher_id.app_id(); |
| 1227 const std::string shelf_app_id = | 1243 const std::string shelf_app_id = |
| 1228 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId( | 1244 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 1229 app_launcher_id_str); | 1245 if (shelf_app_id != app_id) |
| 1230 if (shelf_app_id != app_launcher_id_str) | |
| 1231 continue; | 1246 continue; |
| 1232 | 1247 |
| 1233 // Update apps icon if applicable. | 1248 // Update apps icon if applicable. |
| 1234 OnAppUpdated(profile(), app_launcher_id_str); | 1249 OnAppUpdated(profile(), app_id); |
| 1235 | 1250 |
| 1236 // Find existing pin or app from the right of current |index|. | 1251 // Find existing pin or app from the right of current |index|. |
| 1237 int app_index = index; | 1252 int app_index = index; |
| 1238 for (; app_index < model_->item_count(); ++app_index) { | 1253 for (; app_index < model_->item_count(); ++app_index) { |
| 1239 const ash::ShelfItem& item = model_->items()[app_index]; | 1254 const ash::ShelfItem& item = model_->items()[app_index]; |
| 1240 const IDToItemControllerMap::iterator it = | 1255 const IDToItemControllerMap::iterator it = |
| 1241 id_to_item_controller_map_.find(item.id); | 1256 id_to_item_controller_map_.find(item.id); |
| 1242 if (it != id_to_item_controller_map_.end() && | 1257 if (it != id_to_item_controller_map_.end() && |
| 1243 it->second->app_id() == app_launcher_id_str) { | 1258 it->second->app_id() == app_id && |
| 1259 it->second->launch_id() == pref_app_launcher_id.launch_id()) { |
| 1244 break; | 1260 break; |
| 1245 } | 1261 } |
| 1246 } | 1262 } |
| 1247 if (app_index < model_->item_count()) { | 1263 if (app_index < model_->item_count()) { |
| 1248 // Found existing pin or running app. | 1264 // Found existing pin or running app. |
| 1249 const ash::ShelfItem item = model_->items()[app_index]; | 1265 const ash::ShelfItem item = model_->items()[app_index]; |
| 1250 if (item.type == ash::TYPE_APP_SHORTCUT || | 1266 if (item.type == ash::TYPE_APP_SHORTCUT || |
| 1251 item.type == ash::TYPE_BROWSER_SHORTCUT) { | 1267 item.type == ash::TYPE_BROWSER_SHORTCUT) { |
| 1252 // Just move to required position or keep it inplace. | 1268 // Just move to required position or keep it inplace. |
| 1253 model_->Move(app_index, index); | 1269 model_->Move(app_index, index); |
| 1254 } else { | 1270 } else { |
| 1255 PinRunningAppInternal(index, item.id); | 1271 PinRunningAppInternal(index, item.id); |
| 1256 } | 1272 } |
| 1257 DCHECK_EQ(model_->ItemIndexByID(item.id), index); | 1273 DCHECK_EQ(model_->ItemIndexByID(item.id), index); |
| 1258 } else { | 1274 } else { |
| 1259 // This is fresh pin. Create new one. | 1275 // This is fresh pin. Create new one. |
| 1260 DCHECK_NE(app_launcher_id_str, extension_misc::kChromeAppId); | 1276 DCHECK_NE(app_id, extension_misc::kChromeAppId); |
| 1261 CreateAppShortcutLauncherItem(app_launcher_id_str, index); | 1277 CreateAppShortcutLauncherItem(pref_app_launcher_id, index); |
| 1262 } | 1278 } |
| 1263 ++index; | 1279 ++index; |
| 1264 } | 1280 } |
| 1265 | 1281 |
| 1266 // At second step remove any pin to the right from the current index. | 1282 // At second step remove any pin to the right from the current index. |
| 1267 while (index < model_->item_count()) { | 1283 while (index < model_->item_count()) { |
| 1268 const ash::ShelfItem item = model_->items()[index]; | 1284 const ash::ShelfItem item = model_->items()[index]; |
| 1269 if (item.type != ash::TYPE_APP_SHORTCUT) { | 1285 if (item.type != ash::TYPE_APP_SHORTCUT) { |
| 1270 ++index; | 1286 ++index; |
| 1271 continue; | 1287 continue; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 if (index == -1) | 1565 if (index == -1) |
| 1550 continue; | 1566 continue; |
| 1551 ash::ShelfItem item = model_->items()[index]; | 1567 ash::ShelfItem item = model_->items()[index]; |
| 1552 item.image = image; | 1568 item.image = image; |
| 1553 if (arc_deferred_launcher_) | 1569 if (arc_deferred_launcher_) |
| 1554 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1570 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1555 model_->Set(index, item); | 1571 model_->Set(index, item); |
| 1556 // It's possible we're waiting on more than one item, so don't break. | 1572 // It's possible we're waiting on more than one item, so don't break. |
| 1557 } | 1573 } |
| 1558 } | 1574 } |
| OLD | NEW |