OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 #include "chrome/browser/extensions/settings_api_bubble_controller.h" | 5 #include "chrome/browser/extensions/settings_api_bubble_controller.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_toolbar_model.h" |
9 #include "chrome/browser/extensions/settings_api_helpers.h" | 10 #include "chrome/browser/extensions/settings_api_helpers.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 12 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
12 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.
h" | 13 #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.
h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "extensions/browser/extension_registry.h" | 15 #include "extensions/browser/extension_registry.h" |
15 #include "extensions/browser/extension_system.h" | 16 #include "extensions/browser/extension_system.h" |
16 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 | 20 |
20 using extensions::ExtensionMessageBubbleController; | 21 namespace extensions { |
21 using extensions::SettingsApiBubbleController; | |
22 using extensions::SettingsOverrides; | |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
27 // SettingsApiBubbleDelegate | 26 // SettingsApiBubbleDelegate |
28 | 27 |
29 class SettingsApiBubbleDelegate | 28 class SettingsApiBubbleDelegate |
30 : public extensions::ExtensionMessageBubbleController::Delegate { | 29 : public ExtensionMessageBubbleController::Delegate { |
31 public: | 30 public: |
32 explicit SettingsApiBubbleDelegate(ExtensionService* service, | 31 explicit SettingsApiBubbleDelegate(ExtensionService* service, |
33 Profile* profile, | 32 Profile* profile, |
34 extensions::SettingsApiOverrideType type); | 33 SettingsApiOverrideType type); |
35 virtual ~SettingsApiBubbleDelegate(); | 34 virtual ~SettingsApiBubbleDelegate(); |
36 | 35 |
37 // ExtensionMessageBubbleController::Delegate methods. | 36 // ExtensionMessageBubbleController::Delegate methods. |
38 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; | 37 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; |
39 virtual void AcknowledgeExtension( | 38 virtual void AcknowledgeExtension( |
40 const std::string& extension_id, | 39 const std::string& extension_id, |
41 extensions::ExtensionMessageBubbleController::BubbleAction user_action) | 40 ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE; |
42 OVERRIDE; | 41 virtual void PerformAction(const ExtensionIdList& list) OVERRIDE; |
43 virtual void PerformAction(const extensions::ExtensionIdList& list) OVERRIDE; | 42 virtual void OnClose() OVERRIDE; |
44 virtual base::string16 GetTitle() const OVERRIDE; | 43 virtual base::string16 GetTitle() const OVERRIDE; |
45 virtual base::string16 GetMessageBody() const OVERRIDE; | 44 virtual base::string16 GetMessageBody() const OVERRIDE; |
46 virtual base::string16 GetOverflowText( | 45 virtual base::string16 GetOverflowText( |
47 const base::string16& overflow_count) const OVERRIDE; | 46 const base::string16& overflow_count) const OVERRIDE; |
48 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; | 47 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; |
49 virtual GURL GetLearnMoreUrl() const OVERRIDE; | 48 virtual GURL GetLearnMoreUrl() const OVERRIDE; |
50 virtual base::string16 GetActionButtonLabel() const OVERRIDE; | 49 virtual base::string16 GetActionButtonLabel() const OVERRIDE; |
51 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; | 50 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; |
52 virtual bool ShouldShowExtensionList() const OVERRIDE; | 51 virtual bool ShouldShowExtensionList() const OVERRIDE; |
53 virtual void LogExtensionCount(size_t count) OVERRIDE; | 52 virtual void LogExtensionCount(size_t count) OVERRIDE; |
54 virtual void LogAction( | 53 virtual void LogAction( |
55 extensions::ExtensionMessageBubbleController::BubbleAction action) | 54 ExtensionMessageBubbleController::BubbleAction action) OVERRIDE; |
56 OVERRIDE; | |
57 | 55 |
58 private: | 56 private: |
59 // Our extension service. Weak, not owned by us. | 57 // Our extension service. Weak, not owned by us. |
60 ExtensionService* service_; | 58 ExtensionService* service_; |
61 | 59 |
62 // A weak pointer to the profile we are associated with. Not owned by us. | 60 // A weak pointer to the profile we are associated with. Not owned by us. |
63 Profile* profile_; | 61 Profile* profile_; |
64 | 62 |
65 // The type of settings override this bubble will report on. This can be, for | 63 // The type of settings override this bubble will report on. This can be, for |
66 // example, a bubble to notify the user that the search engine has been | 64 // example, a bubble to notify the user that the search engine has been |
67 // changed by an extension (or homepage/startup pages/etc). | 65 // changed by an extension (or homepage/startup pages/etc). |
68 extensions::SettingsApiOverrideType type_; | 66 SettingsApiOverrideType type_; |
69 | 67 |
70 // The ID of the extension we are showing the bubble for. | 68 // The ID of the extension we are showing the bubble for. |
71 std::string extension_id_; | 69 std::string extension_id_; |
72 | 70 |
73 DISALLOW_COPY_AND_ASSIGN(SettingsApiBubbleDelegate); | 71 DISALLOW_COPY_AND_ASSIGN(SettingsApiBubbleDelegate); |
74 }; | 72 }; |
75 | 73 |
76 SettingsApiBubbleDelegate::SettingsApiBubbleDelegate( | 74 SettingsApiBubbleDelegate::SettingsApiBubbleDelegate( |
77 ExtensionService* service, | 75 ExtensionService* service, |
78 Profile* profile, | 76 Profile* profile, |
79 extensions::SettingsApiOverrideType type) | 77 SettingsApiOverrideType type) |
80 : service_(service), profile_(profile), type_(type) {} | 78 : service_(service), profile_(profile), type_(type) {} |
81 | 79 |
82 SettingsApiBubbleDelegate::~SettingsApiBubbleDelegate() {} | 80 SettingsApiBubbleDelegate::~SettingsApiBubbleDelegate() {} |
83 | 81 |
84 bool SettingsApiBubbleDelegate::ShouldIncludeExtension( | 82 bool SettingsApiBubbleDelegate::ShouldIncludeExtension( |
85 const std::string& extension_id) { | 83 const std::string& extension_id) { |
86 using extensions::ExtensionRegistry; | |
87 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 84 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
88 const extensions::Extension* extension = | 85 const Extension* extension = |
89 registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); | 86 registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
90 if (!extension) | 87 if (!extension) |
91 return false; // The extension provided is no longer enabled. | 88 return false; // The extension provided is no longer enabled. |
92 | 89 |
93 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); | 90 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
94 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) | 91 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) |
95 return false; | 92 return false; |
96 | 93 |
97 const extensions::Extension* override = NULL; | 94 const Extension* override = NULL; |
98 switch (type_) { | 95 switch (type_) { |
99 case extensions::BUBBLE_TYPE_HOME_PAGE: | 96 case BUBBLE_TYPE_HOME_PAGE: |
100 override = extensions::OverridesHomepage(profile_, NULL); | 97 override = GetExtensionOverridingHomepage(profile_, NULL); |
101 break; | 98 break; |
102 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 99 case BUBBLE_TYPE_STARTUP_PAGES: |
103 override = extensions::OverridesStartupPages(profile_, NULL); | 100 override = GetExtensionOverridingStartupPages(profile_, NULL); |
104 break; | 101 break; |
105 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 102 case BUBBLE_TYPE_SEARCH_ENGINE: |
106 override = extensions::OverridesSearchEngine(profile_, NULL); | 103 override = GetExtensionOverridingSearchEngine(profile_, NULL); |
107 break; | 104 break; |
108 } | 105 } |
109 | 106 |
110 if (!override || override->id() != extension->id()) | 107 if (!override || override->id() != extension->id()) |
111 return false; | 108 return false; |
112 | 109 |
113 extension_id_ = extension_id; | 110 extension_id_ = extension_id; |
114 return true; | 111 return true; |
115 } | 112 } |
116 | 113 |
117 void SettingsApiBubbleDelegate::AcknowledgeExtension( | 114 void SettingsApiBubbleDelegate::AcknowledgeExtension( |
118 const std::string& extension_id, | 115 const std::string& extension_id, |
119 ExtensionMessageBubbleController::BubbleAction user_action) { | 116 ExtensionMessageBubbleController::BubbleAction user_action) { |
120 if (user_action != ExtensionMessageBubbleController::ACTION_EXECUTE) { | 117 if (user_action != ExtensionMessageBubbleController::ACTION_EXECUTE) { |
121 extensions::ExtensionPrefs* prefs = | 118 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
122 extensions::ExtensionPrefs::Get(profile_); | |
123 prefs->SetSettingsApiBubbleBeenAcknowledged(extension_id, true); | 119 prefs->SetSettingsApiBubbleBeenAcknowledged(extension_id, true); |
124 } | 120 } |
125 } | 121 } |
126 | 122 |
127 void SettingsApiBubbleDelegate::PerformAction( | 123 void SettingsApiBubbleDelegate::PerformAction(const ExtensionIdList& list) { |
128 const extensions::ExtensionIdList& list) { | |
129 for (size_t i = 0; i < list.size(); ++i) { | 124 for (size_t i = 0; i < list.size(); ++i) { |
130 service_->DisableExtension(list[i], | 125 service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION); |
131 extensions::Extension::DISABLE_USER_ACTION); | |
132 } | 126 } |
133 } | 127 } |
134 | 128 |
| 129 void SettingsApiBubbleDelegate::OnClose() { |
| 130 ExtensionToolbarModel* toolbar_model = ExtensionToolbarModel::Get(profile_); |
| 131 if (toolbar_model) |
| 132 toolbar_model->StopHighlighting(); |
| 133 } |
| 134 |
135 base::string16 SettingsApiBubbleDelegate::GetTitle() const { | 135 base::string16 SettingsApiBubbleDelegate::GetTitle() const { |
136 switch (type_) { | 136 switch (type_) { |
137 case extensions::BUBBLE_TYPE_HOME_PAGE: | 137 case BUBBLE_TYPE_HOME_PAGE: |
138 return l10n_util::GetStringUTF16( | 138 return l10n_util::GetStringUTF16( |
139 IDS_EXTENSIONS_SETTINGS_API_TITLE_HOME_PAGE_BUBBLE); | 139 IDS_EXTENSIONS_SETTINGS_API_TITLE_HOME_PAGE_BUBBLE); |
140 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 140 case BUBBLE_TYPE_STARTUP_PAGES: |
141 return l10n_util::GetStringUTF16( | 141 return l10n_util::GetStringUTF16( |
142 IDS_EXTENSIONS_SETTINGS_API_TITLE_STARTUP_PAGES_BUBBLE); | 142 IDS_EXTENSIONS_SETTINGS_API_TITLE_STARTUP_PAGES_BUBBLE); |
143 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 143 case BUBBLE_TYPE_SEARCH_ENGINE: |
144 return l10n_util::GetStringUTF16( | 144 return l10n_util::GetStringUTF16( |
145 IDS_EXTENSIONS_SETTINGS_API_TITLE_SEARCH_ENGINE_BUBBLE); | 145 IDS_EXTENSIONS_SETTINGS_API_TITLE_SEARCH_ENGINE_BUBBLE); |
146 } | 146 } |
147 NOTREACHED(); | 147 NOTREACHED(); |
148 return base::string16(); | 148 return base::string16(); |
149 } | 149 } |
150 | 150 |
151 base::string16 SettingsApiBubbleDelegate::GetMessageBody() const { | 151 base::string16 SettingsApiBubbleDelegate::GetMessageBody() const { |
152 using extensions::ExtensionRegistry; | |
153 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 152 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
154 const extensions::Extension* extension = | 153 const Extension* extension = |
155 registry->GetExtensionById(extension_id_, ExtensionRegistry::ENABLED); | 154 registry->GetExtensionById(extension_id_, ExtensionRegistry::ENABLED); |
156 const SettingsOverrides* settings = | 155 const SettingsOverrides* settings = |
157 extension ? SettingsOverrides::Get(extension) : NULL; | 156 extension ? SettingsOverrides::Get(extension) : NULL; |
158 if (!extension || !settings) { | 157 if (!extension || !settings) { |
159 NOTREACHED(); | 158 NOTREACHED(); |
160 return base::string16(); | 159 return base::string16(); |
161 } | 160 } |
162 | 161 |
163 bool home_change = settings->homepage != NULL; | 162 bool home_change = settings->homepage != NULL; |
164 bool startup_change = !settings->startup_pages.empty(); | 163 bool startup_change = !settings->startup_pages.empty(); |
165 bool search_change = settings->search_engine != NULL; | 164 bool search_change = settings->search_engine != NULL; |
166 | 165 |
167 base::string16 body; | 166 base::string16 body; |
168 switch (type_) { | 167 switch (type_) { |
169 case extensions::BUBBLE_TYPE_HOME_PAGE: | 168 case BUBBLE_TYPE_HOME_PAGE: |
170 body = l10n_util::GetStringUTF16( | 169 body = l10n_util::GetStringUTF16( |
171 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_HOME_PAGE); | 170 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_HOME_PAGE); |
172 if (startup_change && search_change) { | 171 if (startup_change && search_change) { |
173 body += l10n_util::GetStringUTF16( | 172 body += l10n_util::GetStringUTF16( |
174 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_SEARCH); | 173 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_SEARCH); |
175 } else if (startup_change) { | 174 } else if (startup_change) { |
176 body += l10n_util::GetStringUTF16( | 175 body += l10n_util::GetStringUTF16( |
177 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); | 176 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); |
178 } else if (search_change) { | 177 } else if (search_change) { |
179 body += l10n_util::GetStringUTF16( | 178 body += l10n_util::GetStringUTF16( |
180 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); | 179 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); |
181 } | 180 } |
182 break; | 181 break; |
183 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 182 case BUBBLE_TYPE_STARTUP_PAGES: |
184 body = l10n_util::GetStringUTF16( | 183 body = l10n_util::GetStringUTF16( |
185 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_START_PAGES); | 184 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_START_PAGES); |
186 if (home_change && search_change) { | 185 if (home_change && search_change) { |
187 body += l10n_util::GetStringUTF16( | 186 body += l10n_util::GetStringUTF16( |
188 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_AND_SEARCH); | 187 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_AND_SEARCH); |
189 } else if (home_change) { | 188 } else if (home_change) { |
190 body += l10n_util::GetStringUTF16( | 189 body += l10n_util::GetStringUTF16( |
191 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_PAGE); | 190 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_HOME_PAGE); |
192 } else if (search_change) { | 191 } else if (search_change) { |
193 body += l10n_util::GetStringUTF16( | 192 body += l10n_util::GetStringUTF16( |
194 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); | 193 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE); |
195 } | 194 } |
196 break; | 195 break; |
197 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 196 case BUBBLE_TYPE_SEARCH_ENGINE: |
198 body = l10n_util::GetStringUTF16( | 197 body = l10n_util::GetStringUTF16( |
199 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_SEARCH_ENGINE); | 198 IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_SEARCH_ENGINE); |
200 if (startup_change && home_change) { | 199 if (startup_change && home_change) { |
201 body += l10n_util::GetStringUTF16( | 200 body += l10n_util::GetStringUTF16( |
202 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_HOME); | 201 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_AND_HOME); |
203 } else if (startup_change) { | 202 } else if (startup_change) { |
204 body += l10n_util::GetStringUTF16( | 203 body += l10n_util::GetStringUTF16( |
205 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); | 204 IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_START_PAGES); |
206 } else if (home_change) { | 205 } else if (home_change) { |
207 body += l10n_util::GetStringUTF16( | 206 body += l10n_util::GetStringUTF16( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 bool SettingsApiBubbleDelegate::ShouldShowExtensionList() const { | 240 bool SettingsApiBubbleDelegate::ShouldShowExtensionList() const { |
242 return false; | 241 return false; |
243 } | 242 } |
244 | 243 |
245 void SettingsApiBubbleDelegate::LogExtensionCount(size_t count) { | 244 void SettingsApiBubbleDelegate::LogExtensionCount(size_t count) { |
246 } | 245 } |
247 | 246 |
248 void SettingsApiBubbleDelegate::LogAction( | 247 void SettingsApiBubbleDelegate::LogAction( |
249 ExtensionMessageBubbleController::BubbleAction action) { | 248 ExtensionMessageBubbleController::BubbleAction action) { |
250 switch (type_) { | 249 switch (type_) { |
251 case extensions::BUBBLE_TYPE_HOME_PAGE: | 250 case BUBBLE_TYPE_HOME_PAGE: |
252 UMA_HISTOGRAM_ENUMERATION( | 251 UMA_HISTOGRAM_ENUMERATION( |
253 "ExtensionOverrideBubble.SettingsApiUserSelectionHomePage", | 252 "ExtensionOverrideBubble.SettingsApiUserSelectionHomePage", |
254 action, | 253 action, |
255 ExtensionMessageBubbleController::ACTION_BOUNDARY); | 254 ExtensionMessageBubbleController::ACTION_BOUNDARY); |
256 break; | 255 break; |
257 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 256 case BUBBLE_TYPE_STARTUP_PAGES: |
258 UMA_HISTOGRAM_ENUMERATION( | 257 UMA_HISTOGRAM_ENUMERATION( |
259 "ExtensionOverrideBubble.SettingsApiUserSelectionStartupPage", | 258 "ExtensionOverrideBubble.SettingsApiUserSelectionStartupPage", |
260 action, | 259 action, |
261 ExtensionMessageBubbleController::ACTION_BOUNDARY); | 260 ExtensionMessageBubbleController::ACTION_BOUNDARY); |
262 break; | 261 break; |
263 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 262 case BUBBLE_TYPE_SEARCH_ENGINE: |
264 UMA_HISTOGRAM_ENUMERATION( | 263 UMA_HISTOGRAM_ENUMERATION( |
265 "ExtensionOverrideBubble.SettingsApiUserSelectionSearchEngine", | 264 "ExtensionOverrideBubble.SettingsApiUserSelectionSearchEngine", |
266 action, | 265 action, |
267 ExtensionMessageBubbleController::ACTION_BOUNDARY); | 266 ExtensionMessageBubbleController::ACTION_BOUNDARY); |
268 break; | 267 break; |
269 } | 268 } |
270 } | 269 } |
271 | 270 |
272 } // namespace | 271 } // namespace |
273 | 272 |
274 namespace extensions { | |
275 | |
276 //////////////////////////////////////////////////////////////////////////////// | 273 //////////////////////////////////////////////////////////////////////////////// |
277 // SettingsApiBubbleController | 274 // SettingsApiBubbleController |
278 | 275 |
279 SettingsApiBubbleController::SettingsApiBubbleController( | 276 SettingsApiBubbleController::SettingsApiBubbleController( |
280 Profile* profile, | 277 Profile* profile, |
281 SettingsApiOverrideType type) | 278 SettingsApiOverrideType type) |
282 : ExtensionMessageBubbleController( | 279 : ExtensionMessageBubbleController( |
283 new SettingsApiBubbleDelegate( | 280 new SettingsApiBubbleDelegate( |
284 ExtensionSystem::Get(profile)->extension_service(), | 281 ExtensionSystem::Get(profile)->extension_service(), |
285 profile, | 282 profile, |
286 type), | 283 type), |
287 profile), | 284 profile), |
288 profile_(profile), | 285 profile_(profile), |
289 type_(type) {} | 286 type_(type) {} |
290 | 287 |
291 SettingsApiBubbleController::~SettingsApiBubbleController() {} | 288 SettingsApiBubbleController::~SettingsApiBubbleController() {} |
292 | 289 |
293 bool SettingsApiBubbleController::ShouldShow(const std::string& extension_id) { | 290 bool SettingsApiBubbleController::ShouldShow(const std::string& extension_id) { |
294 extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_); | 291 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); |
295 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) | 292 if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id)) |
296 return false; | 293 return false; |
297 | 294 |
298 if (!delegate()->ShouldIncludeExtension(extension_id)) | 295 if (!delegate()->ShouldIncludeExtension(extension_id)) |
299 return false; | 296 return false; |
300 | 297 |
301 // If the browser is showing the 'Chrome crashed' infobar, it won't be showing | 298 // If the browser is showing the 'Chrome crashed' infobar, it won't be showing |
302 // the startup pages, so there's no point in showing the bubble now. | 299 // the startup pages, so there's no point in showing the bubble now. |
303 if (type_ == BUBBLE_TYPE_STARTUP_PAGES) | 300 if (type_ == BUBBLE_TYPE_STARTUP_PAGES) |
304 return profile_->GetLastSessionExitType() != Profile::EXIT_CRASHED; | 301 return profile_->GetLastSessionExitType() != Profile::EXIT_CRASHED; |
305 | 302 |
306 return true; | 303 return true; |
307 } | 304 } |
308 | 305 |
309 bool SettingsApiBubbleController::CloseOnDeactivate() { | 306 bool SettingsApiBubbleController::CloseOnDeactivate() { |
310 // Startup bubbles tend to get lost in the focus storm that happens on | 307 // Startup bubbles tend to get lost in the focus storm that happens on |
311 // startup. Other types should dismiss on focus loss. | 308 // startup. Other types should dismiss on focus loss. |
312 return type_ != BUBBLE_TYPE_STARTUP_PAGES; | 309 return type_ != BUBBLE_TYPE_STARTUP_PAGES; |
313 } | 310 } |
314 | 311 |
315 } // namespace extensions | 312 } // namespace extensions |
OLD | NEW |