| Index: chrome/browser/extensions/suspicious_extension_bubble_controller.cc
|
| diff --git a/chrome/browser/extensions/suspicious_extension_bubble_controller.cc b/chrome/browser/extensions/suspicious_extension_bubble_controller.cc
|
| index 3d3a7dd736cb0d46d48948dea53e23b8cb88cc1c..50636ea952e2af594fa9c47bcd47b7f7047531b0 100644
|
| --- a/chrome/browser/extensions/suspicious_extension_bubble_controller.cc
|
| +++ b/chrome/browser/extensions/suspicious_extension_bubble_controller.cc
|
| @@ -7,9 +7,9 @@
|
| #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/extensions/suspicious_extension_bubble.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_finder.h"
|
| #include "chrome/common/url_constants.h"
|
| @@ -20,13 +20,6 @@
|
|
|
| namespace {
|
|
|
| -// UMA histogram constants.
|
| -enum UmaWipeoutHistogramOptions {
|
| - ACTION_LEARN_MORE = 0,
|
| - ACTION_DISMISS,
|
| - ACTION_BOUNDARY, // Must be the last value.
|
| -};
|
| -
|
| static base::LazyInstance<extensions::ProfileKeyedAPIFactory<
|
| extensions::SuspiciousExtensionBubbleController> >
|
| g_factory = LAZY_INSTANCE_INITIALIZER;
|
| @@ -40,12 +33,13 @@ namespace extensions {
|
|
|
| SuspiciousExtensionBubbleController::SuspiciousExtensionBubbleController(
|
| Profile* profile)
|
| - : service_(extensions::ExtensionSystem::Get(profile)->extension_service()),
|
| - profile_(profile),
|
| - has_notified_(false) {
|
| + : ExtensionMessageBubbleController(this, profile),
|
| + service_(extensions::ExtensionSystem::Get(profile)->extension_service()),
|
| + profile_(profile) {
|
| }
|
|
|
| -SuspiciousExtensionBubbleController::~SuspiciousExtensionBubbleController() {
|
| +SuspiciousExtensionBubbleController::
|
| + ~SuspiciousExtensionBubbleController() {
|
| }
|
|
|
| // static
|
| @@ -55,75 +49,49 @@ SuspiciousExtensionBubbleController::GetFactoryInstance() {
|
| }
|
|
|
| // static
|
| -SuspiciousExtensionBubbleController* SuspiciousExtensionBubbleController::Get(
|
| - Profile* profile) {
|
| +SuspiciousExtensionBubbleController*
|
| +SuspiciousExtensionBubbleController::Get(Profile* profile) {
|
| return ProfileKeyedAPIFactory<
|
| SuspiciousExtensionBubbleController>::GetForProfile(profile);
|
| }
|
|
|
| -bool SuspiciousExtensionBubbleController::HasSuspiciousExtensions() {
|
| - if (has_notified_)
|
| - return false;
|
| - if (!service_)
|
| - return false; // Can happen during tests.
|
| -
|
| - suspicious_extensions_.clear();
|
| -
|
| +bool SuspiciousExtensionBubbleController::ShouldIncludeExtension(
|
| + const std::string& extension_id) {
|
| ExtensionPrefs* prefs = service_->extension_prefs();
|
| + if (!prefs->IsExtensionDisabled(extension_id))
|
| + return false;
|
|
|
| - scoped_ptr<const ExtensionSet> extension_set(
|
| - service_->GenerateInstalledExtensionsSet());
|
| - for (ExtensionSet::const_iterator it = extension_set->begin();
|
| - it != extension_set->end(); ++it) {
|
| - std::string id = (*it)->id();
|
| - if (!prefs->IsExtensionDisabled(id))
|
| - continue;
|
| - int disble_reasons = prefs->GetDisableReasons(id);
|
| - if (disble_reasons & Extension::DISABLE_NOT_VERIFIED) {
|
| - if (prefs->HasWipeoutBeenAcknowledged(id))
|
| - continue;
|
| -
|
| - suspicious_extensions_.push_back(id);
|
| - }
|
| - }
|
| -
|
| - UMA_HISTOGRAM_COUNTS_100(
|
| - "SuspiciousExtensionBubble.ExtensionWipeoutCount",
|
| - suspicious_extensions_.size());
|
| + int disble_reasons = prefs->GetDisableReasons(extension_id);
|
| + if (disble_reasons & Extension::DISABLE_NOT_VERIFIED)
|
| + return !prefs->HasWipeoutBeenAcknowledged(extension_id);
|
|
|
| - has_notified_ = true;
|
| - return !suspicious_extensions_.empty();
|
| + return false;
|
| }
|
|
|
| -void SuspiciousExtensionBubbleController::Show(
|
| - SuspiciousExtensionBubble* bubble) {
|
| - // Wire up all the callbacks, to get notified what actions the user took.
|
| - base::Closure button_callback =
|
| - base::Bind(&SuspiciousExtensionBubbleController::OnBubbleDismiss,
|
| - base::Unretained(this));
|
| - base::Closure link_callback =
|
| - base::Bind(&SuspiciousExtensionBubbleController::OnLinkClicked,
|
| - base::Unretained(this));
|
| - bubble->OnButtonClicked(button_callback);
|
| - bubble->OnLinkClicked(link_callback);
|
| -
|
| - content::RecordAction(
|
| - content::UserMetricsAction("ExtensionWipeoutNotificationShown"));
|
| +void SuspiciousExtensionBubbleController::AcknowledgeExtension(
|
| + const std::string& extension_id,
|
| + ExtensionMessageBubbleController::BubbleAction user_action) {
|
| + ExtensionPrefs* prefs = service_->extension_prefs();
|
| + prefs->SetWipeoutAcknowledged(extension_id, true);
|
| +}
|
|
|
| - bubble->Show();
|
| +void SuspiciousExtensionBubbleController::PerformAction(
|
| + const ExtensionIdList& list) {
|
| + // This bubble solicits no action from the user. Or as Nimoy would have it:
|
| + // "Well, my work here is done".
|
| }
|
|
|
| -base::string16 SuspiciousExtensionBubbleController::GetTitle() {
|
| +base::string16 SuspiciousExtensionBubbleController::GetTitle() const {
|
| return l10n_util::GetStringUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_TITLE);
|
| }
|
|
|
| -base::string16 SuspiciousExtensionBubbleController::GetMessageBody() {
|
| +base::string16 SuspiciousExtensionBubbleController::GetMessageBody() const {
|
| return l10n_util::GetStringFUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_BODY,
|
| l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE));
|
| }
|
|
|
| base::string16 SuspiciousExtensionBubbleController::GetOverflowText(
|
| - const base::string16& overflow_count) {
|
| + const base::string16& overflow_count) const {
|
| base::string16 overflow_string = l10n_util::GetStringUTF16(
|
| IDS_EXTENSIONS_SUSPICIOUS_DISABLED_AND_N_MORE);
|
| base::string16 new_string;
|
| @@ -143,64 +111,46 @@ base::string16 SuspiciousExtensionBubbleController::GetOverflowText(
|
| return new_string;
|
| }
|
|
|
| -base::string16 SuspiciousExtensionBubbleController::GetLearnMoreLabel() {
|
| +base::string16
|
| +SuspiciousExtensionBubbleController::GetLearnMoreLabel() const {
|
| return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
|
| }
|
|
|
| -base::string16 SuspiciousExtensionBubbleController::GetDismissButtonLabel() {
|
| +GURL SuspiciousExtensionBubbleController::GetLearnMoreUrl() const {
|
| + return GURL(chrome::kRemoveNonCWSExtensionURL);
|
| +}
|
| +
|
| +base::string16
|
| +SuspiciousExtensionBubbleController::GetActionButtonLabel() const {
|
| + return string16();
|
| +}
|
| +
|
| +base::string16
|
| +SuspiciousExtensionBubbleController::GetDismissButtonLabel() const {
|
| return l10n_util::GetStringUTF16(IDS_EXTENSIONS_SUSPICIOUS_DISABLED_BUTTON);
|
| }
|
|
|
| -std::vector<base::string16>
|
| -SuspiciousExtensionBubbleController::GetSuspiciousExtensionNames() {
|
| - if (suspicious_extensions_.empty())
|
| - return std::vector<base::string16>();
|
| -
|
| - std::vector<base::string16> return_value;
|
| - for (ExtensionIdList::const_iterator it = suspicious_extensions_.begin();
|
| - it != suspicious_extensions_.end(); ++it) {
|
| - const Extension* extension = service_->GetInstalledExtension(*it);
|
| - if (extension) {
|
| - return_value.push_back(UTF8ToUTF16(extension->name()));
|
| - } else {
|
| - return_value.push_back(
|
| - ASCIIToUTF16(std::string("(unknown name) ") + *it));
|
| - // TODO(finnur): Add this as a string to the grd, for next milestone.
|
| - }
|
| - }
|
| - return return_value;
|
| -}
|
| -
|
| -void SuspiciousExtensionBubbleController::OnBubbleDismiss() {
|
| - content::RecordAction(
|
| - content::UserMetricsAction("SuspiciousExtensionBubbleDismissed"));
|
| - UMA_HISTOGRAM_ENUMERATION("SuspiciousExtensionBubble.UserSelection",
|
| - ACTION_DISMISS, ACTION_BOUNDARY);
|
| - AcknowledgeWipeout();
|
| -}
|
| -
|
| -void SuspiciousExtensionBubbleController::OnLinkClicked() {
|
| - UMA_HISTOGRAM_ENUMERATION("SuspiciousExtensionBubble.UserSelection",
|
| - ACTION_LEARN_MORE, ACTION_BOUNDARY);
|
| - Browser* browser =
|
| - chrome::FindBrowserWithProfile(profile_, chrome::GetActiveDesktop());
|
| - if (browser) {
|
| - browser->OpenURL(
|
| - content::OpenURLParams(GURL(chrome::kChromeUIExtensionsURL),
|
| - content::Referrer(),
|
| - NEW_FOREGROUND_TAB,
|
| - content::PAGE_TRANSITION_LINK,
|
| - false));
|
| - }
|
| - AcknowledgeWipeout();
|
| +bool
|
| +SuspiciousExtensionBubbleController::ShouldShowExtensionList() const {
|
| + return true;
|
| }
|
|
|
| -void SuspiciousExtensionBubbleController::AcknowledgeWipeout() {
|
| - ExtensionPrefs* prefs = service_->extension_prefs();
|
| - for (ExtensionIdList::const_iterator it = suspicious_extensions_.begin();
|
| - it != suspicious_extensions_.end(); ++it) {
|
| - prefs->SetWipeoutAcknowledged(*it, true);
|
| - }
|
| +std::vector<string16>
|
| +SuspiciousExtensionBubbleController::GetExtensions() {
|
| + return GetExtensionList();
|
| +}
|
| +
|
| +void SuspiciousExtensionBubbleController::LogExtensionCount(
|
| + size_t count) {
|
| + UMA_HISTOGRAM_COUNTS_100(
|
| + "ExtensionWipeoutBubble.ExtensionWipeoutCount", count);
|
| +}
|
| +
|
| +void SuspiciousExtensionBubbleController::LogAction(
|
| + ExtensionMessageBubbleController::BubbleAction action) {
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| + "ExtensionWipeoutBubble.UserSelection",
|
| + action, ExtensionMessageBubbleController::ACTION_BOUNDARY);
|
| }
|
|
|
| template <>
|
|
|