Chromium Code Reviews| Index: chrome/browser/extensions/suspicious_extension_bubble_controller_delegate.cc |
| diff --git a/chrome/browser/extensions/suspicious_extension_bubble_controller_delegate.cc b/chrome/browser/extensions/suspicious_extension_bubble_controller_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b0bdcc282124ede92401221359290a39a74898ea |
| --- /dev/null |
| +++ b/chrome/browser/extensions/suspicious_extension_bubble_controller_delegate.cc |
| @@ -0,0 +1,168 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/extensions/suspicious_extension_bubble_controller_delegate.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/metrics/histogram.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/extensions/extension_message_bubble.h" |
| +#include "chrome/browser/extensions/extension_prefs.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/common/url_constants.h" |
| +#include "content/public/browser/user_metrics.h" |
| +#include "grit/chromium_strings.h" |
| +#include "grit/generated_resources.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| + |
| +namespace { |
| + |
| +static base::LazyInstance<extensions::ProfileKeyedAPIFactory< |
| + extensions::SuspiciousExtensionBubbleControllerDelegate> > |
| +g_factory = LAZY_INSTANCE_INITIALIZER; |
| + |
| +} // namespace |
| + |
| +namespace extensions { |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// SuspiciousExtensionBubbleControllerDelegate |
| + |
| +SuspiciousExtensionBubbleControllerDelegate:: |
| + SuspiciousExtensionBubbleControllerDelegate( |
| + Profile* profile) |
| + : controller_(new ExtensionMessageBubbleController(this, profile)), |
| + service_(extensions::ExtensionSystem::Get(profile)->extension_service()), |
| + profile_(profile) { |
| +} |
| + |
| +SuspiciousExtensionBubbleControllerDelegate:: |
| + ~SuspiciousExtensionBubbleControllerDelegate() { |
| +} |
| + |
| +// static |
| +ProfileKeyedAPIFactory<SuspiciousExtensionBubbleControllerDelegate>* |
| +SuspiciousExtensionBubbleControllerDelegate::GetFactoryInstance() { |
| + return &g_factory.Get(); |
| +} |
| + |
| +// static |
| +SuspiciousExtensionBubbleControllerDelegate* |
| +SuspiciousExtensionBubbleControllerDelegate::Get(Profile* profile) { |
| + return ProfileKeyedAPIFactory< |
| + SuspiciousExtensionBubbleControllerDelegate>::GetForProfile(profile); |
| +} |
| + |
| +void SuspiciousExtensionBubbleControllerDelegate::Show( |
| + ExtensionMessageBubble* bubble) { |
| + controller_->Show(bubble); |
|
not at google - send to devlin
2013/12/10 01:21:39
see comment in extension_message_bubble_view.cc, t
Finnur
2013/12/11 23:12:18
These functions are now gone.
|
| +} |
| + |
| +bool SuspiciousExtensionBubbleControllerDelegate::ShowingBubble() const { |
| + return controller_->showing_bubble(); |
| +} |
| + |
| +bool SuspiciousExtensionBubbleControllerDelegate::HasExtensionList() const { |
| + return controller_->HasExtensionList(); |
| +} |
| + |
| +std::vector<string16> |
| +SuspiciousExtensionBubbleControllerDelegate::GetExtensionList() const { |
| + return controller_->GetExtensionList(); |
| +} |
| + |
| +const ExtensionIdList& |
| +SuspiciousExtensionBubbleControllerDelegate::GetExtensionIdList() const { |
| + return controller_->extension_id_list(); |
| +} |
| + |
| + |
| +bool SuspiciousExtensionBubbleControllerDelegate::ShouldIncludeExtension( |
| + const std::string& extension_id) { |
| + ExtensionPrefs* prefs = service_->extension_prefs(); |
| + if (!prefs->IsExtensionDisabled(extension_id)) |
| + return false; |
| + |
| + int disble_reasons = prefs->GetDisableReasons(extension_id); |
| + if (disble_reasons & Extension::DISABLE_NOT_VERIFIED) |
| + return !prefs->HasWipeoutBeenAcknowledged(extension_id); |
| + |
| + return false; |
| +} |
| + |
| +void SuspiciousExtensionBubbleControllerDelegate::AcknowledgeExtension( |
| + const std::string& extension_id, |
| + ExtensionMessageBubbleController::BubbleAction user_action) { |
| + ExtensionPrefs* prefs = service_->extension_prefs(); |
| + prefs->SetWipeoutAcknowledged(extension_id, true); |
| +} |
| + |
| +void SuspiciousExtensionBubbleControllerDelegate::PerformAction( |
| + const ExtensionIdList& list) { |
| + // This bubble solicits no action from the user. Or as Nimoy would have it: |
| + // "Well, my work here is done". |
| +} |
| + |
| +string16 SuspiciousExtensionBubbleControllerDelegate::GetTitle() const { |
| + return l10n_util::GetStringUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_TITLE); |
| +} |
| + |
| +string16 SuspiciousExtensionBubbleControllerDelegate::GetMessageBody() const { |
| + return l10n_util::GetStringFUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_BODY, |
| + l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)); |
| +} |
| + |
| +string16 SuspiciousExtensionBubbleControllerDelegate::GetOverflowText( |
| + const string16& overflow_count) const { |
| + return l10n_util::GetStringFUTF16( |
| + IDS_EXTENSIONS_SUSPICIOUS_DISABLED_AND_N_MORE, |
| + overflow_count); |
| +} |
| + |
| +string16 |
| +SuspiciousExtensionBubbleControllerDelegate::GetLearnMoreLabel() const { |
| + return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| +} |
| + |
| +GURL SuspiciousExtensionBubbleControllerDelegate::GetLearnMoreUrl() const { |
| + return GURL(chrome::kRemoveNonCWSExtensionURL); |
| +} |
| + |
| +string16 |
| +SuspiciousExtensionBubbleControllerDelegate::GetActionButtonLabel() const { |
| + return string16(); |
| +} |
| + |
| +string16 |
| +SuspiciousExtensionBubbleControllerDelegate::GetDismissButtonLabel() const { |
| + return l10n_util::GetStringUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_BUTTON); |
| +} |
| + |
| +bool |
| +SuspiciousExtensionBubbleControllerDelegate::ShouldShowExtensionList() const { |
| + return true; |
| +} |
| + |
| +void SuspiciousExtensionBubbleControllerDelegate::LogExtensionCount( |
| + size_t count) { |
| + UMA_HISTOGRAM_COUNTS_100( |
| + "ExtensionWipeoutBubble.ExtensionWipeoutCount", count); |
| +} |
| + |
| +void SuspiciousExtensionBubbleControllerDelegate::LogAction( |
| + ExtensionMessageBubbleController::BubbleAction action) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "ExtensionWipeoutBubble.UserSelection", |
| + action, ExtensionMessageBubbleController::ACTION_BOUNDARY); |
| +} |
| + |
| +template <> |
| +void ProfileKeyedAPIFactory< |
| + SuspiciousExtensionBubbleControllerDelegate>::DeclareFactoryDependencies() { |
| + DependsOn(extensions::ExtensionSystemFactory::GetInstance()); |
| +} |
| + |
| +} // namespace extensions |