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_prefs.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" | 13 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" |
14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
16 #include "chrome/common/chrome_content_client.h" | 16 #include "chrome/common/chrome_content_client.h" |
17 #include "chrome/common/jstemplate_builder.h" | 17 #include "chrome/common/jstemplate_builder.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "content/browser/plugin_service.h" | 19 #include "content/browser/plugin_service.h" |
20 #include "content/browser/renderer_host/render_process_host.h" | 20 #include "content/browser/renderer_host/render_process_host.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 | 108 |
109 string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const { | 109 string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const { |
110 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER); | 110 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER); |
111 } | 111 } |
112 | 112 |
113 void PDFEnableAdobeReaderInfoBarDelegate::OnYes() { | 113 void PDFEnableAdobeReaderInfoBarDelegate::OnYes() { |
114 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); | 114 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); |
115 webkit::npapi::PluginList::Singleton()->EnableGroup(false, | 115 webkit::npapi::PluginList::Singleton()->EnableGroup(false, |
116 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); | 116 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); |
117 PluginUpdater* plugin_updater = PluginUpdater::GetInstance(); | |
118 plugin_updater->EnablePluginGroup(true, | |
119 ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName)); | |
120 Profile* profile = | 117 Profile* profile = |
121 Profile::FromBrowserContext(tab_contents_->browser_context()); | 118 Profile::FromBrowserContext(tab_contents_->browser_context()); |
122 plugin_updater->UpdatePreferences(profile, 0); | 119 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); |
| 120 plugin_prefs->EnablePluginGroup( |
| 121 true, ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName)); |
| 122 plugin_prefs->UpdatePreferences(0); |
123 } | 123 } |
124 | 124 |
125 void PDFEnableAdobeReaderInfoBarDelegate::OnNo() { | 125 void PDFEnableAdobeReaderInfoBarDelegate::OnNo() { |
126 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel")); | 126 UserMetrics::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel")); |
127 } | 127 } |
128 | 128 |
129 // Launch the url to get the latest Adbobe Reader installer. | 129 // Launch the url to get the latest Adbobe Reader installer. |
130 void OpenReaderUpdateURL(TabContents* tab) { | 130 void OpenReaderUpdateURL(TabContents* tab) { |
131 tab->OpenURL(GURL(kReaderUpdateUrl), GURL(), CURRENT_TAB, | 131 tab->OpenURL(GURL(kReaderUpdateUrl), GURL(), CURRENT_TAB, |
132 PageTransition::LINK); | 132 PageTransition::LINK); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 false, &plugin_groups); | 381 false, &plugin_groups); |
382 for (size_t i = 0; i < plugin_groups.size(); ++i) { | 382 for (size_t i = 0; i < plugin_groups.size(); ++i) { |
383 if (plugin_groups[i].GetGroupName() == reader_group_name) { | 383 if (plugin_groups[i].GetGroupName() == reader_group_name) { |
384 reader_group = &plugin_groups[i]; | 384 reader_group = &plugin_groups[i]; |
385 break; | 385 break; |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 tab->AddInfoBar(new PDFUnsupportedFeatureInfoBarDelegate(tab, reader_group)); | 389 tab->AddInfoBar(new PDFUnsupportedFeatureInfoBarDelegate(tab, reader_group)); |
390 } | 390 } |
OLD | NEW |