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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2608013002: mash: Replace ShelfItemDelegate::CanPin with ShelfItem::pinned_by_policy. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
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 5f272d6c4edffb2035868cf40a4b34c4621d6cd4..36bfd4c1507a224c9e49658ec97266f78a4cf0b7 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
@@ -399,9 +399,8 @@ void ChromeLauncherControllerImpl::TogglePinned(ash::ShelfID id) {
bool ChromeLauncherControllerImpl::IsPinnable(ash::ShelfID id) const {
const ash::ShelfItem* item = GetItem(id);
- return (item && (item->type == ash::TYPE_APP_SHORTCUT ||
- item->type == ash::TYPE_APP) &&
- model_->GetShelfItemDelegate(id)->CanPin());
+ return item && !item->pinned_by_policy &&
James Cook 2017/01/04 17:32:17 nit: The !pinned_by_policy part is a bit confusing
msw 2017/01/04 22:23:04 Moved into LauncherContextMenu::IsCommandIdEnabled
+ (item->type == ash::TYPE_APP_SHORTCUT || item->type == ash::TYPE_APP);
}
void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) {
@@ -1209,6 +1208,17 @@ void ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref() {
LauncherItemClosed(item.id);
}
}
+
+ // Update the policy-pinned flag for each item on the shelf.
James Cook 2017/01/04 17:32:17 Not your fault, but this function is too long. Ple
msw 2017/01/04 22:23:04 Done.
+ for (index = 0; index < model_->item_count(); index++) {
+ ash::ShelfItem item = model_->items()[index];
+ const bool pinned_by_policy = GetPinnableForAppID(item.app_id, profile()) ==
+ AppListControllerDelegate::PIN_FIXED;
James Cook 2017/01/04 17:32:17 optional: It's pretty confusing that PIN_FIXED liv
msw 2017/01/04 22:23:04 Doesn't make sense to move the enum in this cl.
+ if (item.pinned_by_policy != pinned_by_policy) {
+ item.pinned_by_policy = pinned_by_policy;
+ model_->Set(index, item);
+ }
+ }
}
void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() {

Powered by Google App Engine
This is Rietveld 408576698