summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-27 07:05:21 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-27 07:05:21 +0000
commitacadd8fd77dd19841cdb392fab5e8705d4fbb282 (patch)
tree7576736366e8a21380f0929ac7f31428910b9461
parentd12dcdd649f0f1181ecae1f0f567c6a453a5a96d (diff)
downloadchromium_src-acadd8fd77dd19841cdb392fab5e8705d4fbb282.zip
chromium_src-acadd8fd77dd19841cdb392fab5e8705d4fbb282.tar.gz
chromium_src-acadd8fd77dd19841cdb392fab5e8705d4fbb282.tar.bz2
Reverse the Yes and No buttons for the PDF infobars.
Review URL: http://codereview.chromium.org/6320018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72767 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/pdf_unsupported_feature.cc106
1 files changed, 62 insertions, 44 deletions
diff --git a/chrome/browser/pdf_unsupported_feature.cc b/chrome/browser/pdf_unsupported_feature.cc
index 66a9122..01dc6d8 100644
--- a/chrome/browser/pdf_unsupported_feature.cc
+++ b/chrome/browser/pdf_unsupported_feature.cc
@@ -34,7 +34,8 @@ static const uint16 kMinReaderVersionToUse = 10;
namespace {
// The info bar delegate used to ask the user if they want to use Adobe Reader
-// by default.
+// by default. We want the infobar to have [No][Yes], so we swap the text on
+// the buttons, and the meaning of the delegate callbacks.
class PDFEnableAdobeReaderConfirmInfoBarDelegate
: public ConfirmInfoBarDelegate {
public:
@@ -51,7 +52,7 @@ class PDFEnableAdobeReaderConfirmInfoBarDelegate
}
virtual void InfoBarDismissed() {
- Cancel();
+ OnNo();
}
virtual Type GetInfoBarType() const {
@@ -59,19 +60,11 @@ class PDFEnableAdobeReaderConfirmInfoBarDelegate
}
virtual bool Accept() {
- UserMetrics::RecordAction(
- UserMetricsAction("PDF_EnableReaderInfoBarOK"));
- webkit::npapi::PluginList::Singleton()->EnableGroup(
- false, ASCIIToUTF16(PepperPluginRegistry::kPDFPluginName));
- webkit::npapi::PluginList::Singleton()->EnableGroup(
- true, ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName));
- return true;
+ return OnNo();
}
virtual bool Cancel() {
- UserMetrics::RecordAction(
- UserMetricsAction("PDF_EnableReaderInfoBarCancel"));
- return true;
+ return OnYes();
}
virtual int GetButtons() const {
@@ -82,10 +75,10 @@ class PDFEnableAdobeReaderConfirmInfoBarDelegate
switch (button) {
case BUTTON_OK:
return l10n_util::GetStringUTF16(
- IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL);
+ IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL);
case BUTTON_CANCEL:
return l10n_util::GetStringUTF16(
- IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL);
+ IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL);
default:
// All buttons are labeled above.
NOTREACHED() << "Bad button id " << button;
@@ -99,6 +92,22 @@ class PDFEnableAdobeReaderConfirmInfoBarDelegate
}
private:
+ bool OnYes() {
+ UserMetrics::RecordAction(
+ UserMetricsAction("PDF_EnableReaderInfoBarOK"));
+ webkit::npapi::PluginList::Singleton()->EnableGroup(
+ false, ASCIIToUTF16(PepperPluginRegistry::kPDFPluginName));
+ webkit::npapi::PluginList::Singleton()->EnableGroup(
+ true, ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName));
+ return true;
+ }
+
+ bool OnNo() {
+ UserMetrics::RecordAction(
+ UserMetricsAction("PDF_EnableReaderInfoBarCancel"));
+ return true;
+ }
+
DISALLOW_IMPLICIT_CONSTRUCTORS(PDFEnableAdobeReaderConfirmInfoBarDelegate);
};
@@ -206,7 +215,8 @@ class PDFUnsupportedFeatureInterstitial : public InterstitialPage {
};
// The info bar delegate used to inform the user that we don't support a feature
-// in the PDF.
+// in the PDF. See the comment about how we swap buttons for
+// PDFEnableAdobeReaderConfirmInfoBarDelegate.
class PDFUnsupportedFeatureConfirmInfoBarDelegate
: public ConfirmInfoBarDelegate {
public:
@@ -244,7 +254,7 @@ class PDFUnsupportedFeatureConfirmInfoBarDelegate
}
virtual void InfoBarDismissed() {
- Cancel();
+ OnNo();
}
virtual Type GetInfoBarType() const {
@@ -252,7 +262,41 @@ class PDFUnsupportedFeatureConfirmInfoBarDelegate
}
virtual bool Accept() {
- if (!reader_installed_) {
+ return OnNo();
+ }
+
+ virtual bool Cancel() {
+ return OnYes();
+ }
+
+ virtual int GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+ }
+
+ virtual string16 GetButtonLabel(InfoBarButton button) const {
+ switch (button) {
+ case BUTTON_OK:
+ return l10n_util::GetStringUTF16(
+ IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL);
+ case BUTTON_CANCEL:
+ return l10n_util::GetStringUTF16(
+ IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL);
+ default:
+ // All buttons are labeled above.
+ NOTREACHED() << "Bad button id " << button;
+ return string16();
+ }
+ }
+
+ virtual string16 GetMessageText() const {
+ return l10n_util::GetStringUTF16(reader_installed_ ?
+ IDS_PDF_INFOBAR_QUESTION_READER_INSTALLED :
+ IDS_PDF_INFOBAR_QUESTION_READER_NOT_INSTALLED);
+ }
+
+ private:
+ bool OnYes() {
+ if (!reader_installed_) {
UserMetrics::RecordAction(
UserMetricsAction("PDF_InstallReaderInfoBarOK"));
OpenReaderUpdateURL(tab_contents_);
@@ -274,7 +318,7 @@ class PDFUnsupportedFeatureConfirmInfoBarDelegate
return false;
}
- virtual bool Cancel() {
+ bool OnNo() {
if (reader_installed_) {
UserMetrics::RecordAction(
UserMetricsAction("PDF_UseReaderInfoBarCancel"));
@@ -285,32 +329,6 @@ class PDFUnsupportedFeatureConfirmInfoBarDelegate
return true;
}
- virtual int GetButtons() const {
- return BUTTON_OK | BUTTON_CANCEL;
- }
-
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- switch (button) {
- case BUTTON_OK:
- return l10n_util::GetStringUTF16(
- IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL);
- case BUTTON_CANCEL:
- return l10n_util::GetStringUTF16(
- IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL);
- default:
- // All buttons are labeled above.
- NOTREACHED() << "Bad button id " << button;
- return string16();
- }
- }
-
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringUTF16(reader_installed_ ?
- IDS_PDF_INFOBAR_QUESTION_READER_INSTALLED :
- IDS_PDF_INFOBAR_QUESTION_READER_NOT_INSTALLED);
- }
-
- private:
TabContents* tab_contents_;
bool reader_installed_;
bool reader_vulnerable_;