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

Side by Side Diff: athena/home/app_list_view_delegate.cc

Issue 306083005: Replace the HomeCard by the AppList in Athena. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for focus_controller Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "athena/home/app_list_view_delegate.h"
6
7 #include <string>
8
9 #include "base/basictypes.h"
10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 #include "base/strings/utf_string_conversions.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/app_list/app_list_item.h"
15 #include "ui/app_list/app_list_item_list.h"
16 #include "ui/app_list/app_list_model.h"
17 #include "ui/app_list/search_box_model.h"
18 #include "ui/app_list/search_result.h"
19 #include "ui/app_list/speech_ui_model.h"
20 #include "ui/gfx/image/image_skia.h"
21
22 namespace athena {
23
24 namespace {
25
26 const int kIconSize = 64;
27
28 class DummyItem : public app_list::AppListItem {
29 public:
30 enum Type {
31 DUMMY_MAIL,
32 DUMMY_CALENDAR,
33 DUMMY_VIDEO,
34 DUMMY_MUSIC,
35 DUMMY_CONTACT,
36 LAST_TYPE,
37 };
38
39 static std::string GetTitle(Type type) {
40 switch (type) {
41 case DUMMY_MAIL:
42 return "mail";
43 case DUMMY_CALENDAR:
44 return "calendar";
45 case DUMMY_VIDEO:
46 return "video";
47 case DUMMY_MUSIC:
48 return "music";
49 case DUMMY_CONTACT:
50 return "contact";
51 case LAST_TYPE:
52 break;
53 }
54 NOTREACHED();
55 return "";
56 }
57
58 static std::string GetId(Type type) {
59 return std::string("id-") + GetTitle(type);
60 }
61
62 explicit DummyItem(Type type)
63 : app_list::AppListItem(GetId(type)),
64 type_(type) {
65 SetIcon(GetIcon(), false /* has_shadow */);
66 SetName(GetTitle(type_));
67 }
68
69 private:
70 gfx::ImageSkia GetIcon() const {
71 SkColor color = SK_ColorWHITE;
72 switch (type_) {
73 case DUMMY_MAIL:
74 color = SK_ColorRED;
75 break;
76 case DUMMY_CALENDAR:
77 color = SK_ColorBLUE;
78 break;
79 case DUMMY_VIDEO:
80 color = SK_ColorGREEN;
81 break;
82 case DUMMY_MUSIC:
83 color = SK_ColorYELLOW;
84 break;
85 case DUMMY_CONTACT:
86 color = SK_ColorCYAN;
87 break;
88 case LAST_TYPE:
89 NOTREACHED();
90 break;
91 }
92 SkBitmap bitmap;
93 bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize);
94 bitmap.allocPixels();
95 bitmap.eraseColor(color);
96 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
97 }
98
99 Type type_;
100
101 DISALLOW_COPY_AND_ASSIGN(DummyItem);
102 };
103
104 } // namespace
105
106 AppListViewDelegate::AppListViewDelegate()
107 : model_(new app_list::AppListModel),
108 speech_ui_(new app_list::SpeechUIModel(
109 app_list::SPEECH_RECOGNITION_OFF)) {
110 PopulateApps();
111 // TODO(mukai): get the text from the resources.
112 model_->search_box()->SetHintText(base::ASCIIToUTF16("Search"));
113 }
114
115 AppListViewDelegate::~AppListViewDelegate() {
116 }
117
118 void AppListViewDelegate::PopulateApps() {
119 for (int i = 0; i < static_cast<int>(DummyItem::LAST_TYPE); ++i) {
120 model_->AddItem(scoped_ptr<app_list::AppListItem>(
121 new DummyItem(static_cast<DummyItem::Type>(i))));
122 }
123 }
124
125 bool AppListViewDelegate::ForceNativeDesktop() const {
126 return false;
127 }
128
129 void AppListViewDelegate::SetProfileByPath(const base::FilePath& profile_path) {
130 // Nothing needs to be done.
131 }
132
133 app_list::AppListModel* AppListViewDelegate::GetModel() {
134 return model_.get();
135 }
136
137 app_list::SigninDelegate* AppListViewDelegate::GetSigninDelegate() {
138 return NULL;
139 }
140
141 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() {
142 return speech_ui_.get();
143 }
144
145 void AppListViewDelegate::GetShortcutPathForApp(
146 const std::string& app_id,
147 const base::Callback<void(const base::FilePath&)>& callback) {
148 // Windows only, nothing is necessary.
149 }
150
151 void AppListViewDelegate::StartSearch() {
152 // TODO(mukai): implement this.
153 }
154
155 void AppListViewDelegate::StopSearch() {
156 // TODO(mukai): implement this.
157 }
158
159 void AppListViewDelegate::OpenSearchResult(app_list::SearchResult* result,
160 bool auto_launch,
161 int event_flags) {
162 // TODO(mukai): implement this.
163 }
164
165 void AppListViewDelegate::InvokeSearchResultAction(
166 app_list::SearchResult* result,
167 int action_index,
168 int event_flags) {
169 // TODO(mukai): implement this.
170 }
171
172 base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() {
173 // Used by voice search, nothing needs to be done for now.
174 return base::TimeDelta();
175 }
176
177 void AppListViewDelegate::AutoLaunchCanceled() {
178 // Used by voice search, nothing needs to be done for now.
179 }
180
181 void AppListViewDelegate::ViewInitialized() {
182 // Nothing needs to be done.
183 }
184
185 void AppListViewDelegate::Dismiss() {
186 // Nothing needs to be done.
187 }
188
189 void AppListViewDelegate::ViewClosing() {
190 // Nothing needs to be done.
191 }
192
193 gfx::ImageSkia AppListViewDelegate::GetWindowIcon() {
194 return gfx::ImageSkia();
195 }
196
197 void AppListViewDelegate::OpenSettings() {
198 // Nothing needs to be done for now.
199 // TODO(mukai): should invoke the settings app.
200 }
201
202 void AppListViewDelegate::OpenHelp() {
203 // Nothing needs to be done for now.
204 // TODO(mukai): should invoke the help app.
205 }
206
207 void AppListViewDelegate::OpenFeedback() {
208 // Nothing needs to be done for now.
209 // TODO(mukai): should invoke the feedback app.
210 }
211
212 void AppListViewDelegate::ToggleSpeechRecognition() {
213 // Nothing needs to be done.
214 }
215
216 void AppListViewDelegate::ShowForProfileByPath(
217 const base::FilePath& profile_path) {
218 // Nothing needs to be done.
219 }
220
221 content::WebContents* AppListViewDelegate::GetStartPageContents() {
222 return NULL;
223 }
224
225 content::WebContents* AppListViewDelegate::GetSpeechRecognitionContents() {
226 return NULL;
227 }
228
229 const app_list::AppListViewDelegate::Users&
230 AppListViewDelegate::GetUsers() const {
231 return users_;
232 }
233
234 bool AppListViewDelegate::ShouldCenterWindow() const {
235 return true;
236 }
237
238 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698