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

Side by Side Diff: ash/common/shelf/shelf_view.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 (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 if (model_->items()[index].pinned_by_policy)
1355 return NOT_REMOVABLE;
1356
1357 // Note: Only pinned app shortcuts can be removed!
1354 std::string app_id = delegate_->GetAppIDForShelfID(model_->items()[index].id); 1358 std::string app_id = delegate_->GetAppIDForShelfID(model_->items()[index].id);
1355 ShelfItemDelegate* item_delegate =
1356 model_->GetShelfItemDelegate(model_->items()[index].id);
1357 if (!item_delegate->CanPin())
1358 return NOT_REMOVABLE;
1359 // Note: Only pinned app shortcuts can be removed!
1360 return (type == TYPE_APP_SHORTCUT && delegate_->IsAppPinned(app_id)) 1359 return (type == TYPE_APP_SHORTCUT && delegate_->IsAppPinned(app_id))
1361 ? REMOVABLE 1360 ? REMOVABLE
1362 : DRAGGABLE; 1361 : DRAGGABLE;
1363 } 1362 }
1364 1363
1365 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const { 1364 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const {
1366 switch (typea) { 1365 switch (typea) {
1367 case TYPE_APP_SHORTCUT: 1366 case TYPE_APP_SHORTCUT:
1368 case TYPE_BROWSER_SHORTCUT: 1367 case TYPE_BROWSER_SHORTCUT:
1369 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT); 1368 return (typeb == TYPE_APP_SHORTCUT || typeb == TYPE_BROWSER_SHORTCUT);
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 1880
1882 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1881 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1883 const gfx::Rect bounds = GetBoundsInScreen(); 1882 const gfx::Rect bounds = GetBoundsInScreen();
1884 int distance = wm_shelf_->SelectValueForShelfAlignment( 1883 int distance = wm_shelf_->SelectValueForShelfAlignment(
1885 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1884 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1886 bounds.x() - coordinate.x()); 1885 bounds.x() - coordinate.x());
1887 return distance > 0 ? distance : 0; 1886 return distance > 0 ? distance : 0;
1888 } 1887 }
1889 1888
1890 } // namespace ash 1889 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_item_types.h ('k') | ash/common/shelf/shelf_window_watcher_item_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698