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

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

Issue 2917013002: mash: Move ShelfModel* to ash/public/cpp. (Closed)
Patch Set: Initialize the AppList item title in ShelfController. 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 21 matching lines...) Expand all
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.
52 ShelfItem item; 50 ShelfItem item;
53 item.type = TYPE_APP_LIST; 51 item.type = TYPE_APP_LIST;
54 item.id = ShelfID(kAppListId); 52 item.id = ShelfID(kAppListId);
James Cook 2017/06/02 18:22:16 nit: Leave a comment about who sets the title.
msw 2017/06/02 18:25:03 Done.
55 item.title = l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
56 const int index = Add(item); 53 const int index = Add(item);
57 DCHECK_EQ(0, index); 54 DCHECK_EQ(0, index);
58 } 55 }
59 56
60 ShelfModel::~ShelfModel() = default; 57 ShelfModel::~ShelfModel() = default;
61 58
62 void ShelfModel::PinAppWithID(const std::string& app_id) { 59 void ShelfModel::PinAppWithID(const std::string& app_id) {
63 const ShelfID shelf_id(app_id); 60 const ShelfID shelf_id(app_id);
64 61
65 // If the app is already pinned, do nothing and return. 62 // 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)); 252 static_cast<ShelfItems::difference_type>(index));
256 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, 253 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy,
257 CompareByWeight) - 254 CompareByWeight) -
258 items_.begin(), 255 items_.begin(),
259 static_cast<ShelfItems::difference_type>(index)); 256 static_cast<ShelfItems::difference_type>(index));
260 257
261 return index; 258 return index;
262 } 259 }
263 260
264 } // namespace ash 261 } // 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