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

Side by Side Diff: chrome/browser/extensions/extension_message_bubble_controller.h

Issue 134103002: Refactor the extension message bubbles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 6 years, 11 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
10 #include "chrome/browser/extensions/extension_message_bubble.h" 10 #include "chrome/browser/extensions/extension_message_bubble.h"
(...skipping 12 matching lines...) Expand all
23 // UMA histogram constants. 23 // UMA histogram constants.
24 enum BubbleAction { 24 enum BubbleAction {
25 ACTION_LEARN_MORE = 0, 25 ACTION_LEARN_MORE = 0,
26 ACTION_EXECUTE, 26 ACTION_EXECUTE,
27 ACTION_DISMISS, 27 ACTION_DISMISS,
28 ACTION_BOUNDARY, // Must be the last value. 28 ACTION_BOUNDARY, // Must be the last value.
29 }; 29 };
30 30
31 class Delegate { 31 class Delegate {
32 public: 32 public:
33 Delegate();
34 virtual ~Delegate();
35
33 virtual bool ShouldIncludeExtension(const std::string& extension_id) = 0; 36 virtual bool ShouldIncludeExtension(const std::string& extension_id) = 0;
34 virtual void AcknowledgeExtension( 37 virtual void AcknowledgeExtension(
35 const std::string& extension_id, 38 const std::string& extension_id,
36 BubbleAction action) = 0; 39 BubbleAction action) = 0;
37 virtual void PerformAction(const ExtensionIdList& list) = 0; 40 virtual void PerformAction(const ExtensionIdList& list) = 0;
38 41
39 // Text for various UI labels shown in the bubble. 42 // Text for various UI labels shown in the bubble.
40 virtual base::string16 GetTitle() const = 0; 43 virtual base::string16 GetTitle() const = 0;
41 virtual base::string16 GetMessageBody() const = 0; 44 virtual base::string16 GetMessageBody() const = 0;
42 virtual base::string16 GetOverflowText( 45 virtual base::string16 GetOverflowText(
43 const base::string16& overflow_count) const = 0; 46 const base::string16& overflow_count) const = 0;
44 virtual base::string16 GetLearnMoreLabel() const = 0; 47 virtual base::string16 GetLearnMoreLabel() const = 0;
45 virtual GURL GetLearnMoreUrl() const = 0; 48 virtual GURL GetLearnMoreUrl() const = 0;
46 virtual base::string16 GetActionButtonLabel() const = 0; 49 virtual base::string16 GetActionButtonLabel() const = 0;
47 virtual base::string16 GetDismissButtonLabel() const = 0; 50 virtual base::string16 GetDismissButtonLabel() const = 0;
48 51
49 // Whether to show a list of extensions in the bubble. 52 // Whether to show a list of extensions in the bubble.
50 virtual bool ShouldShowExtensionList() const = 0; 53 virtual bool ShouldShowExtensionList() const = 0;
51 // The data to show in the bubble.
52 virtual std::vector<base::string16> GetExtensions() = 0;
53 54
54 // Record, through UMA, how many extensions were found. 55 // Record, through UMA, how many extensions were found.
55 virtual void LogExtensionCount(size_t count) = 0; 56 virtual void LogExtensionCount(size_t count) = 0;
56 virtual void LogAction(BubbleAction action) = 0; 57 virtual void LogAction(BubbleAction action) = 0;
57 }; 58 };
58 59
59 ExtensionMessageBubbleController(Delegate* delegate, Profile* profile); 60 ExtensionMessageBubbleController(Delegate* delegate, Profile* profile);
60 virtual ~ExtensionMessageBubbleController(); 61 virtual ~ExtensionMessageBubbleController();
61 62
62 // Whether the controller knows of extensions to list in the bubble. Returns 63 Delegate* delegate() const { return delegate_.get(); }
63 // true if so.
64 bool ShouldShow();
65 64
66 // Obtains a list of all extensions (by name) the controller knows about. 65 // Obtains a list of all extensions (by name) the controller knows about.
67 std::vector<base::string16> GetExtensionList(); 66 std::vector<base::string16> GetExtensionList();
68 67
69 // Obtains a list of all extensions (by id) the controller knows about. 68 // Obtains a list of all extensions (by id) the controller knows about.
70 const ExtensionIdList& GetExtensionIdList(); 69 const ExtensionIdList& GetExtensionIdList();
71 70
72 // Sets up the callbacks and shows the bubble. 71 // Sets up the callbacks and shows the bubble.
73 void Show(ExtensionMessageBubble* bubble); 72 virtual void Show(ExtensionMessageBubble* bubble);
74 73
75 // Callbacks from bubble. Declared virtual for testing purposes. 74 // Callbacks from bubble. Declared virtual for testing purposes.
76 virtual void OnBubbleAction(); 75 virtual void OnBubbleAction();
77 virtual void OnBubbleDismiss(); 76 virtual void OnBubbleDismiss();
78 virtual void OnLinkClicked(); 77 virtual void OnLinkClicked();
79 78
79 private:
80 // Iterate over the known extensions and acknowledge each one. 80 // Iterate over the known extensions and acknowledge each one.
81 void AcknowledgeExtensions(); 81 void AcknowledgeExtensions();
82 82
83 // Get the data this class needs. 83 // Get the data this class needs.
84 ExtensionIdList* GetOrCreateExtensionList(); 84 ExtensionIdList* GetOrCreateExtensionList();
85 85
86 // Our extension service. Weak, not owned by us. 86 // Our extension service. Weak, not owned by us.
87 ExtensionService* service_; 87 ExtensionService* service_;
88 88
89 // A weak pointer to the profile we are associated with. Not owned by us. 89 // A weak pointer to the profile we are associated with. Not owned by us.
90 Profile* profile_; 90 Profile* profile_;
91 91
92 // The list of extensions found. 92 // The list of extensions found.
93 ExtensionIdList extension_list_; 93 ExtensionIdList extension_list_;
94 94
95 // The action the user took in the bubble. 95 // The action the user took in the bubble.
96 BubbleAction user_action_; 96 BubbleAction user_action_;
97 97
98 Delegate* delegate_; 98 // Our delegate supplying information about what to show in the dialog.
99 scoped_ptr<Delegate> delegate_;
99 100
100 // Whether this class has initialized. 101 // Whether this class has initialized.
101 bool initialized_; 102 bool initialized_;
102 103
103 // This object only checks once for suspicious extensions because the dataset
104 // doesn't change after startup.
105 bool has_notified_;
106
107 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleController); 104 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleController);
108 }; 105 };
109 106
110 } // namespace extensions 107 } // namespace extensions
111 108
112 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ 109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698