| Index: chrome/browser/extensions/settings_api_bubble_controller.cc
|
| diff --git a/chrome/browser/extensions/settings_api_bubble_controller.cc b/chrome/browser/extensions/settings_api_bubble_controller.cc
|
| index 0b353883f17678437bf800fb3d4115d09f0d9130..79d7eb71e3e3bc36342de496f63c62c7e219814a 100644
|
| --- a/chrome/browser/extensions/settings_api_bubble_controller.cc
|
| +++ b/chrome/browser/extensions/settings_api_bubble_controller.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/metrics/histogram.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| +#include "chrome/browser/extensions/extension_toolbar_model.h"
|
| #include "chrome/browser/extensions/settings_api_helpers.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/startup/startup_browser_creator.h"
|
| @@ -18,9 +19,7 @@
|
| #include "grit/generated_resources.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| -using extensions::ExtensionMessageBubbleController;
|
| -using extensions::SettingsApiBubbleController;
|
| -using extensions::SettingsOverrides;
|
| +namespace extensions {
|
|
|
| namespace {
|
|
|
| @@ -28,22 +27,23 @@ namespace {
|
| // SettingsApiBubbleDelegate
|
|
|
| class SettingsApiBubbleDelegate
|
| - : public extensions::ExtensionMessageBubbleController::Delegate {
|
| + : public ExtensionMessageBubbleController::Delegate {
|
| public:
|
| explicit SettingsApiBubbleDelegate(ExtensionService* service,
|
| Profile* profile,
|
| - extensions::SettingsApiOverrideType type);
|
| + SettingsApiOverrideType type);
|
| virtual ~SettingsApiBubbleDelegate();
|
|
|
| // ExtensionMessageBubbleController::Delegate methods.
|
| virtual bool ShouldIncludeExtension(const std::string& extension_id) OVERRIDE;
|
| virtual void AcknowledgeExtension(
|
| const std::string& extension_id,
|
| - extensions::ExtensionMessageBubbleController::BubbleAction user_action)
|
| - OVERRIDE;
|
| - virtual void PerformAction(const extensions::ExtensionIdList& list) OVERRIDE;
|
| + ExtensionMessageBubbleController::BubbleAction user_action) OVERRIDE;
|
| + virtual void PerformAction(const ExtensionIdList& list) OVERRIDE;
|
| + virtual void OnClose() OVERRIDE;
|
| virtual base::string16 GetTitle() const OVERRIDE;
|
| - virtual base::string16 GetMessageBody() const OVERRIDE;
|
| + virtual base::string16 GetMessageBody(
|
| + bool anchored_to_browser_action) const OVERRIDE;
|
| virtual base::string16 GetOverflowText(
|
| const base::string16& overflow_count) const OVERRIDE;
|
| virtual base::string16 GetLearnMoreLabel() const OVERRIDE;
|
| @@ -53,8 +53,7 @@ class SettingsApiBubbleDelegate
|
| virtual bool ShouldShowExtensionList() const OVERRIDE;
|
| virtual void LogExtensionCount(size_t count) OVERRIDE;
|
| virtual void LogAction(
|
| - extensions::ExtensionMessageBubbleController::BubbleAction action)
|
| - OVERRIDE;
|
| + ExtensionMessageBubbleController::BubbleAction action) OVERRIDE;
|
|
|
| private:
|
| // Our extension service. Weak, not owned by us.
|
| @@ -66,7 +65,7 @@ class SettingsApiBubbleDelegate
|
| // The type of settings override this bubble will report on. This can be, for
|
| // example, a bubble to notify the user that the search engine has been
|
| // changed by an extension (or homepage/startup pages/etc).
|
| - extensions::SettingsApiOverrideType type_;
|
| + SettingsApiOverrideType type_;
|
|
|
| // The ID of the extension we are showing the bubble for.
|
| std::string extension_id_;
|
| @@ -77,34 +76,33 @@ class SettingsApiBubbleDelegate
|
| SettingsApiBubbleDelegate::SettingsApiBubbleDelegate(
|
| ExtensionService* service,
|
| Profile* profile,
|
| - extensions::SettingsApiOverrideType type)
|
| + SettingsApiOverrideType type)
|
| : service_(service), profile_(profile), type_(type) {}
|
|
|
| SettingsApiBubbleDelegate::~SettingsApiBubbleDelegate() {}
|
|
|
| bool SettingsApiBubbleDelegate::ShouldIncludeExtension(
|
| const std::string& extension_id) {
|
| - using extensions::ExtensionRegistry;
|
| ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
|
| - const extensions::Extension* extension =
|
| + const Extension* extension =
|
| registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED);
|
| if (!extension)
|
| return false; // The extension provided is no longer enabled.
|
|
|
| - extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_);
|
| + ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
|
| if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id))
|
| return false;
|
|
|
| - const extensions::Extension* override = NULL;
|
| + const Extension* override = NULL;
|
| switch (type_) {
|
| - case extensions::BUBBLE_TYPE_HOME_PAGE:
|
| - override = extensions::OverridesHomepage(profile_, NULL);
|
| + case BUBBLE_TYPE_HOME_PAGE:
|
| + override = GetExtensionOverridingHomepage(profile_, NULL);
|
| break;
|
| - case extensions::BUBBLE_TYPE_STARTUP_PAGES:
|
| - override = extensions::OverridesStartupPages(profile_, NULL);
|
| + case BUBBLE_TYPE_STARTUP_PAGES:
|
| + override = GetExtensionOverridingStartupPages(profile_, NULL);
|
| break;
|
| - case extensions::BUBBLE_TYPE_SEARCH_ENGINE:
|
| - override = extensions::OverridesSearchEngine(profile_, NULL);
|
| + case BUBBLE_TYPE_SEARCH_ENGINE:
|
| + override = GetExtensionOverridingSearchEngine(profile_, NULL);
|
| break;
|
| }
|
|
|
| @@ -119,29 +117,32 @@ void SettingsApiBubbleDelegate::AcknowledgeExtension(
|
| const std::string& extension_id,
|
| ExtensionMessageBubbleController::BubbleAction user_action) {
|
| if (user_action != ExtensionMessageBubbleController::ACTION_EXECUTE) {
|
| - extensions::ExtensionPrefs* prefs =
|
| - extensions::ExtensionPrefs::Get(profile_);
|
| + ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
|
| prefs->SetSettingsApiBubbleBeenAcknowledged(extension_id, true);
|
| }
|
| }
|
|
|
| -void SettingsApiBubbleDelegate::PerformAction(
|
| - const extensions::ExtensionIdList& list) {
|
| +void SettingsApiBubbleDelegate::PerformAction(const ExtensionIdList& list) {
|
| for (size_t i = 0; i < list.size(); ++i) {
|
| - service_->DisableExtension(list[i],
|
| - extensions::Extension::DISABLE_USER_ACTION);
|
| + service_->DisableExtension(list[i], Extension::DISABLE_USER_ACTION);
|
| }
|
| }
|
|
|
| +void SettingsApiBubbleDelegate::OnClose() {
|
| + ExtensionToolbarModel* toolbar_model = ExtensionToolbarModel::Get(profile_);
|
| + if (toolbar_model)
|
| + toolbar_model->StopHighlighting();
|
| +}
|
| +
|
| base::string16 SettingsApiBubbleDelegate::GetTitle() const {
|
| switch (type_) {
|
| - case extensions::BUBBLE_TYPE_HOME_PAGE:
|
| + case BUBBLE_TYPE_HOME_PAGE:
|
| return l10n_util::GetStringUTF16(
|
| IDS_EXTENSIONS_SETTINGS_API_TITLE_HOME_PAGE_BUBBLE);
|
| - case extensions::BUBBLE_TYPE_STARTUP_PAGES:
|
| + case BUBBLE_TYPE_STARTUP_PAGES:
|
| return l10n_util::GetStringUTF16(
|
| IDS_EXTENSIONS_SETTINGS_API_TITLE_STARTUP_PAGES_BUBBLE);
|
| - case extensions::BUBBLE_TYPE_SEARCH_ENGINE:
|
| + case BUBBLE_TYPE_SEARCH_ENGINE:
|
| return l10n_util::GetStringUTF16(
|
| IDS_EXTENSIONS_SETTINGS_API_TITLE_SEARCH_ENGINE_BUBBLE);
|
| }
|
| @@ -149,10 +150,10 @@ base::string16 SettingsApiBubbleDelegate::GetTitle() const {
|
| return base::string16();
|
| }
|
|
|
| -base::string16 SettingsApiBubbleDelegate::GetMessageBody() const {
|
| - using extensions::ExtensionRegistry;
|
| +base::string16 SettingsApiBubbleDelegate::GetMessageBody(
|
| + bool anchored_to_browser_action) const {
|
| ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
|
| - const extensions::Extension* extension =
|
| + const Extension* extension =
|
| registry->GetExtensionById(extension_id_, ExtensionRegistry::ENABLED);
|
| const SettingsOverrides* settings =
|
| extension ? SettingsOverrides::Get(extension) : NULL;
|
| @@ -167,7 +168,7 @@ base::string16 SettingsApiBubbleDelegate::GetMessageBody() const {
|
|
|
| base::string16 body;
|
| switch (type_) {
|
| - case extensions::BUBBLE_TYPE_HOME_PAGE:
|
| + case BUBBLE_TYPE_HOME_PAGE:
|
| body = l10n_util::GetStringUTF16(
|
| IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_HOME_PAGE);
|
| if (startup_change && search_change) {
|
| @@ -181,7 +182,7 @@ base::string16 SettingsApiBubbleDelegate::GetMessageBody() const {
|
| IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE);
|
| }
|
| break;
|
| - case extensions::BUBBLE_TYPE_STARTUP_PAGES:
|
| + case BUBBLE_TYPE_STARTUP_PAGES:
|
| body = l10n_util::GetStringUTF16(
|
| IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_START_PAGES);
|
| if (home_change && search_change) {
|
| @@ -195,7 +196,7 @@ base::string16 SettingsApiBubbleDelegate::GetMessageBody() const {
|
| IDS_EXTENSIONS_SETTINGS_API_SECOND_LINE_SEARCH_ENGINE);
|
| }
|
| break;
|
| - case extensions::BUBBLE_TYPE_SEARCH_ENGINE:
|
| + case BUBBLE_TYPE_SEARCH_ENGINE:
|
| body = l10n_util::GetStringUTF16(
|
| IDS_EXTENSIONS_SETTINGS_API_FIRST_LINE_SEARCH_ENGINE);
|
| if (startup_change && home_change) {
|
| @@ -249,19 +250,19 @@ void SettingsApiBubbleDelegate::LogExtensionCount(size_t count) {
|
| void SettingsApiBubbleDelegate::LogAction(
|
| ExtensionMessageBubbleController::BubbleAction action) {
|
| switch (type_) {
|
| - case extensions::BUBBLE_TYPE_HOME_PAGE:
|
| + case BUBBLE_TYPE_HOME_PAGE:
|
| UMA_HISTOGRAM_ENUMERATION(
|
| "ExtensionOverrideBubble.SettingsApiUserSelectionHomePage",
|
| action,
|
| ExtensionMessageBubbleController::ACTION_BOUNDARY);
|
| break;
|
| - case extensions::BUBBLE_TYPE_STARTUP_PAGES:
|
| + case BUBBLE_TYPE_STARTUP_PAGES:
|
| UMA_HISTOGRAM_ENUMERATION(
|
| "ExtensionOverrideBubble.SettingsApiUserSelectionStartupPage",
|
| action,
|
| ExtensionMessageBubbleController::ACTION_BOUNDARY);
|
| break;
|
| - case extensions::BUBBLE_TYPE_SEARCH_ENGINE:
|
| + case BUBBLE_TYPE_SEARCH_ENGINE:
|
| UMA_HISTOGRAM_ENUMERATION(
|
| "ExtensionOverrideBubble.SettingsApiUserSelectionSearchEngine",
|
| action,
|
| @@ -272,8 +273,6 @@ void SettingsApiBubbleDelegate::LogAction(
|
|
|
| } // namespace
|
|
|
| -namespace extensions {
|
| -
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // SettingsApiBubbleController
|
|
|
| @@ -292,7 +291,7 @@ SettingsApiBubbleController::SettingsApiBubbleController(
|
| SettingsApiBubbleController::~SettingsApiBubbleController() {}
|
|
|
| bool SettingsApiBubbleController::ShouldShow(const std::string& extension_id) {
|
| - extensions::ExtensionPrefs* prefs = extensions::ExtensionPrefs::Get(profile_);
|
| + ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
|
| if (prefs->HasSettingsApiBubbleBeenAcknowledged(extension_id))
|
| return false;
|
|
|
|
|