| 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 <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" | 15 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 16 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 16 #include "chrome/browser/plugins/plugin_metadata.h" | 17 #include "chrome/browser/plugins/plugin_metadata.h" |
| 17 #include "chrome/browser/plugins/plugin_prefs.h" | 18 #include "chrome/browser/plugins/plugin_prefs.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/renderer_preferences_util.h" | 20 #include "chrome/browser/renderer_preferences_util.h" |
| 20 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
| 21 #include "chrome/common/chrome_content_client.h" | 22 #include "chrome/common/chrome_content_client.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ChromePluginServiceFilter::GetInstance()->OverridePluginForFrame( | 140 ChromePluginServiceFilter::GetInstance()->OverridePluginForFrame( |
| 140 web_contents->GetRenderProcessHost()->GetID(), | 141 web_contents->GetRenderProcessHost()->GetID(), |
| 141 web_contents->GetMainFrame()->GetRoutingID(), | 142 web_contents->GetMainFrame()->GetRoutingID(), |
| 142 web_contents->GetURL(), | 143 web_contents->GetURL(), |
| 143 reader_plugin); | 144 reader_plugin); |
| 144 web_contents->ReloadFocusedFrame(false); | 145 web_contents->ReloadFocusedFrame(false); |
| 145 | 146 |
| 146 pdf::PDFWebContentsHelper* pdf_tab_helper = | 147 pdf::PDFWebContentsHelper* pdf_tab_helper = |
| 147 pdf::PDFWebContentsHelper::FromWebContents(web_contents); | 148 pdf::PDFWebContentsHelper::FromWebContents(web_contents); |
| 148 if (client) | 149 if (client) |
| 149 pdf_tab_helper->ShowOpenInReaderPrompt(make_scoped_ptr(client)); | 150 pdf_tab_helper->ShowOpenInReaderPrompt(base::WrapUnique(client)); |
| 150 } | 151 } |
| 151 | 152 |
| 152 // An interstitial to be used when the user chooses to open a PDF using Adobe | 153 // An interstitial to be used when the user chooses to open a PDF using Adobe |
| 153 // Reader, but it is out of date. | 154 // Reader, but it is out of date. |
| 154 class PDFUnsupportedFeatureInterstitial | 155 class PDFUnsupportedFeatureInterstitial |
| 155 : public content::InterstitialPageDelegate { | 156 : public content::InterstitialPageDelegate { |
| 156 public: | 157 public: |
| 157 PDFUnsupportedFeatureInterstitial( | 158 PDFUnsupportedFeatureInterstitial( |
| 158 WebContents* web_contents, | 159 WebContents* web_contents, |
| 159 const WebPluginInfo& reader_webplugininfo) | 160 const WebPluginInfo& reader_webplugininfo) |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 UserMetricsAction("PDF_UseReaderInfoBarCancel") : | 319 UserMetricsAction("PDF_UseReaderInfoBarCancel") : |
| 319 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); | 320 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); |
| 320 } | 321 } |
| 321 | 322 |
| 322 void MaybeShowOpenPDFInReaderPrompt(WebContents* web_contents, | 323 void MaybeShowOpenPDFInReaderPrompt(WebContents* web_contents, |
| 323 const AdobeReaderPluginInfo& reader_info) { | 324 const AdobeReaderPluginInfo& reader_info) { |
| 324 // If the Reader plugin is disabled by policy, don't prompt them. | 325 // If the Reader plugin is disabled by policy, don't prompt them. |
| 325 if (!reader_info.is_installed || !reader_info.is_enabled) | 326 if (!reader_info.is_installed || !reader_info.is_enabled) |
| 326 return; | 327 return; |
| 327 | 328 |
| 328 scoped_ptr<pdf::OpenPDFInReaderPromptClient> prompt( | 329 std::unique_ptr<pdf::OpenPDFInReaderPromptClient> prompt( |
| 329 new PDFUnsupportedFeaturePromptClient(web_contents, reader_info)); | 330 new PDFUnsupportedFeaturePromptClient(web_contents, reader_info)); |
| 330 pdf::PDFWebContentsHelper* pdf_tab_helper = | 331 pdf::PDFWebContentsHelper* pdf_tab_helper = |
| 331 pdf::PDFWebContentsHelper::FromWebContents(web_contents); | 332 pdf::PDFWebContentsHelper::FromWebContents(web_contents); |
| 332 pdf_tab_helper->ShowOpenInReaderPrompt(std::move(prompt)); | 333 pdf_tab_helper->ShowOpenInReaderPrompt(std::move(prompt)); |
| 333 } | 334 } |
| 334 | 335 |
| 335 void GotPluginsCallback(int process_id, | 336 void GotPluginsCallback(int process_id, |
| 336 int routing_id, | 337 int routing_id, |
| 337 const AdobeReaderPluginInfo& reader_info) { | 338 const AdobeReaderPluginInfo& reader_info) { |
| 338 WebContents* web_contents = | 339 WebContents* web_contents = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 355 MaybeShowOpenPDFInReaderPrompt(web_contents, reader_info); | 356 MaybeShowOpenPDFInReaderPrompt(web_contents, reader_info); |
| 356 return; | 357 return; |
| 357 } | 358 } |
| 358 GetAdobeReaderPluginInfoAsync( | 359 GetAdobeReaderPluginInfoAsync( |
| 359 profile, | 360 profile, |
| 360 base::Bind(&GotPluginsCallback, | 361 base::Bind(&GotPluginsCallback, |
| 361 web_contents->GetRenderProcessHost()->GetID(), | 362 web_contents->GetRenderProcessHost()->GetID(), |
| 362 web_contents->GetRenderViewHost()->GetRoutingID())); | 363 web_contents->GetRenderViewHost()->GetRoutingID())); |
| 363 #endif // defined(OS_WIN) | 364 #endif // defined(OS_WIN) |
| 364 } | 365 } |
| OLD | NEW |