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

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

Issue 25859005: Elim ActivateAppListItem, ChromeAppListItem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix static cast in AppModelBuilder, add AppType Created 7 years, 2 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 #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/extensions/extension_icon_image.h" 11 #include "chrome/browser/extensions/extension_icon_image.h"
12 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h" 12 #include "chrome/browser/ui/app_list/app_context_menu_delegate.h"
13 #include "chrome/browser/ui/app_list/chrome_app_list_item.h"
14 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" 13 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
15 #include "sync/api/string_ordinal.h" 14 #include "sync/api/string_ordinal.h"
15 #include "ui/app_list/app_list_item_model.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 ChromeAppListItem, 32 class ExtensionAppItem : public app_list::AppListItemModel,
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 ExtensionAppItem(Profile* profile, 37 ExtensionAppItem(Profile* profile,
38 const std::string& extension_id, 38 const std::string& extension_id,
39 AppListControllerDelegate* controller, 39 AppListControllerDelegate* controller,
40 const std::string& extension_name, 40 const std::string& extension_name,
41 const gfx::ImageSkia& installing_icon, 41 const gfx::ImageSkia& installing_icon,
42 bool is_platform_app); 42 bool is_platform_app);
43 virtual ~ExtensionAppItem(); 43 virtual ~ExtensionAppItem();
44 44
45 // Reload the title and icon from the underlying extension.
46 void Reload();
47
48 syncer::StringOrdinal GetPageOrdinal() const; 45 syncer::StringOrdinal GetPageOrdinal() const;
49 syncer::StringOrdinal GetAppLaunchOrdinal() const; 46 syncer::StringOrdinal GetAppLaunchOrdinal() const;
50 47
51 // Update page and app launcher ordinals to put the app in between |prev| and 48 // Update page and app launcher ordinals to put the app in between |prev| and
52 // |next|. Note that |prev| and |next| could be NULL when the app is put at 49 // |next|. Note that |prev| and |next| could be NULL when the app is put at
53 // the beginning or at the end. 50 // the beginning or at the end.
54 void Move(const ExtensionAppItem* prev, const ExtensionAppItem* next); 51 void Move(const ExtensionAppItem* prev, const ExtensionAppItem* next);
55 52
56 // Updates the app item's icon, if necessary adding an overlay and/or making 53 // Updates the app item's icon, if necessary adding an overlay and/or making
57 // it gray. 54 // it gray.
58 void UpdateIcon(); 55 void UpdateIcon();
59 56
60 const std::string& extension_id() const { return extension_id_; } 57 const std::string& extension_id() const { return extension_id_; }
61 58
59 static std::string ExtensionAppType();
60
62 private: 61 private:
63 // Gets extension associated with this model. Returns NULL if extension 62 // Gets extension associated with this model. Returns NULL if extension
64 // no longer exists. 63 // no longer exists.
65 const extensions::Extension* GetExtension() const; 64 const extensions::Extension* GetExtension() const;
66 65
67 // Loads extension icon. 66 // Loads extension icon.
68 void LoadImage(const extensions::Extension* extension); 67 void LoadImage(const extensions::Extension* extension);
69 68
70 // Checks if extension is disabled and if enable flow should be started. 69 // Checks if extension is disabled and if enable flow should be started.
71 // Returns true if extension enable flow is started or there is already one 70 // Returns true if extension enable flow is started or there is already one
72 // running. 71 // running.
73 bool RunExtensionEnableFlow(); 72 bool RunExtensionEnableFlow();
74 73
75 // Private equivalent to Activate(), without refocus for already-running apps. 74 // Private equivalent to Activate(), without refocus for already-running apps.
76 void Launch(int event_flags); 75 void Launch(int event_flags);
77 76
78 // Whether or not the app item has an overlay. 77 // Whether or not the app item has an overlay.
79 bool HasOverlay() const; 78 bool HasOverlay() const;
80 79
81 // Overridden from extensions::IconImage::Observer: 80 // Overridden from extensions::IconImage::Observer:
82 virtual void OnExtensionIconImageChanged( 81 virtual void OnExtensionIconImageChanged(
83 extensions::IconImage* image) OVERRIDE; 82 extensions::IconImage* image) OVERRIDE;
84 83
85 // Overridden from ExtensionEnableFlowDelegate: 84 // Overridden from ExtensionEnableFlowDelegate:
86 virtual void ExtensionEnableFlowFinished() OVERRIDE; 85 virtual void ExtensionEnableFlowFinished() OVERRIDE;
87 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE; 86 virtual void ExtensionEnableFlowAborted(bool user_initiated) OVERRIDE;
88 87
89 // Overridden from ChromeAppListItem: 88 // Overridden from AppListItemModel:
89 virtual std::string AppType() const OVERRIDE;
90 virtual void Activate(int event_flags) OVERRIDE; 90 virtual void Activate(int event_flags) OVERRIDE;
91 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE; 91 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE;
92 virtual void Update() OVERRIDE;
92 93
93 // Overridden from app_list::AppContextMenuDelegate: 94 // Overridden from app_list::AppContextMenuDelegate:
94 virtual void ExecuteLaunchCommand(int event_flags) OVERRIDE; 95 virtual void ExecuteLaunchCommand(int event_flags) OVERRIDE;
95 96
96 Profile* profile_; 97 Profile* profile_;
97 const std::string extension_id_; 98 const std::string extension_id_;
98 AppListControllerDelegate* controller_; 99 AppListControllerDelegate* controller_;
99 100
100 scoped_ptr<extensions::IconImage> icon_; 101 scoped_ptr<extensions::IconImage> icon_;
101 scoped_ptr<app_list::AppContextMenu> context_menu_; 102 scoped_ptr<app_list::AppContextMenu> context_menu_;
102 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_; 103 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
103 104
104 // Name to use for the extension if we can't access it. 105 // Name to use for the extension if we can't access it.
105 std::string extension_name_; 106 std::string extension_name_;
106 107
107 // Icon for the extension if we can't access the installed extension. 108 // Icon for the extension if we can't access the installed extension.
108 gfx::ImageSkia installing_icon_; 109 gfx::ImageSkia installing_icon_;
109 110
110 // Whether or not this app is a platform app. 111 // Whether or not this app is a platform app.
111 bool is_platform_app_; 112 bool is_platform_app_;
112 113
113 DISALLOW_COPY_AND_ASSIGN(ExtensionAppItem); 114 DISALLOW_COPY_AND_ASSIGN(ExtensionAppItem);
114 }; 115 };
115 116
116 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_ 117 #endif // CHROME_BROWSER_UI_APP_LIST_EXTENSION_APP_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698