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

Side by Side Diff: ui/app_list/app_list_item.h

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 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 #ifndef UI_APP_LIST_APP_LIST_ITEM_H_ 5 #ifndef UI_APP_LIST_APP_LIST_ITEM_H_
6 #define UI_APP_LIST_APP_LIST_ITEM_H_ 6 #define UI_APP_LIST_APP_LIST_ITEM_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "sync/api/string_ordinal.h" 12 #include "sync/api/string_ordinal.h"
13 #include "ui/app_list/app_list_export.h" 13 #include "ui/app_list/app_list_export.h"
14 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
15 15
16 namespace ui { 16 namespace ui {
17 class MenuModel; 17 class MenuModel;
18 } 18 }
19 19
20 namespace app_list { 20 namespace app_list {
21 21
22 class AppListItemList; 22 class AppListItemList;
23 class AppListItemListTest; 23 class AppListItemListTest;
24 class AppListItemObserver; 24 class AppListItemObserver;
25 class AppListModel;
25 26
26 // AppListItem provides icon and title to be shown in a AppListItemView 27 // AppListItem provides icon and title to be shown in a AppListItemView
27 // and action to be executed when the AppListItemView is activated. 28 // and action to be executed when the AppListItemView is activated.
28 class APP_LIST_EXPORT AppListItem { 29 class APP_LIST_EXPORT AppListItem {
29 public: 30 public:
30 explicit AppListItem(const std::string& id); 31 explicit AppListItem(const std::string& id);
31 virtual ~AppListItem(); 32 virtual ~AppListItem();
32 33
33 void SetIcon(const gfx::ImageSkia& icon, bool has_shadow); 34 void SetIcon(const gfx::ImageSkia& icon, bool has_shadow);
34 const gfx::ImageSkia& icon() const { return icon_; } 35 const gfx::ImageSkia& icon() const { return icon_; }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Note the returned menu model is owned by this item. 67 // Note the returned menu model is owned by this item.
67 virtual ui::MenuModel* GetContextMenuModel(); 68 virtual ui::MenuModel* GetContextMenuModel();
68 69
69 // Utility functions for sync integration tests. 70 // Utility functions for sync integration tests.
70 virtual bool CompareForTest(const AppListItem* other) const; 71 virtual bool CompareForTest(const AppListItem* other) const;
71 virtual std::string ToDebugString() const; 72 virtual std::string ToDebugString() const;
72 73
73 protected: 74 protected:
74 friend class AppListItemList; 75 friend class AppListItemList;
75 friend class AppListItemListTest; 76 friend class AppListItemListTest;
77 friend class AppListModel;
76 78
77 void set_position(const syncer::StringOrdinal& new_position) { 79 void set_position(const syncer::StringOrdinal& new_position) {
78 DCHECK(new_position.IsValid()); 80 DCHECK(new_position.IsValid());
79 position_ = new_position; 81 position_ = new_position;
80 } 82 }
81 83
82 private: 84 private:
83 friend class AppListModelTest; 85 friend class AppListModelTest;
84 86
85 const std::string id_; 87 const std::string id_;
86 syncer::StringOrdinal position_; 88 syncer::StringOrdinal position_;
87 gfx::ImageSkia icon_; 89 gfx::ImageSkia icon_;
88 bool has_shadow_; 90 bool has_shadow_;
89 std::string title_; 91 std::string title_;
90 std::string full_name_; 92 std::string full_name_;
91 bool highlighted_; 93 bool highlighted_;
92 bool is_installing_; 94 bool is_installing_;
93 int percent_downloaded_; 95 int percent_downloaded_;
94 96
95 ObserverList<AppListItemObserver> observers_; 97 ObserverList<AppListItemObserver> observers_;
96 98
97 DISALLOW_COPY_AND_ASSIGN(AppListItem); 99 DISALLOW_COPY_AND_ASSIGN(AppListItem);
98 }; 100 };
99 101
100 } // namespace app_list 102 } // namespace app_list
101 103
102 #endif // UI_APP_LIST_APP_LIST_ITEM_H_ 104 #endif // UI_APP_LIST_APP_LIST_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698