OLD | NEW |
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 "extensions/browser/browser_context_keyed_api_factory.h" | 9 #include "extensions/browser/browser_context_keyed_api_factory.h" |
10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
11 | 11 |
12 class Browser; | 12 class Browser; |
13 class ExtensionService; | 13 class ExtensionService; |
14 class Profile; | 14 class Profile; |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 class ExtensionPrefs; | 18 class ExtensionPrefs; |
19 class ExtensionRegistry; | 19 class ExtensionRegistry; |
20 | 20 |
21 class ExtensionMessageBubbleController { | 21 class ExtensionMessageBubbleController { |
22 public: | 22 public: |
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_USER_ACTION, | 27 ACTION_DISMISS, |
28 ACTION_DISMISS_DEACTIVATION, | 28 ACTION_BOUNDARY, // Must be the last value. |
29 ACTION_BOUNDARY, // Must be the last value. | |
30 }; | 29 }; |
31 | 30 |
32 class Delegate { | 31 class Delegate { |
33 public: | 32 public: |
34 explicit Delegate(Profile* profile); | 33 explicit Delegate(Profile* profile); |
35 virtual ~Delegate(); | 34 virtual ~Delegate(); |
36 | 35 |
37 virtual bool ShouldIncludeExtension(const Extension* extension) = 0; | 36 virtual bool ShouldIncludeExtension(const Extension* extension) = 0; |
38 virtual void AcknowledgeExtension( | 37 virtual void AcknowledgeExtension( |
39 const std::string& extension_id, | 38 const std::string& extension_id, |
(...skipping 28 matching lines...) Expand all Loading... |
68 // the toolbar. | 67 // the toolbar. |
69 virtual bool ShouldHighlightExtensions() const = 0; | 68 virtual bool ShouldHighlightExtensions() const = 0; |
70 | 69 |
71 // Returns true if only enabled extensions should be considered. | 70 // Returns true if only enabled extensions should be considered. |
72 virtual bool ShouldLimitToEnabledExtensions() const = 0; | 71 virtual bool ShouldLimitToEnabledExtensions() const = 0; |
73 | 72 |
74 // Record, through UMA, how many extensions were found. | 73 // Record, through UMA, how many extensions were found. |
75 virtual void LogExtensionCount(size_t count) = 0; | 74 virtual void LogExtensionCount(size_t count) = 0; |
76 virtual void LogAction(BubbleAction action) = 0; | 75 virtual void LogAction(BubbleAction action) = 0; |
77 | 76 |
78 // Returns a key unique to the type of bubble that can be used to retrieve | 77 // Has the user acknowledged info about the extension the bubble reports. |
79 // state specific to the type (e.g., shown for profiles). | 78 virtual bool HasBubbleInfoBeenAcknowledged(const std::string& extension_id); |
80 virtual const char* GetKey() = 0; | 79 virtual void SetBubbleInfoBeenAcknowledged(const std::string& extension_id, |
| 80 bool value); |
81 | 81 |
82 // Whether the "shown for profiles" set should be cleared if an action is | 82 // Returns the set of profiles for which this bubble has been shown. |
83 // taken on the bubble. This defaults to true, since once an action is | 83 // If profiles are not tracked, returns null (default). |
84 // taken, the extension will usually either be acknowledged or removed, and | 84 virtual std::set<Profile*>* GetProfileSet(); |
85 // the bubble won't show for that extension. | |
86 // This should be false in cases where there is no acknowledgment option | |
87 // (as in the developer-mode extension warning). | |
88 virtual bool ClearProfileSetAfterAction(); | |
89 | |
90 // Has the user acknowledged info about the extension the bubble reports. | |
91 bool HasBubbleInfoBeenAcknowledged(const std::string& extension_id); | |
92 void SetBubbleInfoBeenAcknowledged(const std::string& extension_id, | |
93 bool value); | |
94 | 85 |
95 protected: | 86 protected: |
96 Profile* profile() { return profile_; } | 87 Profile* profile() { return profile_; } |
97 ExtensionService* service() { return service_; } | 88 ExtensionService* service() { return service_; } |
98 const ExtensionRegistry* registry() const { return registry_; } | 89 const ExtensionRegistry* registry() const { return registry_; } |
99 | 90 |
100 std::string get_acknowledged_flag_pref_name() const; | 91 std::string get_acknowledged_flag_pref_name() const; |
101 void set_acknowledged_flag_pref_name(const std::string& pref_name); | 92 void set_acknowledged_flag_pref_name(const std::string& pref_name); |
102 | 93 |
103 private: | 94 private: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Highlights the affected extensions if appropriate. Safe to call multiple | 134 // Highlights the affected extensions if appropriate. Safe to call multiple |
144 // times. | 135 // times. |
145 void HighlightExtensionsIfNecessary(); | 136 void HighlightExtensionsIfNecessary(); |
146 | 137 |
147 // Called when the bubble is actually shown. Because some bubbles are delayed | 138 // Called when the bubble is actually shown. Because some bubbles are delayed |
148 // (in order to weather the "focus storm"), they are not shown immediately. | 139 // (in order to weather the "focus storm"), they are not shown immediately. |
149 void OnShown(); | 140 void OnShown(); |
150 | 141 |
151 // Callbacks from bubble. Declared virtual for testing purposes. | 142 // Callbacks from bubble. Declared virtual for testing purposes. |
152 virtual void OnBubbleAction(); | 143 virtual void OnBubbleAction(); |
153 virtual void OnBubbleDismiss(bool dismissed_by_deactivation); | 144 virtual void OnBubbleDismiss(); |
154 virtual void OnLinkClicked(); | 145 virtual void OnLinkClicked(); |
155 | 146 |
156 void ClearProfileListForTesting(); | |
157 | |
158 static void set_should_ignore_learn_more_for_testing( | 147 static void set_should_ignore_learn_more_for_testing( |
159 bool should_ignore_learn_more); | 148 bool should_ignore_learn_more); |
160 | 149 |
161 private: | 150 private: |
162 // Iterate over the known extensions and acknowledge each one. | 151 // Iterate over the known extensions and acknowledge each one. |
163 void AcknowledgeExtensions(); | 152 void AcknowledgeExtensions(); |
164 | 153 |
165 // Get the data this class needs. | 154 // Get the data this class needs. |
166 ExtensionIdList* GetOrCreateExtensionList(); | 155 ExtensionIdList* GetOrCreateExtensionList(); |
167 | 156 |
168 // Performs cleanup after the bubble closes. | 157 // Performs cleanup after the bubble closes. |
169 void OnClose(); | 158 void OnClose(); |
170 | 159 |
171 std::set<Profile*>* GetProfileSet(); | |
172 | |
173 // A weak pointer to the Browser we are associated with. Not owned by us. | 160 // A weak pointer to the Browser we are associated with. Not owned by us. |
174 Browser* browser_; | 161 Browser* browser_; |
175 | 162 |
176 // The list of extensions found. | 163 // The list of extensions found. |
177 ExtensionIdList extension_list_; | 164 ExtensionIdList extension_list_; |
178 | 165 |
179 // The action the user took in the bubble. | 166 // The action the user took in the bubble. |
180 BubbleAction user_action_; | 167 BubbleAction user_action_; |
181 | 168 |
182 // Our delegate supplying information about what to show in the dialog. | 169 // Our delegate supplying information about what to show in the dialog. |
183 scoped_ptr<Delegate> delegate_; | 170 scoped_ptr<Delegate> delegate_; |
184 | 171 |
185 // Whether this class has initialized. | 172 // Whether this class has initialized. |
186 bool initialized_; | 173 bool initialized_; |
187 | 174 |
188 // Whether or not the bubble is highlighting extensions. | 175 // Whether or not the bubble is highlighting extensions. |
189 bool did_highlight_; | 176 bool did_highlight_; |
190 | 177 |
191 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleController); | 178 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleController); |
192 }; | 179 }; |
193 | 180 |
194 } // namespace extensions | 181 } // namespace extensions |
195 | 182 |
196 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ | 183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_CONTROLLER_H_ |
OLD | NEW |