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

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

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

Powered by Google App Engine
This is Rietveld 408576698