Chromium Code Reviews| Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| index 6d6f16d690c98eaa9a4fea47d0744fd589e6c052..2687c5b19afe3a58198069207b108d970517ae87 100644 |
| --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc |
| @@ -38,6 +38,7 @@ |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| +#include "chrome/browser/ui/ash/app_launcher_id.h" |
| #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
| #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h" |
| @@ -360,11 +361,8 @@ void ChromeLauncherControllerImpl::UnpinAndUpdatePrefs(ash::ShelfID id, |
| LauncherItemController* controller = GetLauncherItemController(id); |
| CHECK(controller); |
| - if (update_prefs) { |
| - ash::launcher::RemovePinPosition( |
| - profile(), ash::launcher::AppLauncherId(GetAppIDForShelfID(id), |
| - GetLaunchIDForShelfID(id))); |
| - } |
| + if (update_prefs) |
| + ash::launcher::RemovePinPosition(profile(), GetAppIDForShelfID(id)); |
| const ash::ShelfItem* item = GetItem(id); |
| if (item && (item->status != ash::STATUS_CLOSED || controller->locked())) |
| @@ -1078,17 +1076,20 @@ void ChromeLauncherControllerImpl::SyncPinPosition(ash::ShelfID shelf_id) { |
| const std::string& app_id = GetAppIDForShelfID(shelf_id); |
| DCHECK(!app_id.empty()); |
| const std::string& launch_id = GetLaunchIDForShelfID(shelf_id); |
| + if (!launch_id.empty()) { |
| + VLOG(2) << "Pinning app '" << app_id << "' with non-empty launch id '" |
| + << launch_id << "' is not supported."; |
| + return; |
| + } |
|
stevenjb
2017/02/08 18:19:03
Long term I think we are going to need to sync lau
khmel
2017/02/08 20:08:43
Agree, we can leave this code for now.
|
| std::string app_id_before; |
| - std::string launch_id_before; |
| - std::vector<ash::launcher::AppLauncherId> app_launcher_ids_after; |
| + std::vector<std::string> app_ids_after; |
| for (int i = index - 1; i > 0; --i) { |
| const ash::ShelfID shelf_id_before = model_->items()[i].id; |
| if (IsPinned(shelf_id_before)) { |
| app_id_before = GetAppIDForShelfID(shelf_id_before); |
| DCHECK(!app_id_before.empty()); |
| - launch_id_before = GetLaunchIDForShelfID(shelf_id_before); |
| break; |
| } |
| } |
| @@ -1098,20 +1099,12 @@ void ChromeLauncherControllerImpl::SyncPinPosition(ash::ShelfID shelf_id) { |
| if (IsPinned(shelf_id_after)) { |
| const std::string app_id_after = GetAppIDForShelfID(shelf_id_after); |
| DCHECK(!app_id_after.empty()); |
| - const std::string launch_id_after = GetLaunchIDForShelfID(shelf_id_after); |
| - app_launcher_ids_after.push_back( |
| - ash::launcher::AppLauncherId(app_id_after, launch_id_after)); |
| + app_ids_after.push_back(app_id_after); |
| } |
| } |
| - ash::launcher::AppLauncherId app_launcher_id_before = |
| - app_id_before.empty() |
| - ? ash::launcher::AppLauncherId() |
| - : ash::launcher::AppLauncherId(app_id_before, launch_id_before); |
| - |
| - ash::launcher::SetPinPosition(profile(), |
| - ash::launcher::AppLauncherId(app_id, launch_id), |
| - app_launcher_id_before, app_launcher_ids_after); |
| + ash::launcher::SetPinPosition(profile(), app_id, app_id_before, |
| + app_ids_after); |
| } |
| void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
| @@ -1138,7 +1131,7 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
| // into the pref state. Therefore we tell |persistPinnedState| to ignore any |
| // invocations while we are running. |
| base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true); |
| - const std::vector<ash::launcher::AppLauncherId> pinned_apps = |
| + const std::vector<std::string> pinned_apps = |
| ash::launcher::GetPinnedAppsFromPrefs(profile()->GetPrefs(), |
| launcher_controller_helper()); |
| @@ -1150,10 +1143,9 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
| // Apply pins in two steps. At the first step, go through the list of apps to |
| // pin, move existing pin to current position specified by |index| or create |
| // the new pin at that position. |
| - for (const auto& pref_app_launcher_id : pinned_apps) { |
| + for (const auto& app_id : pinned_apps) { |
| // Filter out apps that may be mapped wrongly. |
| // TODO(khmel): b/31703859 is to refactore shelf mapping. |
| - const std::string app_id = pref_app_launcher_id.app_id(); |
| const std::string shelf_app_id = |
| ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| if (shelf_app_id != app_id) |
| @@ -1169,8 +1161,7 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
| const IDToItemControllerMap::iterator it = |
| id_to_item_controller_map_.find(item.id); |
| if (it != id_to_item_controller_map_.end() && |
| - it->second->app_id() == app_id && |
| - it->second->launch_id() == pref_app_launcher_id.launch_id()) { |
| + it->second->app_id() == app_id && it->second->launch_id().empty()) { |
| break; |
| } |
| } |
| @@ -1188,7 +1179,8 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() { |
| } else { |
| // This is fresh pin. Create new one. |
| DCHECK_NE(app_id, extension_misc::kChromeAppId); |
| - CreateAppShortcutLauncherItem(pref_app_launcher_id, index); |
| + CreateAppShortcutLauncherItem(ash::launcher::AppLauncherId(app_id), |
| + index); |
| } |
| ++index; |
| } |