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

Side by Side Diff: ash/shell/app_list.cc

Issue 148403007: Protect AppListItemList Add/Remove and fix sync bugs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 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
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 <string> 5 #include <string>
6 6
7 #include "ash/session_state_delegate.h" 7 #include "ash/session_state_delegate.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell/example_factory.h" 9 #include "ash/shell/example_factory.h"
10 #include "ash/shell/toplevel_window.h" 10 #include "ash/shell/toplevel_window.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 private: 191 private:
192 WindowTypeLauncherItem::Type type_; 192 WindowTypeLauncherItem::Type type_;
193 193
194 DISALLOW_COPY_AND_ASSIGN(ExampleSearchResult); 194 DISALLOW_COPY_AND_ASSIGN(ExampleSearchResult);
195 }; 195 };
196 196
197 class ExampleAppListViewDelegate : public app_list::AppListViewDelegate { 197 class ExampleAppListViewDelegate : public app_list::AppListViewDelegate {
198 public: 198 public:
199 ExampleAppListViewDelegate() 199 ExampleAppListViewDelegate()
200 : model_(new app_list::AppListModel) { 200 : model_(new app_list::AppListModel) {
201 PopulateApps(model_->item_list()); 201 PopulateApps();
202 DecorateSearchBox(model_->search_box()); 202 DecorateSearchBox(model_->search_box());
203 } 203 }
204 204
205 private: 205 private:
206 void PopulateApps(app_list::AppListItemList* item_list) { 206 void PopulateApps() {
207 for (int i = 0; 207 for (int i = 0;
208 i < static_cast<int>(WindowTypeLauncherItem::LAST_TYPE); 208 i < static_cast<int>(WindowTypeLauncherItem::LAST_TYPE);
209 ++i) { 209 ++i) {
210 WindowTypeLauncherItem::Type type = 210 WindowTypeLauncherItem::Type type =
211 static_cast<WindowTypeLauncherItem::Type>(i); 211 static_cast<WindowTypeLauncherItem::Type>(i);
212 std::string id = base::StringPrintf("%d", i); 212 std::string id = base::StringPrintf("%d", i);
213 item_list->AddItem(new WindowTypeLauncherItem(id, type)); 213 model_->AddItem(new WindowTypeLauncherItem(id, type));
214 } 214 }
215 } 215 }
216 216
217 gfx::ImageSkia CreateSearchBoxIcon() { 217 gfx::ImageSkia CreateSearchBoxIcon() {
218 const base::string16 icon_text = base::ASCIIToUTF16("ash"); 218 const base::string16 icon_text = base::ASCIIToUTF16("ash");
219 const gfx::Size icon_size(32, 32); 219 const gfx::Size icon_size(32, 32);
220 220
221 gfx::Canvas canvas(icon_size, 1.0f, false /* is_opaque */); 221 gfx::Canvas canvas(icon_size, 1.0f, false /* is_opaque */);
222 canvas.DrawStringInt(icon_text, 222 canvas.DrawStringInt(icon_text,
223 gfx::Font(), 223 gfx::Font(),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 }; 366 };
367 367
368 } // namespace 368 } // namespace
369 369
370 app_list::AppListViewDelegate* CreateAppListViewDelegate() { 370 app_list::AppListViewDelegate* CreateAppListViewDelegate() {
371 return new ExampleAppListViewDelegate; 371 return new ExampleAppListViewDelegate;
372 } 372 }
373 373
374 } // namespace shell 374 } // namespace shell
375 } // namespace ash 375 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698