| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/pdf/pdf_unsupported_feature.h" | 5 #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
| 11 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 11 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 12 #include "chrome/browser/plugins/plugin_metadata.h" | 12 #include "chrome/browser/plugins/plugin_metadata.h" |
| 13 #include "chrome/browser/plugins/plugin_prefs.h" | 13 #include "chrome/browser/plugins/plugin_prefs.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/renderer_preferences_util.h" | 15 #include "chrome/browser/renderer_preferences_util.h" |
| 16 #include "chrome/browser/tab_contents/tab_util.h" | 16 #include "chrome/browser/tab_contents/tab_util.h" |
| 17 #include "chrome/browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h" | |
| 18 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" | |
| 19 #include "chrome/common/chrome_content_client.h" | 17 #include "chrome/common/chrome_content_client.h" |
| 20 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" |
| 20 #include "components/pdf/browser/pdf_web_contents_helper.h" |
| 21 #include "content/public/browser/interstitial_page.h" | 21 #include "content/public/browser/interstitial_page.h" |
| 22 #include "content/public/browser/interstitial_page_delegate.h" | 22 #include "content/public/browser/interstitial_page_delegate.h" |
| 23 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
| 24 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
| 25 #include "content/public/browser/page_navigator.h" | 25 #include "content/public/browser/page_navigator.h" |
| 26 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
| 27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
| 29 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
| 30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 45 using content::WebContents; | 45 using content::WebContents; |
| 46 using content::WebPluginInfo; | 46 using content::WebPluginInfo; |
| 47 | 47 |
| 48 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 const char kAdobeReaderUpdateUrl[] = "http://www.adobe.com/go/getreader_chrome"; | 51 const char kAdobeReaderUpdateUrl[] = "http://www.adobe.com/go/getreader_chrome"; |
| 52 | 52 |
| 53 // The prompt delegate used to ask the user if they want to use Adobe Reader | 53 // The prompt delegate used to ask the user if they want to use Adobe Reader |
| 54 // by default. | 54 // by default. |
| 55 class PDFEnableAdobeReaderPromptDelegate | 55 class PDFEnableAdobeReaderPromptClient |
| 56 : public OpenPDFInReaderPromptDelegate { | 56 : public pdf::OpenPDFInReaderPromptClient { |
| 57 public: | 57 public: |
| 58 explicit PDFEnableAdobeReaderPromptDelegate(Profile* profile); | 58 explicit PDFEnableAdobeReaderPromptClient(Profile* profile); |
| 59 virtual ~PDFEnableAdobeReaderPromptDelegate(); | 59 virtual ~PDFEnableAdobeReaderPromptClient(); |
| 60 | 60 |
| 61 // OpenPDFInReaderPromptDelegate | 61 // pdf::OpenPDFInReaderPromptClient |
| 62 virtual base::string16 GetMessageText() const OVERRIDE; | 62 virtual base::string16 GetMessageText() const OVERRIDE; |
| 63 virtual base::string16 GetAcceptButtonText() const OVERRIDE; | 63 virtual base::string16 GetAcceptButtonText() const OVERRIDE; |
| 64 virtual base::string16 GetCancelButtonText() const OVERRIDE; | 64 virtual base::string16 GetCancelButtonText() const OVERRIDE; |
| 65 virtual bool ShouldExpire( | 65 virtual bool ShouldExpire( |
| 66 const content::LoadCommittedDetails& details) const OVERRIDE; | 66 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 67 virtual void Accept() OVERRIDE; | 67 virtual void Accept() OVERRIDE; |
| 68 virtual void Cancel() OVERRIDE; | 68 virtual void Cancel() OVERRIDE; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 void OnYes(); | 71 void OnYes(); |
| 72 void OnNo(); | 72 void OnNo(); |
| 73 | 73 |
| 74 Profile* profile_; | 74 Profile* profile_; |
| 75 | 75 |
| 76 DISALLOW_IMPLICIT_CONSTRUCTORS(PDFEnableAdobeReaderPromptDelegate); | 76 DISALLOW_IMPLICIT_CONSTRUCTORS(PDFEnableAdobeReaderPromptClient); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 PDFEnableAdobeReaderPromptDelegate::PDFEnableAdobeReaderPromptDelegate( | 79 PDFEnableAdobeReaderPromptClient::PDFEnableAdobeReaderPromptClient( |
| 80 Profile* profile) | 80 Profile* profile) |
| 81 : profile_(profile) { | 81 : profile_(profile) { |
| 82 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarShown")); | 82 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarShown")); |
| 83 } | 83 } |
| 84 | 84 |
| 85 PDFEnableAdobeReaderPromptDelegate::~PDFEnableAdobeReaderPromptDelegate() { | 85 PDFEnableAdobeReaderPromptClient::~PDFEnableAdobeReaderPromptClient() { |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool PDFEnableAdobeReaderPromptDelegate::ShouldExpire( | 88 bool PDFEnableAdobeReaderPromptClient::ShouldExpire( |
| 89 const content::LoadCommittedDetails& details) const { | 89 const content::LoadCommittedDetails& details) const { |
| 90 content::PageTransition transition = | 90 content::PageTransition transition = |
| 91 content::PageTransitionStripQualifier(details.entry->GetTransitionType()); | 91 content::PageTransitionStripQualifier(details.entry->GetTransitionType()); |
| 92 // We don't want to expire on a reload, because that is how we open the PDF in | 92 // We don't want to expire on a reload, because that is how we open the PDF in |
| 93 // Reader. | 93 // Reader. |
| 94 return !details.is_in_page && transition != content::PAGE_TRANSITION_RELOAD; | 94 return !details.is_in_page && transition != content::PAGE_TRANSITION_RELOAD; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void PDFEnableAdobeReaderPromptDelegate::Accept() { | 97 void PDFEnableAdobeReaderPromptClient::Accept() { |
| 98 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); | 98 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); |
| 99 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile_).get(); | 99 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile_).get(); |
| 100 plugin_prefs->EnablePluginGroup( | 100 plugin_prefs->EnablePluginGroup( |
| 101 true, base::ASCIIToUTF16(PluginMetadata::kAdobeReaderGroupName)); | 101 true, base::ASCIIToUTF16(PluginMetadata::kAdobeReaderGroupName)); |
| 102 plugin_prefs->EnablePluginGroup( | 102 plugin_prefs->EnablePluginGroup( |
| 103 false, base::ASCIIToUTF16(ChromeContentClient::kPDFPluginName)); | 103 false, base::ASCIIToUTF16(ChromeContentClient::kPDFPluginName)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void PDFEnableAdobeReaderPromptDelegate::Cancel() { | 106 void PDFEnableAdobeReaderPromptClient::Cancel() { |
| 107 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel")); | 107 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel")); |
| 108 } | 108 } |
| 109 | 109 |
| 110 base::string16 PDFEnableAdobeReaderPromptDelegate::GetAcceptButtonText() const { | 110 base::string16 PDFEnableAdobeReaderPromptClient::GetAcceptButtonText() const { |
| 111 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_ALWAYS_USE_READER_BUTTON); | 111 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_ALWAYS_USE_READER_BUTTON); |
| 112 } | 112 } |
| 113 | 113 |
| 114 base::string16 PDFEnableAdobeReaderPromptDelegate::GetCancelButtonText() const { | 114 base::string16 PDFEnableAdobeReaderPromptClient::GetCancelButtonText() const { |
| 115 return l10n_util::GetStringUTF16(IDS_DONE); | 115 return l10n_util::GetStringUTF16(IDS_DONE); |
| 116 } | 116 } |
| 117 | 117 |
| 118 base::string16 PDFEnableAdobeReaderPromptDelegate::GetMessageText() const { | 118 base::string16 PDFEnableAdobeReaderPromptClient::GetMessageText() const { |
| 119 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER); | 119 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Launch the url to get the latest Adbobe Reader installer. | 122 // Launch the url to get the latest Adbobe Reader installer. |
| 123 void OpenReaderUpdateURL(WebContents* web_contents) { | 123 void OpenReaderUpdateURL(WebContents* web_contents) { |
| 124 OpenURLParams params( | 124 OpenURLParams params( |
| 125 GURL(kAdobeReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB, | 125 GURL(kAdobeReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB, |
| 126 content::PAGE_TRANSITION_LINK, false); | 126 content::PAGE_TRANSITION_LINK, false); |
| 127 web_contents->OpenURL(params); | 127 web_contents->OpenURL(params); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Opens the PDF using Adobe Reader. | 130 // Opens the PDF using Adobe Reader. |
| 131 void OpenUsingReader(WebContents* web_contents, | 131 void OpenUsingReader(WebContents* web_contents, |
| 132 const WebPluginInfo& reader_plugin, | 132 const WebPluginInfo& reader_plugin, |
| 133 OpenPDFInReaderPromptDelegate* delegate) { | 133 pdf::OpenPDFInReaderPromptClient* client) { |
| 134 ChromePluginServiceFilter::GetInstance()->OverridePluginForFrame( | 134 ChromePluginServiceFilter::GetInstance()->OverridePluginForFrame( |
| 135 web_contents->GetRenderProcessHost()->GetID(), | 135 web_contents->GetRenderProcessHost()->GetID(), |
| 136 web_contents->GetMainFrame()->GetRoutingID(), | 136 web_contents->GetMainFrame()->GetRoutingID(), |
| 137 web_contents->GetURL(), | 137 web_contents->GetURL(), |
| 138 reader_plugin); | 138 reader_plugin); |
| 139 web_contents->ReloadFocusedFrame(false); | 139 web_contents->ReloadFocusedFrame(false); |
| 140 | 140 |
| 141 PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents); | 141 pdf::PDFWebContentsHelper* pdf_tab_helper = |
| 142 if (delegate) | 142 pdf::PDFWebContentsHelper::FromWebContents(web_contents); |
| 143 pdf_tab_helper->ShowOpenInReaderPrompt(make_scoped_ptr(delegate)); | 143 if (client) |
| 144 pdf_tab_helper->ShowOpenInReaderPrompt(make_scoped_ptr(client)); |
| 144 } | 145 } |
| 145 | 146 |
| 146 // An interstitial to be used when the user chooses to open a PDF using Adobe | 147 // An interstitial to be used when the user chooses to open a PDF using Adobe |
| 147 // Reader, but it is out of date. | 148 // Reader, but it is out of date. |
| 148 class PDFUnsupportedFeatureInterstitial | 149 class PDFUnsupportedFeatureInterstitial |
| 149 : public content::InterstitialPageDelegate { | 150 : public content::InterstitialPageDelegate { |
| 150 public: | 151 public: |
| 151 PDFUnsupportedFeatureInterstitial( | 152 PDFUnsupportedFeatureInterstitial( |
| 152 WebContents* web_contents, | 153 WebContents* web_contents, |
| 153 const WebPluginInfo& reader_webplugininfo) | 154 const WebPluginInfo& reader_webplugininfo) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 private: | 224 private: |
| 224 WebContents* web_contents_; | 225 WebContents* web_contents_; |
| 225 WebPluginInfo reader_webplugininfo_; | 226 WebPluginInfo reader_webplugininfo_; |
| 226 InterstitialPage* interstitial_page_; // Owns us. | 227 InterstitialPage* interstitial_page_; // Owns us. |
| 227 | 228 |
| 228 DISALLOW_COPY_AND_ASSIGN(PDFUnsupportedFeatureInterstitial); | 229 DISALLOW_COPY_AND_ASSIGN(PDFUnsupportedFeatureInterstitial); |
| 229 }; | 230 }; |
| 230 | 231 |
| 231 // The delegate for the bubble used to inform the user that we don't support a | 232 // The delegate for the bubble used to inform the user that we don't support a |
| 232 // feature in the PDF. | 233 // feature in the PDF. |
| 233 class PDFUnsupportedFeaturePromptDelegate | 234 class PDFUnsupportedFeaturePromptClient |
| 234 : public OpenPDFInReaderPromptDelegate { | 235 : public pdf::OpenPDFInReaderPromptClient { |
| 235 public: | 236 public: |
| 236 PDFUnsupportedFeaturePromptDelegate( | 237 PDFUnsupportedFeaturePromptClient(WebContents* web_contents, |
| 237 WebContents* web_contents, | 238 const AdobeReaderPluginInfo& reader_info); |
| 238 const AdobeReaderPluginInfo& reader_info); | 239 virtual ~PDFUnsupportedFeaturePromptClient(); |
| 239 virtual ~PDFUnsupportedFeaturePromptDelegate(); | |
| 240 | 240 |
| 241 // OpenPDFInReaderPromptDelegate: | 241 // pdf::OpenPDFInReaderPromptClient: |
| 242 virtual base::string16 GetMessageText() const OVERRIDE; | 242 virtual base::string16 GetMessageText() const OVERRIDE; |
| 243 virtual base::string16 GetAcceptButtonText() const OVERRIDE; | 243 virtual base::string16 GetAcceptButtonText() const OVERRIDE; |
| 244 virtual base::string16 GetCancelButtonText() const OVERRIDE; | 244 virtual base::string16 GetCancelButtonText() const OVERRIDE; |
| 245 virtual bool ShouldExpire( | 245 virtual bool ShouldExpire( |
| 246 const content::LoadCommittedDetails& details) const OVERRIDE; | 246 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 247 virtual void Accept() OVERRIDE; | 247 virtual void Accept() OVERRIDE; |
| 248 virtual void Cancel() OVERRIDE; | 248 virtual void Cancel() OVERRIDE; |
| 249 | 249 |
| 250 private: | 250 private: |
| 251 WebContents* web_contents_; | 251 WebContents* web_contents_; |
| 252 const AdobeReaderPluginInfo reader_info_; | 252 const AdobeReaderPluginInfo reader_info_; |
| 253 | 253 |
| 254 DISALLOW_IMPLICIT_CONSTRUCTORS(PDFUnsupportedFeaturePromptDelegate); | 254 DISALLOW_IMPLICIT_CONSTRUCTORS(PDFUnsupportedFeaturePromptClient); |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 PDFUnsupportedFeaturePromptDelegate::PDFUnsupportedFeaturePromptDelegate( | 257 PDFUnsupportedFeaturePromptClient::PDFUnsupportedFeaturePromptClient( |
| 258 WebContents* web_contents, | 258 WebContents* web_contents, |
| 259 const AdobeReaderPluginInfo& reader_info) | 259 const AdobeReaderPluginInfo& reader_info) |
| 260 : web_contents_(web_contents), | 260 : web_contents_(web_contents), reader_info_(reader_info) { |
| 261 reader_info_(reader_info) { | |
| 262 content::RecordAction(reader_info_.is_installed ? | 261 content::RecordAction(reader_info_.is_installed ? |
| 263 UserMetricsAction("PDF_UseReaderInfoBarShown") : | 262 UserMetricsAction("PDF_UseReaderInfoBarShown") : |
| 264 UserMetricsAction("PDF_InstallReaderInfoBarShown")); | 263 UserMetricsAction("PDF_InstallReaderInfoBarShown")); |
| 265 } | 264 } |
| 266 | 265 |
| 267 PDFUnsupportedFeaturePromptDelegate::~PDFUnsupportedFeaturePromptDelegate() { | 266 PDFUnsupportedFeaturePromptClient::~PDFUnsupportedFeaturePromptClient() { |
| 268 } | 267 } |
| 269 | 268 |
| 270 base::string16 PDFUnsupportedFeaturePromptDelegate::GetMessageText() const { | 269 base::string16 PDFUnsupportedFeaturePromptClient::GetMessageText() const { |
| 271 return l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_MESSAGE); | 270 return l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_MESSAGE); |
| 272 } | 271 } |
| 273 | 272 |
| 274 base::string16 PDFUnsupportedFeaturePromptDelegate::GetAcceptButtonText() | 273 base::string16 PDFUnsupportedFeaturePromptClient::GetAcceptButtonText() const { |
| 275 const { | |
| 276 if (base::win::IsMetroProcess()) | 274 if (base::win::IsMetroProcess()) |
| 277 return l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_METRO_MODE_LINK); | 275 return l10n_util::GetStringUTF16(IDS_PDF_BUBBLE_METRO_MODE_LINK); |
| 278 | 276 |
| 279 return l10n_util::GetStringUTF16( | 277 return l10n_util::GetStringUTF16( |
| 280 reader_info_.is_installed ? IDS_PDF_BUBBLE_OPEN_IN_READER_LINK | 278 reader_info_.is_installed ? IDS_PDF_BUBBLE_OPEN_IN_READER_LINK |
| 281 : IDS_PDF_BUBBLE_INSTALL_READER_LINK); | 279 : IDS_PDF_BUBBLE_INSTALL_READER_LINK); |
| 282 } | 280 } |
| 283 | 281 |
| 284 base::string16 PDFUnsupportedFeaturePromptDelegate::GetCancelButtonText() | 282 base::string16 PDFUnsupportedFeaturePromptClient::GetCancelButtonText() const { |
| 285 const { | |
| 286 return l10n_util::GetStringUTF16(IDS_DONE); | 283 return l10n_util::GetStringUTF16(IDS_DONE); |
| 287 } | 284 } |
| 288 | 285 |
| 289 bool PDFUnsupportedFeaturePromptDelegate::ShouldExpire( | 286 bool PDFUnsupportedFeaturePromptClient::ShouldExpire( |
| 290 const content::LoadCommittedDetails& details) const { | 287 const content::LoadCommittedDetails& details) const { |
| 291 return !details.is_in_page; | 288 return !details.is_in_page; |
| 292 } | 289 } |
| 293 | 290 |
| 294 void PDFUnsupportedFeaturePromptDelegate::Accept() { | 291 void PDFUnsupportedFeaturePromptClient::Accept() { |
| 295 if (base::win::IsMetroProcess()) { | 292 if (base::win::IsMetroProcess()) { |
| 296 chrome::AttemptRestartWithModeSwitch(); | 293 chrome::AttemptRestartWithModeSwitch(); |
| 297 return; | 294 return; |
| 298 } | 295 } |
| 299 | 296 |
| 300 if (!reader_info_.is_installed) { | 297 if (!reader_info_.is_installed) { |
| 301 content::RecordAction(UserMetricsAction("PDF_InstallReaderInfoBarOK")); | 298 content::RecordAction(UserMetricsAction("PDF_InstallReaderInfoBarOK")); |
| 302 OpenReaderUpdateURL(web_contents_); | 299 OpenReaderUpdateURL(web_contents_); |
| 303 return; | 300 return; |
| 304 } | 301 } |
| 305 | 302 |
| 306 content::RecordAction(UserMetricsAction("PDF_UseReaderInfoBarOK")); | 303 content::RecordAction(UserMetricsAction("PDF_UseReaderInfoBarOK")); |
| 307 | 304 |
| 308 if (!reader_info_.is_secure) { | 305 if (!reader_info_.is_secure) { |
| 309 new PDFUnsupportedFeatureInterstitial(web_contents_, | 306 new PDFUnsupportedFeatureInterstitial(web_contents_, |
| 310 reader_info_.plugin_info); | 307 reader_info_.plugin_info); |
| 311 return; | 308 return; |
| 312 } | 309 } |
| 313 | 310 |
| 314 Profile* profile = | 311 Profile* profile = |
| 315 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 312 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 316 OpenPDFInReaderPromptDelegate* delegate = | 313 pdf::OpenPDFInReaderPromptClient* client = |
| 317 new PDFEnableAdobeReaderPromptDelegate(profile); | 314 new PDFEnableAdobeReaderPromptClient(profile); |
| 318 | 315 |
| 319 OpenUsingReader(web_contents_, reader_info_.plugin_info, delegate); | 316 OpenUsingReader(web_contents_, reader_info_.plugin_info, client); |
| 320 } | 317 } |
| 321 | 318 |
| 322 void PDFUnsupportedFeaturePromptDelegate::Cancel() { | 319 void PDFUnsupportedFeaturePromptClient::Cancel() { |
| 323 content::RecordAction(reader_info_.is_installed ? | 320 content::RecordAction(reader_info_.is_installed ? |
| 324 UserMetricsAction("PDF_UseReaderInfoBarCancel") : | 321 UserMetricsAction("PDF_UseReaderInfoBarCancel") : |
| 325 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); | 322 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); |
| 326 } | 323 } |
| 327 | 324 |
| 328 void MaybeShowOpenPDFInReaderPrompt(WebContents* web_contents, | 325 void MaybeShowOpenPDFInReaderPrompt(WebContents* web_contents, |
| 329 const AdobeReaderPluginInfo& reader_info) { | 326 const AdobeReaderPluginInfo& reader_info) { |
| 330 // If the Reader plugin is disabled by policy, don't prompt them. | 327 // If the Reader plugin is disabled by policy, don't prompt them. |
| 331 if (!reader_info.is_installed || !reader_info.is_enabled) | 328 if (!reader_info.is_installed || !reader_info.is_enabled) |
| 332 return; | 329 return; |
| 333 | 330 |
| 334 scoped_ptr<OpenPDFInReaderPromptDelegate> prompt( | 331 scoped_ptr<pdf::OpenPDFInReaderPromptClient> prompt( |
| 335 new PDFUnsupportedFeaturePromptDelegate(web_contents, reader_info)); | 332 new PDFUnsupportedFeaturePromptClient(web_contents, reader_info)); |
| 336 PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents); | 333 pdf::PDFWebContentsHelper* pdf_tab_helper = |
| 334 pdf::PDFWebContentsHelper::FromWebContents(web_contents); |
| 337 pdf_tab_helper->ShowOpenInReaderPrompt(prompt.Pass()); | 335 pdf_tab_helper->ShowOpenInReaderPrompt(prompt.Pass()); |
| 338 } | 336 } |
| 339 | 337 |
| 340 void GotPluginsCallback(int process_id, | 338 void GotPluginsCallback(int process_id, |
| 341 int routing_id, | 339 int routing_id, |
| 342 const AdobeReaderPluginInfo& reader_info) { | 340 const AdobeReaderPluginInfo& reader_info) { |
| 343 WebContents* web_contents = | 341 WebContents* web_contents = |
| 344 tab_util::GetWebContentsByID(process_id, routing_id); | 342 tab_util::GetWebContentsByID(process_id, routing_id); |
| 345 if (web_contents) | 343 if (web_contents) |
| 346 MaybeShowOpenPDFInReaderPrompt(web_contents, reader_info); | 344 MaybeShowOpenPDFInReaderPrompt(web_contents, reader_info); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 360 MaybeShowOpenPDFInReaderPrompt(web_contents, reader_info); | 358 MaybeShowOpenPDFInReaderPrompt(web_contents, reader_info); |
| 361 return; | 359 return; |
| 362 } | 360 } |
| 363 GetAdobeReaderPluginInfoAsync( | 361 GetAdobeReaderPluginInfoAsync( |
| 364 profile, | 362 profile, |
| 365 base::Bind(&GotPluginsCallback, | 363 base::Bind(&GotPluginsCallback, |
| 366 web_contents->GetRenderProcessHost()->GetID(), | 364 web_contents->GetRenderProcessHost()->GetID(), |
| 367 web_contents->GetRenderViewHost()->GetRoutingID())); | 365 web_contents->GetRenderViewHost()->GetRoutingID())); |
| 368 #endif // defined(OS_WIN) | 366 #endif // defined(OS_WIN) |
| 369 } | 367 } |
| OLD | NEW |