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

Side by Side Diff: chrome/browser/ui/app_list/extension_app_item.h

Issue 1507873006: Implement base class for app_list items. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits addressed Created 5 years 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
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 #ifndef CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_
6 #define CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" 11 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h"
12 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 12 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
13 #include "chrome/browser/ui/app_list/chrome_app_list_item.h"
13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" 14 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
14 #include "extensions/browser/extension_icon_image.h" 15 #include "extensions/browser/extension_icon_image.h"
15 #include "ui/app_list/app_list_item.h"
16 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
17 17
18 class AppListControllerDelegate; 18 class AppListControllerDelegate;
19 class ExtensionEnableFlow; 19 class ExtensionEnableFlow;
20 class Profile; 20 class Profile;
21 21
22 namespace app_list { 22 namespace app_list {
23 class AppContextMenu; 23 class AppContextMenu;
24 } 24 }
25 25
26 namespace extensions { 26 namespace extensions {
27 class ContextMenuMatcher; 27 class ContextMenuMatcher;
28 class Extension; 28 class Extension;
29 } 29 }
30 30
31 // ExtensionAppItem represents an extension app in app list. 31 // ExtensionAppItem represents an extension app in app list.
32 class ExtensionAppItem : public app_list::AppListItem, 32 class ExtensionAppItem : public ChromeAppListItem,
33 public extensions::IconImage::Observer, 33 public extensions::IconImage::Observer,
34 public ExtensionEnableFlowDelegate, 34 public ExtensionEnableFlowDelegate,
35 public app_list::AppContextMenuDelegate { 35 public app_list::AppContextMenuDelegate {
36 public: 36 public:
37 static const char kItemType[]; 37 static const char kItemType[];
38 38
39 ExtensionAppItem(Profile* profile, 39 ExtensionAppItem(Profile* profile,
40 const app_list::AppListSyncableService::SyncItem* sync_item, 40 const app_list::AppListSyncableService::SyncItem* sync_item,
41 const std::string& extension_id, 41 const std::string& extension_id,
42 const std::string& extension_name, 42 const std::string& extension_name,
43 const gfx::ImageSkia& installing_icon, 43 const gfx::ImageSkia& installing_icon,
44 bool is_platform_app); 44 bool is_platform_app);
45 ~ExtensionAppItem() override; 45 ~ExtensionAppItem() override;
46 46
47 // Reload the title and icon from the underlying extension. 47 // Reload the title and icon from the underlying extension.
48 void Reload(); 48 void Reload();
49 49
50 // Updates the app item's icon, if necessary adding an overlay and/or making 50 // Updates the app item's icon, if necessary adding an overlay and/or making
51 // it gray. 51 // it gray.
52 void UpdateIcon(); 52 void UpdateIcon();
53 53
54 // Update page and app launcher ordinals to put the app in between |prev| and 54 // Update page and app launcher ordinals to put the app in between |prev| and
55 // |next|. Note that |prev| and |next| could be NULL when the app is put at 55 // |next|. Note that |prev| and |next| could be NULL when the app is put at
56 // the beginning or at the end. 56 // the beginning or at the end.
57 void Move(const ExtensionAppItem* prev, const ExtensionAppItem* next); 57 void Move(const ExtensionAppItem* prev, const ExtensionAppItem* next);
58 58
59 const std::string& extension_id() const { return extension_id_; } 59 const std::string& extension_id() const { return id(); }
60 const std::string& extension_name() const { return extension_name_; } 60 const std::string& extension_name() const { return extension_name_; }
61 61
62 private: 62 private:
63 // Gets extension associated with this model. Returns NULL if extension 63 // Gets extension associated with this model. Returns NULL if extension
64 // no longer exists. 64 // no longer exists.
65 const extensions::Extension* GetExtension() const; 65 const extensions::Extension* GetExtension() const;
66 66
67 // Loads extension icon. 67 // Loads extension icon.
68 void LoadImage(const extensions::Extension* extension); 68 void LoadImage(const extensions::Extension* extension);
69 69
(...skipping 18 matching lines...) Expand all
88 // Overridden from AppListItem: 88 // Overridden from AppListItem:
89 void Activate(int event_flags) override; 89 void Activate(int event_flags) override;
90 ui::MenuModel* GetContextMenuModel() override; 90 ui::MenuModel* GetContextMenuModel() override;
91 // Updates the icon if the overlay needs to be added/removed. 91 // Updates the icon if the overlay needs to be added/removed.
92 void OnExtensionPreferenceChanged() override; 92 void OnExtensionPreferenceChanged() override;
93 const char* GetItemType() const override; 93 const char* GetItemType() const override;
94 94
95 // Overridden from app_list::AppContextMenuDelegate: 95 // Overridden from app_list::AppContextMenuDelegate:
96 void ExecuteLaunchCommand(int event_flags) override; 96 void ExecuteLaunchCommand(int event_flags) override;
97 97
98 // Set the position from the extension ordering. 98 // Set the position from the ordering.
99 void UpdatePositionFromExtensionOrdering(); 99 void UpdatePositionFromOrdering();
100
101 // Return the controller for the active desktop type.
102 AppListControllerDelegate* GetController();
103
104 Profile* profile_;
105 const std::string extension_id_;
106 100
107 scoped_ptr<extensions::IconImage> icon_; 101 scoped_ptr<extensions::IconImage> icon_;
108 scoped_ptr<app_list::AppContextMenu> context_menu_; 102 scoped_ptr<app_list::AppContextMenu> context_menu_;
109 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; 103 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
110 AppListControllerDelegate* extension_enable_flow_controller_; 104 AppListControllerDelegate* extension_enable_flow_controller_;
111 105
112 // Name to use for the extension if we can't access it. 106 // Name to use for the extension if we can't access it.
113 std::string extension_name_; 107 std::string extension_name_;
114 108
115 // Icon for the extension if we can't access the installed extension. 109 // Icon for the extension if we can't access the installed extension.
116 gfx::ImageSkia installing_icon_; 110 gfx::ImageSkia installing_icon_;
117 111
118 // Whether or not this app is a platform app. 112 // Whether or not this app is a platform app.
119 bool is_platform_app_; 113 bool is_platform_app_;
120 114
121 // Whether this app item has an overlay. 115 // Whether this app item has an overlay.
122 bool has_overlay_; 116 bool has_overlay_;
123 117
124 DISALLOW_COPY_AND_ASSIGN(ExtensionAppItem); 118 DISALLOW_COPY_AND_ASSIGN(ExtensionAppItem);
125 }; 119 };
126 120
127 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ 121 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/chrome_app_list_item.cc ('k') | chrome/browser/ui/app_list/extension_app_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698