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 using extensions::ExtensionMessageBubbleController; |
21 using extensions::SettingsApiBubbleController; | 22 using extensions::SettingsApiBubbleController; |
22 using extensions::SettingsOverrides; | 23 using extensions::SettingsOverrides; |
24 using extensions::ExtensionToolbarModel; | |
Devlin
2014/05/20 17:26:31
Why not move extensions namespace up?
Finnur
2014/05/21 16:30:32
Done.
| |
23 | 25 |
24 namespace { | 26 namespace { |
25 | 27 |
26 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
27 // SettingsApiBubbleDelegate | 29 // SettingsApiBubbleDelegate |
28 | 30 |
29 class SettingsApiBubbleDelegate | 31 class SettingsApiBubbleDelegate |
30 : public extensions::ExtensionMessageBubbleController::Delegate { | 32 : public extensions::ExtensionMessageBubbleController::Delegate { |
31 public: | 33 public: |
32 explicit SettingsApiBubbleDelegate(ExtensionService* service, | 34 explicit SettingsApiBubbleDelegate(ExtensionService* service, |
33 Profile* profile, | 35 Profile* profile, |
34 extensions::SettingsApiOverrideType type); | 36 extensions::SettingsApiOverrideType type); |
35 virtual ~SettingsApiBubbleDelegate(); | 37 virtual ~SettingsApiBubbleDelegate(); |
36 | 38 |
37 // ExtensionMessageBubbleController::Delegate methods. | 39 // ExtensionMessageBubbleController::Delegate methods. |
38 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; | 40 virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE; |
39 virtual void AcknowledgeExtension( | 41 virtual void AcknowledgeExtension( |
40 const std::string& extension_id, | 42 const std::string& extension_id, |
41 extensions::ExtensionMessageBubbleController::BubbleAction user_action) | 43 extensions::ExtensionMessageBubbleController::BubbleAction user_action) |
42 OVERRIDE; | 44 OVERRIDE; |
43 virtual void PerformAction(const extensions::ExtensionIdList& list) OVERRIDE; | 45 virtual void PerformAction(const extensions::ExtensionIdList& list) OVERRIDE; |
46 virtual void OnClose() OVERRIDE; | |
44 virtual base::string16 GetTitle() const OVERRIDE; | 47 virtual base::string16 GetTitle() const OVERRIDE; |
45 virtual base::string16 GetMessageBody() const OVERRIDE; | 48 virtual base::string16 GetMessageBody() const OVERRIDE; |
46 virtual base::string16 GetOverflowText( | 49 virtual base::string16 GetOverflowText( |
47 const base::string16& overflow_count) const OVERRIDE; | 50 const base::string16& overflow_count) const OVERRIDE; |
48 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; | 51 virtual base::string16 GetLearnMoreLabel() const OVERRIDE; |
49 virtual GURL GetLearnMoreUrl() const OVERRIDE; | 52 virtual GURL GetLearnMoreUrl() const OVERRIDE; |
50 virtual base::string16 GetActionButtonLabel() const OVERRIDE; | 53 virtual base::string16 GetActionButtonLabel() const OVERRIDE; |
51 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; | 54 virtual base::string16 GetDismissButtonLabel() const OVERRIDE; |
52 virtual bool ShouldShowExtensionList() const OVERRIDE; | 55 virtual bool ShouldShowExtensionList() const OVERRIDE; |
53 virtual void LogExtensionCount(size_t count) OVERRIDE; | 56 virtual void LogExtensionCount(size_t count) OVERRIDE; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 } | 128 } |
126 | 129 |
127 void SettingsApiBubbleDelegate::PerformAction( | 130 void SettingsApiBubbleDelegate::PerformAction( |
128 const extensions::ExtensionIdList& list) { | 131 const extensions::ExtensionIdList& list) { |
129 for (size_t i = 0; i < list.size(); ++i) { | 132 for (size_t i = 0; i < list.size(); ++i) { |
130 service_->DisableExtension(list[i], | 133 service_->DisableExtension(list[i], |
131 extensions::Extension::DISABLE_USER_ACTION); | 134 extensions::Extension::DISABLE_USER_ACTION); |
132 } | 135 } |
133 } | 136 } |
134 | 137 |
138 void SettingsApiBubbleDelegate::OnClose() { | |
139 ExtensionToolbarModel* toolbar_model = ExtensionToolbarModel::Get(profile_); | |
140 if (toolbar_model) | |
141 toolbar_model->StopHighlighting(); | |
142 } | |
143 | |
135 base::string16 SettingsApiBubbleDelegate::GetTitle() const { | 144 base::string16 SettingsApiBubbleDelegate::GetTitle() const { |
136 switch (type_) { | 145 switch (type_) { |
137 case extensions::BUBBLE_TYPE_HOME_PAGE: | 146 case extensions::BUBBLE_TYPE_HOME_PAGE: |
138 return l10n_util::GetStringUTF16( | 147 return l10n_util::GetStringUTF16( |
139 IDS_EXTENSIONS_SETTINGS_API_TITLE_HOME_PAGE_BUBBLE); | 148 IDS_EXTENSIONS_SETTINGS_API_TITLE_HOME_PAGE_BUBBLE); |
140 case extensions::BUBBLE_TYPE_STARTUP_PAGES: | 149 case extensions::BUBBLE_TYPE_STARTUP_PAGES: |
141 return l10n_util::GetStringUTF16( | 150 return l10n_util::GetStringUTF16( |
142 IDS_EXTENSIONS_SETTINGS_API_TITLE_STARTUP_PAGES_BUBBLE); | 151 IDS_EXTENSIONS_SETTINGS_API_TITLE_STARTUP_PAGES_BUBBLE); |
143 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: | 152 case extensions::BUBBLE_TYPE_SEARCH_ENGINE: |
144 return l10n_util::GetStringUTF16( | 153 return l10n_util::GetStringUTF16( |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 return true; | 315 return true; |
307 } | 316 } |
308 | 317 |
309 bool SettingsApiBubbleController::CloseOnDeactivate() { | 318 bool SettingsApiBubbleController::CloseOnDeactivate() { |
310 // Startup bubbles tend to get lost in the focus storm that happens on | 319 // Startup bubbles tend to get lost in the focus storm that happens on |
311 // startup. Other types should dismiss on focus loss. | 320 // startup. Other types should dismiss on focus loss. |
312 return type_ != BUBBLE_TYPE_STARTUP_PAGES; | 321 return type_ != BUBBLE_TYPE_STARTUP_PAGES; |
313 } | 322 } |
314 | 323 |
315 } // namespace extensions | 324 } // namespace extensions |
OLD | NEW |