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

Side by Side 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 3 years, 11 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return; // May happen if item closed with menu open. 392 return; // May happen if item closed with menu open.
393 393
394 if (IsPinned(id)) 394 if (IsPinned(id))
395 Unpin(id); 395 Unpin(id);
396 else 396 else
397 Pin(id); 397 Pin(id);
398 } 398 }
399 399
400 bool ChromeLauncherControllerImpl::IsPinnable(ash::ShelfID id) const { 400 bool ChromeLauncherControllerImpl::IsPinnable(ash::ShelfID id) const {
401 const ash::ShelfItem* item = GetItem(id); 401 const ash::ShelfItem* item = GetItem(id);
402 return (item && (item->type == ash::TYPE_APP_SHORTCUT || 402 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
403 item->type == ash::TYPE_APP) && 403 (item->type == ash::TYPE_APP_SHORTCUT || item->type == ash::TYPE_APP);
404 model_->GetShelfItemDelegate(id)->CanPin());
405 } 404 }
406 405
407 void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) { 406 void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) {
408 ash::ShelfID id = GetShelfIDForAppID(app_id); 407 ash::ShelfID id = GetShelfIDForAppID(app_id);
409 if (id == ash::kInvalidShelfID) { 408 if (id == ash::kInvalidShelfID) {
410 CreateAppShortcutLauncherItemWithType(ash::launcher::AppLauncherId(app_id), 409 CreateAppShortcutLauncherItemWithType(ash::launcher::AppLauncherId(app_id),
411 model_->item_count(), ash::TYPE_APP); 410 model_->item_count(), ash::TYPE_APP);
412 id = GetShelfIDForAppID(app_id); 411 id = GetShelfIDForAppID(app_id);
413 } 412 }
414 CHECK(id); 413 CHECK(id);
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 DCHECK_NE(controller->app_id(), extension_misc::kChromeAppId); 1201 DCHECK_NE(controller->app_id(), extension_misc::kChromeAppId);
1203 1202
1204 if (item.status != ash::STATUS_CLOSED || controller->locked()) { 1203 if (item.status != ash::STATUS_CLOSED || controller->locked()) {
1205 UnpinRunningAppInternal(index); 1204 UnpinRunningAppInternal(index);
1206 // Note, item can be moved to the right due weighting in shelf model. 1205 // Note, item can be moved to the right due weighting in shelf model.
1207 DCHECK_GE(model_->ItemIndexByID(item.id), index); 1206 DCHECK_GE(model_->ItemIndexByID(item.id), index);
1208 } else { 1207 } else {
1209 LauncherItemClosed(item.id); 1208 LauncherItemClosed(item.id);
1210 } 1209 }
1211 } 1210 }
1211
1212 // 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.
1213 for (index = 0; index < model_->item_count(); index++) {
1214 ash::ShelfItem item = model_->items()[index];
1215 const bool pinned_by_policy = GetPinnableForAppID(item.app_id, profile()) ==
1216 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.
1217 if (item.pinned_by_policy != pinned_by_policy) {
1218 item.pinned_by_policy = pinned_by_policy;
1219 model_->Set(index, item);
1220 }
1221 }
1212 } 1222 }
1213 1223
1214 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() { 1224 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() {
1215 const PrefService* service = profile()->GetPrefs(); 1225 const PrefService* service = profile()->GetPrefs();
1216 const bool was_enabled = keyboard::IsKeyboardEnabled(); 1226 const bool was_enabled = keyboard::IsKeyboardEnabled();
1217 if (!service->HasPrefPath(prefs::kTouchVirtualKeyboardEnabled)) { 1227 if (!service->HasPrefPath(prefs::kTouchVirtualKeyboardEnabled)) {
1218 keyboard::SetKeyboardShowOverride(keyboard::KEYBOARD_SHOW_OVERRIDE_NONE); 1228 keyboard::SetKeyboardShowOverride(keyboard::KEYBOARD_SHOW_OVERRIDE_NONE);
1219 } else { 1229 } else {
1220 const bool enable = 1230 const bool enable =
1221 service->GetBoolean(prefs::kTouchVirtualKeyboardEnabled); 1231 service->GetBoolean(prefs::kTouchVirtualKeyboardEnabled);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 LauncherItemController* controller = GetLauncherItemController(item.id); 1468 LauncherItemController* controller = GetLauncherItemController(item.id);
1459 if (!controller || controller->image_set_by_controller()) 1469 if (!controller || controller->image_set_by_controller())
1460 continue; 1470 continue;
1461 item.image = image; 1471 item.image = image;
1462 if (arc_deferred_launcher_) 1472 if (arc_deferred_launcher_)
1463 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1473 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1464 model_->Set(index, item); 1474 model_->Set(index, item);
1465 // It's possible we're waiting on more than one item, so don't break. 1475 // It's possible we're waiting on more than one item, so don't break.
1466 } 1476 }
1467 } 1477 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698