| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pdf_unsupported_feature.h" | 5 #include "chrome/browser/pdf_unsupported_feature.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "base/version.h" | 9 #include "base/version.h" |
| 10 #include "chrome/browser/plugin_updater.h" | 10 #include "chrome/browser/plugin_updater.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 void PDFEnableAdobeReaderInfoBarDelegate::InfoBarDismissed() { | 79 void PDFEnableAdobeReaderInfoBarDelegate::InfoBarDismissed() { |
| 80 OnNo(); | 80 OnNo(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 InfoBarDelegate::Type | 83 InfoBarDelegate::Type |
| 84 PDFEnableAdobeReaderInfoBarDelegate::GetInfoBarType() const { | 84 PDFEnableAdobeReaderInfoBarDelegate::GetInfoBarType() const { |
| 85 return PAGE_ACTION_TYPE; | 85 return PAGE_ACTION_TYPE; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool PDFEnableAdobeReaderInfoBarDelegate::Accept() { | 88 bool PDFEnableAdobeReaderInfoBarDelegate::Accept() { |
| 89 tab_contents_->profile()->GetPrefs()->SetBoolean( | 89 Profile* profile = static_cast<Profile*>(tab_contents_->context()); |
| 90 prefs::kPluginsShowSetReaderDefaultInfobar, false); | 90 profile->GetPrefs()->SetBoolean(prefs::kPluginsShowSetReaderDefaultInfobar, |
| 91 false); |
| 91 OnNo(); | 92 OnNo(); |
| 92 return true; | 93 return true; |
| 93 } | 94 } |
| 94 | 95 |
| 95 bool PDFEnableAdobeReaderInfoBarDelegate::Cancel() { | 96 bool PDFEnableAdobeReaderInfoBarDelegate::Cancel() { |
| 96 OnYes(); | 97 OnYes(); |
| 97 return true; | 98 return true; |
| 98 } | 99 } |
| 99 | 100 |
| 100 string16 PDFEnableAdobeReaderInfoBarDelegate::GetButtonLabel( | 101 string16 PDFEnableAdobeReaderInfoBarDelegate::GetButtonLabel( |
| 101 InfoBarButton button) const { | 102 InfoBarButton button) const { |
| 102 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 103 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 103 IDS_PDF_INFOBAR_NEVER_USE_READER_BUTTON : | 104 IDS_PDF_INFOBAR_NEVER_USE_READER_BUTTON : |
| 104 IDS_PDF_INFOBAR_ALWAYS_USE_READER_BUTTON); | 105 IDS_PDF_INFOBAR_ALWAYS_USE_READER_BUTTON); |
| 105 } | 106 } |
| 106 | 107 |
| 107 string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const { | 108 string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const { |
| 108 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER); | 109 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void PDFEnableAdobeReaderInfoBarDelegate::OnYes() { | 112 void PDFEnableAdobeReaderInfoBarDelegate::OnYes() { |
| 112 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); | 113 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); |
| 113 webkit::npapi::PluginList::Singleton()->EnableGroup(false, | 114 webkit::npapi::PluginList::Singleton()->EnableGroup(false, |
| 114 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); | 115 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); |
| 115 PluginUpdater* plugin_updater = PluginUpdater::GetInstance(); | 116 PluginUpdater* plugin_updater = PluginUpdater::GetInstance(); |
| 116 plugin_updater->EnablePluginGroup(true, | 117 plugin_updater->EnablePluginGroup(true, |
| 117 ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName)); | 118 ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName)); |
| 118 plugin_updater->UpdatePreferences(tab_contents_->profile(), 0); | 119 Profile* profile = static_cast<Profile*>(tab_contents_->context()); |
| 120 plugin_updater->UpdatePreferences(profile, 0); |
| 119 } | 121 } |
| 120 | 122 |
| 121 void PDFEnableAdobeReaderInfoBarDelegate::OnNo() { | 123 void PDFEnableAdobeReaderInfoBarDelegate::OnNo() { |
| 122 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel")); | 124 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel")); |
| 123 } | 125 } |
| 124 | 126 |
| 125 // Launch the url to get the latest Adbobe Reader installer. | 127 // Launch the url to get the latest Adbobe Reader installer. |
| 126 void OpenReaderUpdateURL(TabContents* tab) { | 128 void OpenReaderUpdateURL(TabContents* tab) { |
| 127 tab->OpenURL(GURL(kReaderUpdateUrl), GURL(), CURRENT_TAB, | 129 tab->OpenURL(GURL(kReaderUpdateUrl), GURL(), CURRENT_TAB, |
| 128 PageTransition::LINK); | 130 PageTransition::LINK); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 false, &plugin_groups); | 378 false, &plugin_groups); |
| 377 for (size_t i = 0; i < plugin_groups.size(); ++i) { | 379 for (size_t i = 0; i < plugin_groups.size(); ++i) { |
| 378 if (plugin_groups[i].GetGroupName() == reader_group_name) { | 380 if (plugin_groups[i].GetGroupName() == reader_group_name) { |
| 379 reader_group = &plugin_groups[i]; | 381 reader_group = &plugin_groups[i]; |
| 380 break; | 382 break; |
| 381 } | 383 } |
| 382 } | 384 } |
| 383 | 385 |
| 384 tab->AddInfoBar(new PDFUnsupportedFeatureInfoBarDelegate(tab, reader_group)); | 386 tab->AddInfoBar(new PDFUnsupportedFeatureInfoBarDelegate(tab, reader_group)); |
| 385 } | 387 } |
| OLD | NEW |