Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2295343002: arc: Dont sync app list change caused by Arc opt out. (Closed)
Patch Set: nit Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 item.type = ash::TYPE_APP_SHORTCUT; 376 item.type = ash::TYPE_APP_SHORTCUT;
377 model_->Set(index, item); 377 model_->Set(index, item);
378 } else if (item.type != ash::TYPE_APP_SHORTCUT) { 378 } else if (item.type != ash::TYPE_APP_SHORTCUT) {
379 return; 379 return;
380 } 380 }
381 381
382 SyncPinPosition(id); 382 SyncPinPosition(id);
383 } 383 }
384 384
385 void ChromeLauncherControllerImpl::Unpin(ash::ShelfID id) { 385 void ChromeLauncherControllerImpl::Unpin(ash::ShelfID id) {
386 UnpinAndUpdatePrefs(id, true /* update_prefs */);
387 }
388
389 void ChromeLauncherControllerImpl::UnpinAndUpdatePrefs(ash::ShelfID id,
390 bool update_prefs) {
386 LauncherItemController* controller = GetLauncherItemController(id); 391 LauncherItemController* controller = GetLauncherItemController(id);
387 CHECK(controller); 392 CHECK(controller);
388 393
389 ash::launcher::RemovePinPosition(profile_, GetAppIDForShelfID(id)); 394 if (update_prefs)
395 ash::launcher::RemovePinPosition(profile_, GetAppIDForShelfID(id));
390 396
391 if (controller->type() == LauncherItemController::TYPE_APP || 397 if (controller->type() == LauncherItemController::TYPE_APP ||
392 controller->locked()) { 398 controller->locked()) {
393 UnpinRunningAppInternal(model_->ItemIndexByID(id)); 399 UnpinRunningAppInternal(model_->ItemIndexByID(id));
394 } else { 400 } else {
395 LauncherItemClosed(id); 401 LauncherItemClosed(id);
396 } 402 }
397 } 403 }
398 404
399 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { 405 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) {
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 i != id_to_item_controller_map_.end(); ++i) { 938 i != id_to_item_controller_map_.end(); ++i) {
933 if (IsPinned(i->first) && i->second->app_id() == app_id) 939 if (IsPinned(i->first) && i->second->app_id() == app_id)
934 return true; 940 return true;
935 } 941 }
936 return false; 942 return false;
937 } 943 }
938 944
939 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) { 945 void ChromeLauncherControllerImpl::UnpinAppWithID(const std::string& app_id) {
940 if (GetPinnableForAppID(app_id, profile_) == 946 if (GetPinnableForAppID(app_id, profile_) ==
941 AppListControllerDelegate::PIN_EDITABLE) 947 AppListControllerDelegate::PIN_EDITABLE)
942 DoUnpinAppWithID(app_id); 948 DoUnpinAppWithID(app_id, true /* update_prefs */);
943 else 949 else
944 NOTREACHED(); 950 NOTREACHED();
945 } 951 }
946 952
947 /////////////////////////////////////////////////////////////////////////////// 953 ///////////////////////////////////////////////////////////////////////////////
948 // LauncherAppUpdater::Delegate: 954 // LauncherAppUpdater::Delegate:
949 955
950 void ChromeLauncherControllerImpl::OnAppInstalled( 956 void ChromeLauncherControllerImpl::OnAppInstalled(
951 content::BrowserContext* browser_context, 957 content::BrowserContext* browser_context,
952 const std::string& app_id) { 958 const std::string& app_id) {
(...skipping 20 matching lines...) Expand all
973 void ChromeLauncherControllerImpl::OnAppUninstalledPrepared( 979 void ChromeLauncherControllerImpl::OnAppUninstalledPrepared(
974 content::BrowserContext* browser_context, 980 content::BrowserContext* browser_context,
975 const std::string& app_id) { 981 const std::string& app_id) {
976 // Since we might have windowed apps of this type which might have 982 // Since we might have windowed apps of this type which might have
977 // outstanding locks which needs to be removed. 983 // outstanding locks which needs to be removed.
978 const Profile* profile = Profile::FromBrowserContext(browser_context); 984 const Profile* profile = Profile::FromBrowserContext(browser_context);
979 if (GetShelfIDForAppID(app_id)) 985 if (GetShelfIDForAppID(app_id))
980 CloseWindowedAppsFromRemovedExtension(app_id, profile); 986 CloseWindowedAppsFromRemovedExtension(app_id, profile);
981 987
982 if (IsAppPinned(app_id)) { 988 if (IsAppPinned(app_id)) {
983 if (profile == profile_) 989 if (profile == profile_) {
984 DoUnpinAppWithID(app_id); 990 // Some apps may be removed locally. Don't remove pin position from sync
991 // model. When needed, it is automatically deleted on app list model
992 // update.
993 DoUnpinAppWithID(app_id, false /* update_prefs */);
994 }
985 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 995 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
986 if (app_icon_loader) 996 if (app_icon_loader)
987 app_icon_loader->ClearImage(app_id); 997 app_icon_loader->ClearImage(app_id);
988 } 998 }
989 } 999 }
990 1000
991 /////////////////////////////////////////////////////////////////////////////// 1001 ///////////////////////////////////////////////////////////////////////////////
992 // ChromeLauncherControllerImpl protected: 1002 // ChromeLauncherControllerImpl protected:
993 1003
994 ash::ShelfID ChromeLauncherControllerImpl::CreateAppShortcutLauncherItem( 1004 ash::ShelfID ChromeLauncherControllerImpl::CreateAppShortcutLauncherItem(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 if (shelf_id) { 1102 if (shelf_id) {
1093 // App item exists, pin it 1103 // App item exists, pin it
1094 Pin(shelf_id); 1104 Pin(shelf_id);
1095 } else { 1105 } else {
1096 // Otherwise, create a shortcut item for it. 1106 // Otherwise, create a shortcut item for it.
1097 shelf_id = CreateAppShortcutLauncherItem(app_id, model_->item_count()); 1107 shelf_id = CreateAppShortcutLauncherItem(app_id, model_->item_count());
1098 SyncPinPosition(shelf_id); 1108 SyncPinPosition(shelf_id);
1099 } 1109 }
1100 } 1110 }
1101 1111
1102 void ChromeLauncherControllerImpl::DoUnpinAppWithID(const std::string& app_id) { 1112 void ChromeLauncherControllerImpl::DoUnpinAppWithID(const std::string& app_id,
1113 bool update_prefs) {
1103 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id); 1114 ash::ShelfID shelf_id = GetShelfIDForAppID(app_id);
1104 if (shelf_id && IsPinned(shelf_id)) 1115 if (shelf_id && IsPinned(shelf_id))
1105 Unpin(shelf_id); 1116 UnpinAndUpdatePrefs(shelf_id, update_prefs);
1106 } 1117 }
1107 1118
1108 int ChromeLauncherControllerImpl::PinRunningAppInternal(int index, 1119 int ChromeLauncherControllerImpl::PinRunningAppInternal(int index,
1109 ash::ShelfID shelf_id) { 1120 ash::ShelfID shelf_id) {
1110 int running_index = model_->ItemIndexByID(shelf_id); 1121 int running_index = model_->ItemIndexByID(shelf_id);
1111 ash::ShelfItem item = model_->items()[running_index]; 1122 ash::ShelfItem item = model_->items()[running_index];
1112 DCHECK(item.type == ash::TYPE_WINDOWED_APP || 1123 DCHECK(item.type == ash::TYPE_WINDOWED_APP ||
1113 item.type == ash::TYPE_PLATFORM_APP); 1124 item.type == ash::TYPE_PLATFORM_APP);
1114 item.type = ash::TYPE_APP_SHORTCUT; 1125 item.type = ash::TYPE_APP_SHORTCUT;
1115 model_->Set(running_index, item); 1126 model_->Set(running_index, item);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 if (index == -1) 1698 if (index == -1)
1688 continue; 1699 continue;
1689 ash::ShelfItem item = model_->items()[index]; 1700 ash::ShelfItem item = model_->items()[index];
1690 item.image = image; 1701 item.image = image;
1691 if (arc_deferred_launcher_) 1702 if (arc_deferred_launcher_)
1692 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1703 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1693 model_->Set(index, item); 1704 model_->Set(index, item);
1694 // It's possible we're waiting on more than one item, so don't break. 1705 // It's possible we're waiting on more than one item, so don't break.
1695 } 1706 }
1696 } 1707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698