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

Side by Side Diff: ash/public/cpp/shelf_model.cc

Issue 2917013002: mash: Move ShelfModel* to ash/public/cpp. (Closed)
Patch Set: Comment on AppList item init. Created 3 years, 6 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
« no previous file with comments | « ash/public/cpp/shelf_model.h ('k') | ash/public/cpp/shelf_model_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/shelf/shelf_model.h" 5 #include "ash/public/cpp/shelf_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/public/cpp/shelf_item_delegate.h" 9 #include "ash/public/cpp/shelf_item_delegate.h"
10 #include "ash/shelf/shelf_model_observer.h" 10 #include "ash/public/cpp/shelf_model_observer.h"
11 #include "ash/strings/grit/ash_strings.h"
12 #include "ui/base/l10n/l10n_util.h"
13 11
14 namespace ash { 12 namespace ash {
15 13
16 namespace { 14 namespace {
17 15
18 int ShelfItemTypeToWeight(ShelfItemType type) { 16 int ShelfItemTypeToWeight(ShelfItemType type) {
19 switch (type) { 17 switch (type) {
20 case TYPE_APP_LIST: 18 case TYPE_APP_LIST:
21 // TODO(skuhne): If the app list item becomes movable again, this need 19 // TODO(skuhne): If the app list item becomes movable again, this need
22 // to be a fallthrough. 20 // to be a fallthrough.
(...skipping 18 matching lines...) Expand all
41 39
42 bool CompareByWeight(const ShelfItem& a, const ShelfItem& b) { 40 bool CompareByWeight(const ShelfItem& a, const ShelfItem& b) {
43 return ShelfItemTypeToWeight(a.type) < ShelfItemTypeToWeight(b.type); 41 return ShelfItemTypeToWeight(a.type) < ShelfItemTypeToWeight(b.type);
44 } 42 }
45 43
46 } // namespace 44 } // namespace
47 45
48 const char kAppListId[] = "jlfapfmkapbjlfbpjedlinehodkccjee"; 46 const char kAppListId[] = "jlfapfmkapbjlfbpjedlinehodkccjee";
49 47
50 ShelfModel::ShelfModel() { 48 ShelfModel::ShelfModel() {
51 // Add the app list item. 49 // Add the app list item; its title and delegate are set in ShelfController.
50 // This avoids an ash/public dep on ash/strings, and a Chrome-side delegate.
52 ShelfItem item; 51 ShelfItem item;
53 item.type = TYPE_APP_LIST; 52 item.type = TYPE_APP_LIST;
54 item.id = ShelfID(kAppListId); 53 item.id = ShelfID(kAppListId);
55 item.title = l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
56 const int index = Add(item); 54 const int index = Add(item);
57 DCHECK_EQ(0, index); 55 DCHECK_EQ(0, index);
58 } 56 }
59 57
60 ShelfModel::~ShelfModel() = default; 58 ShelfModel::~ShelfModel() = default;
61 59
62 void ShelfModel::PinAppWithID(const std::string& app_id) { 60 void ShelfModel::PinAppWithID(const std::string& app_id) {
63 const ShelfID shelf_id(app_id); 61 const ShelfID shelf_id(app_id);
64 62
65 // If the app is already pinned, do nothing and return. 63 // If the app is already pinned, do nothing and return.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 static_cast<ShelfItems::difference_type>(index)); 253 static_cast<ShelfItems::difference_type>(index));
256 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, 254 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy,
257 CompareByWeight) - 255 CompareByWeight) -
258 items_.begin(), 256 items_.begin(),
259 static_cast<ShelfItems::difference_type>(index)); 257 static_cast<ShelfItems::difference_type>(index));
260 258
261 return index; 259 return index;
262 } 260 }
263 261
264 } // namespace ash 262 } // namespace ash
OLDNEW
« no previous file with comments | « ash/public/cpp/shelf_model.h ('k') | ash/public/cpp/shelf_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698