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

Side by Side Diff: chrome/browser/ui/app_list/search/extension_app_result.h

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: Devlin's comments Created 3 years, 7 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
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 CHROME_BROWSER_UI_APP_LIST_SEARCH_EXTENSION_APP_RESULT_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_EXTENSION_APP_RESULT_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_EXTENSION_APP_RESULT_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_EXTENSION_APP_RESULT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/extensions/extension_app_icon_delegate.h"
12 #include "chrome/browser/ui/app_list/search/app_result.h" 13 #include "chrome/browser/ui/app_list/search/app_result.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 "extensions/browser/extension_registry_observer.h" 16 #include "extensions/browser/extension_registry_observer.h"
16 17
17 class AppListControllerDelegate; 18 class AppListControllerDelegate;
18 class ExtensionEnableFlow; 19 class ExtensionEnableFlow;
19 class Profile; 20 class Profile;
20 21
21 namespace extensions { 22 namespace extensions {
22 class ExtensionRegistry; 23 class ExtensionRegistry;
23 } 24 }
24 25
25 namespace app_list { 26 namespace app_list {
26 27
27 class ExtensionAppContextMenu; 28 class ExtensionAppContextMenu;
28 29
29 class ExtensionAppResult : public AppResult, 30 class ExtensionAppResult : public AppResult,
30 public extensions::IconImage::Observer, 31 public extensions::ExtensionAppIconDelegate,
31 public ExtensionEnableFlowDelegate, 32 public ExtensionEnableFlowDelegate,
32 public extensions::ExtensionRegistryObserver { 33 public extensions::ExtensionRegistryObserver {
33 public: 34 public:
34 ExtensionAppResult(Profile* profile, 35 ExtensionAppResult(Profile* profile,
35 const std::string& app_id, 36 const std::string& app_id,
36 AppListControllerDelegate* controller, 37 AppListControllerDelegate* controller,
37 bool is_recommendation); 38 bool is_recommendation);
38 ~ExtensionAppResult() override; 39 ~ExtensionAppResult() override;
39 40
40 // SearchResult overrides: 41 // SearchResult overrides:
41 void Open(int event_flags) override; 42 void Open(int event_flags) override;
42 std::unique_ptr<SearchResult> Duplicate() const override; 43 std::unique_ptr<SearchResult> Duplicate() const override;
43 ui::MenuModel* GetContextMenuModel() override; 44 ui::MenuModel* GetContextMenuModel() override;
44 45
45 private: 46 private:
46 void StartObservingExtensionRegistry(); 47 void StartObservingExtensionRegistry();
47 void StopObservingExtensionRegistry(); 48 void StopObservingExtensionRegistry();
48 49
49 // Checks if extension is disabled and if enable flow should be started. 50 // Checks if extension is disabled and if enable flow should be started.
50 // Returns true if extension enable flow is started or there is already one 51 // Returns true if extension enable flow is started or there is already one
51 // running. 52 // running.
52 bool RunExtensionEnableFlow(); 53 bool RunExtensionEnableFlow();
53 54
54 // Creates new icon in case icon does not exist or previous icon was
55 // invalidated.
56 void CreateOrUpdateIcon();
57
58 // Updates the app item's icon, if necessary making it gray.
59 void UpdateIcon();
60
61 // extensions::IconImage::Observer overrides:
62 void OnExtensionIconImageChanged(extensions::IconImage* image) override;
63 void OnExtensionIconImageDestroyed(extensions::IconImage* image) override;
64
65 // AppContextMenuDelegate overrides: 55 // AppContextMenuDelegate overrides:
66 void ExecuteLaunchCommand(int event_flags) override; 56 void ExecuteLaunchCommand(int event_flags) override;
67 57
68 // ExtensionEnableFlowDelegate overrides: 58 // ExtensionEnableFlowDelegate overrides:
69 void ExtensionEnableFlowFinished() override; 59 void ExtensionEnableFlowFinished() override;
70 void ExtensionEnableFlowAborted(bool user_initiated) override; 60 void ExtensionEnableFlowAborted(bool user_initiated) override;
71 61
72 // extensions::ExtensionRegistryObserver override: 62 // extensions::ExtensionRegistryObserver override:
73 void OnExtensionLoaded(content::BrowserContext* browser_context, 63 void OnExtensionLoaded(content::BrowserContext* browser_context,
74 const extensions::Extension* extension) override; 64 const extensions::Extension* extension) override;
75 void OnShutdown(extensions::ExtensionRegistry* registry) override; 65 void OnShutdown(extensions::ExtensionRegistry* registry) override;
76 66
67 // extensions::ExtensionAppIconDelegate:
68 void OnIconUpdated(extensions::ExtensionAppIcon* icon) override;
69
77 bool is_platform_app_; 70 bool is_platform_app_;
78 std::unique_ptr<extensions::IconImage> icon_; 71 std::unique_ptr<extensions::ExtensionAppIcon> icon_;
79 std::unique_ptr<ExtensionAppContextMenu> context_menu_; 72 std::unique_ptr<ExtensionAppContextMenu> context_menu_;
80 std::unique_ptr<ExtensionEnableFlow> extension_enable_flow_; 73 std::unique_ptr<ExtensionEnableFlow> extension_enable_flow_;
81 74
82 extensions::ExtensionRegistry* extension_registry_ = nullptr; 75 extensions::ExtensionRegistry* extension_registry_ = nullptr;
83 76
84 DISALLOW_COPY_AND_ASSIGN(ExtensionAppResult); 77 DISALLOW_COPY_AND_ASSIGN(ExtensionAppResult);
85 }; 78 };
86 79
87 } // namespace app_list 80 } // namespace app_list
88 81
89 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_EXTENSION_APP_RESULT_H_ 82 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_EXTENSION_APP_RESULT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698