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

Side by Side Diff: ash/common/shelf/shelf_view.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/common/shelf/shelf_view.h" 5 #include "ash/common/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/common/ash_constants.h" 10 #include "ash/common/ash_constants.h"
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 } 1344 }
1345 DestroyDragIconProxy(); 1345 DestroyDragIconProxy();
1346 } 1346 }
1347 1347
1348 ShelfView::RemovableState ShelfView::RemovableByRipOff(int index) const { 1348 ShelfView::RemovableState ShelfView::RemovableByRipOff(int index) const {
1349 DCHECK(index >= 0 && index < model_->item_count()); 1349 DCHECK(index >= 0 && index < model_->item_count());
1350 ShelfItemType type = model_->items()[index].type; 1350 ShelfItemType type = model_->items()[index].type;
1351 if (type == TYPE_APP_LIST || type == TYPE_DIALOG) 1351 if (type == TYPE_APP_LIST || type == TYPE_DIALOG)
1352 return NOT_REMOVABLE; 1352 return NOT_REMOVABLE;
1353 1353
1354 std::string app_id = delegate_->GetAppIDForShelfID(model_->items()[index].id); 1354 std::string app_id = delegate_->GetAppIDForShelfID(model_->items()[index].id);
James Cook 2017/01/04 17:32:17 nit: move this down near 1357
msw 2017/01/04 22:23:04 Done.
1355 ShelfItemDelegate* item_delegate = 1355 if (model_->items()[index].pinned_by_policy)
1356 model_->GetShelfItemDelegate(model_->items()[index].id);
1357 if (!item_delegate->CanPin())
1358 return NOT_REMOVABLE; 1356 return NOT_REMOVABLE;
1359 // Note: Only pinned app shortcuts can be removed! 1357 // Note: Only pinned app shortcuts can be removed!
1360 return (type == TYPE_APP_SHORTCUT && delegate_->IsAppPinned(app_id)) 1358 return (type == TYPE_APP_SHORTCUT && delegate_->IsAppPinned(app_id))
1361 ? REMOVABLE 1359 ? REMOVABLE
1362 : DRAGGABLE; 1360 : DRAGGABLE;
1363 } 1361 }
1364 1362
1365 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const { 1363 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const {
1366 switch (typea) { 1364 switch (typea) {
1367 case TYPE_APP_SHORTCUT: 1365 case TYPE_APP_SHORTCUT:
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 1879
1882 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1880 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1883 const gfx::Rect bounds = GetBoundsInScreen(); 1881 const gfx::Rect bounds = GetBoundsInScreen();
1884 int distance = wm_shelf_->SelectValueForShelfAlignment( 1882 int distance = wm_shelf_->SelectValueForShelfAlignment(
1885 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1883 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1886 bounds.x() - coordinate.x()); 1884 bounds.x() - coordinate.x());
1887 return distance > 0 ? distance : 0; 1885 return distance > 0 ? distance : 0;
1888 } 1886 }
1889 1887
1890 } // namespace ash 1888 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698