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

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: Fix test. 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 void ChromeLauncherControllerImpl::TogglePinned(ash::ShelfID id) { 390 void ChromeLauncherControllerImpl::TogglePinned(ash::ShelfID id) {
391 if (!HasShelfIDToAppIDMapping(id)) 391 if (!HasShelfIDToAppIDMapping(id))
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 {
401 const ash::ShelfItem* item = GetItem(id);
402 return (item && (item->type == ash::TYPE_APP_SHORTCUT ||
403 item->type == ash::TYPE_APP) &&
404 model_->GetShelfItemDelegate(id)->CanPin());
405 }
406
407 void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) { 400 void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) {
408 ash::ShelfID id = GetShelfIDForAppID(app_id); 401 ash::ShelfID id = GetShelfIDForAppID(app_id);
409 if (id == ash::kInvalidShelfID) { 402 if (id == ash::kInvalidShelfID) {
410 CreateAppShortcutLauncherItemWithType(ash::launcher::AppLauncherId(app_id), 403 CreateAppShortcutLauncherItemWithType(ash::launcher::AppLauncherId(app_id),
411 model_->item_count(), ash::TYPE_APP); 404 model_->item_count(), ash::TYPE_APP);
412 id = GetShelfIDForAppID(app_id); 405 id = GetShelfIDForAppID(app_id);
413 } 406 }
414 CHECK(id); 407 CHECK(id);
415 GetLauncherItemController(id)->lock(); 408 GetLauncherItemController(id)->lock();
416 } 409 }
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 DCHECK_NE(controller->app_id(), extension_misc::kChromeAppId); 1195 DCHECK_NE(controller->app_id(), extension_misc::kChromeAppId);
1203 1196
1204 if (item.status != ash::STATUS_CLOSED || controller->locked()) { 1197 if (item.status != ash::STATUS_CLOSED || controller->locked()) {
1205 UnpinRunningAppInternal(index); 1198 UnpinRunningAppInternal(index);
1206 // Note, item can be moved to the right due weighting in shelf model. 1199 // Note, item can be moved to the right due weighting in shelf model.
1207 DCHECK_GE(model_->ItemIndexByID(item.id), index); 1200 DCHECK_GE(model_->ItemIndexByID(item.id), index);
1208 } else { 1201 } else {
1209 LauncherItemClosed(item.id); 1202 LauncherItemClosed(item.id);
1210 } 1203 }
1211 } 1204 }
1205
1206 UpdatePolicyPinnedAppsFromPrefs();
1207 }
1208
1209 void ChromeLauncherControllerImpl::UpdatePolicyPinnedAppsFromPrefs() {
1210 for (int index = 0; index < model_->item_count(); index++) {
1211 ash::ShelfItem item = model_->items()[index];
1212 const bool pinned_by_policy = GetPinnableForAppID(item.app_id, profile()) ==
1213 AppListControllerDelegate::PIN_FIXED;
1214 if (item.pinned_by_policy != pinned_by_policy) {
1215 item.pinned_by_policy = pinned_by_policy;
1216 model_->Set(index, item);
1217 }
1218 }
1212 } 1219 }
1213 1220
1214 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() { 1221 void ChromeLauncherControllerImpl::SetVirtualKeyboardBehaviorFromPrefs() {
1215 const PrefService* service = profile()->GetPrefs(); 1222 const PrefService* service = profile()->GetPrefs();
1216 const bool was_enabled = keyboard::IsKeyboardEnabled(); 1223 const bool was_enabled = keyboard::IsKeyboardEnabled();
1217 if (!service->HasPrefPath(prefs::kTouchVirtualKeyboardEnabled)) { 1224 if (!service->HasPrefPath(prefs::kTouchVirtualKeyboardEnabled)) {
1218 keyboard::SetKeyboardShowOverride(keyboard::KEYBOARD_SHOW_OVERRIDE_NONE); 1225 keyboard::SetKeyboardShowOverride(keyboard::KEYBOARD_SHOW_OVERRIDE_NONE);
1219 } else { 1226 } else {
1220 const bool enable = 1227 const bool enable =
1221 service->GetBoolean(prefs::kTouchVirtualKeyboardEnabled); 1228 service->GetBoolean(prefs::kTouchVirtualKeyboardEnabled);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 LauncherItemController* controller = GetLauncherItemController(item.id); 1465 LauncherItemController* controller = GetLauncherItemController(item.id);
1459 if (!controller || controller->image_set_by_controller()) 1466 if (!controller || controller->image_set_by_controller())
1460 continue; 1467 continue;
1461 item.image = image; 1468 item.image = image;
1462 if (arc_deferred_launcher_) 1469 if (arc_deferred_launcher_)
1463 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1470 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1464 model_->Set(index, item); 1471 model_->Set(index, item);
1465 // It's possible we're waiting on more than one item, so don't break. 1472 // It's possible we're waiting on more than one item, so don't break.
1466 } 1473 }
1467 } 1474 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698