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