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

Side by Side Diff: ash/launcher/launcher_model.cc

Issue 10905201: Move app list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review issues Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/launcher/launcher_model_unittest.cc » ('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 (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/launcher/launcher_model.h" 5 #include "ash/launcher/launcher_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/launcher/launcher_model_observer.h" 9 #include "ash/launcher/launcher_model_observer.h"
10 10
11 namespace ash { 11 namespace ash {
12 12
13 namespace { 13 namespace {
14 14
15 int LauncherItemTypeToWeight(LauncherItemType type) { 15 int LauncherItemTypeToWeight(LauncherItemType type) {
16 switch (type) { 16 switch (type) {
17 case TYPE_APP_LIST:
18 return 0;
17 case TYPE_BROWSER_SHORTCUT: 19 case TYPE_BROWSER_SHORTCUT:
18 return 0; 20 return 1;
19 case TYPE_APP_SHORTCUT: 21 case TYPE_APP_SHORTCUT:
20 return 1; 22 return 2;
21 case TYPE_TABBED: 23 case TYPE_TABBED:
22 case TYPE_APP_PANEL: 24 case TYPE_APP_PANEL:
23 case TYPE_PLATFORM_APP: 25 case TYPE_PLATFORM_APP:
24 return 2;
25 case TYPE_APP_LIST:
26 return 3; 26 return 3;
27 } 27 }
28 28
29 NOTREACHED() << "Invalid type " << type; 29 NOTREACHED() << "Invalid type " << type;
30 return 2; 30 return 2;
31 } 31 }
32 32
33 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { 33 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) {
34 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type); 34 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type);
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 LauncherModel::LauncherModel() : next_id_(1), status_(STATUS_NORMAL) { 39 LauncherModel::LauncherModel() : next_id_(1), status_(STATUS_NORMAL) {
40 LauncherItem app_list; 40 LauncherItem app_list;
41 app_list.type = TYPE_APP_LIST; 41 app_list.type = TYPE_APP_LIST;
42 app_list.is_incognito = false; 42 app_list.is_incognito = false;
43 43
44 LauncherItem browser_shortcut; 44 LauncherItem browser_shortcut;
45 browser_shortcut.type = TYPE_BROWSER_SHORTCUT; 45 browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
46 browser_shortcut.is_incognito = false; 46 browser_shortcut.is_incognito = false;
47 47
48 AddAt(0, browser_shortcut); 48 AddAt(0, app_list);
49 AddAt(1, app_list); 49 AddAt(1, browser_shortcut);
50 } 50 }
51 51
52 LauncherModel::~LauncherModel() { 52 LauncherModel::~LauncherModel() {
53 } 53 }
54 54
55 int LauncherModel::Add(const LauncherItem& item) { 55 int LauncherModel::Add(const LauncherItem& item) {
56 return AddAt(items_.size(), item); 56 return AddAt(items_.size(), item);
57 } 57 }
58 58
59 int LauncherModel::AddAt(int index, const LauncherItem& item) { 59 int LauncherModel::AddAt(int index, const LauncherItem& item) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 CompareByWeight) - items_.begin(), 145 CompareByWeight) - items_.begin(),
146 static_cast<LauncherItems::difference_type>(index)); 146 static_cast<LauncherItems::difference_type>(index));
147 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, 147 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy,
148 CompareByWeight) - items_.begin(), 148 CompareByWeight) - items_.begin(),
149 static_cast<LauncherItems::difference_type>(index)); 149 static_cast<LauncherItems::difference_type>(index));
150 150
151 return index; 151 return index;
152 } 152 }
153 153
154 } // namespace ash 154 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/launcher/launcher_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698