Chromium Code Reviews| 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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "base/version.h" | 12 #include "base/version.h" |
| 13 #include "chrome/browser/lifetime/application_lifetime.h" | 13 #include "chrome/browser/lifetime/application_lifetime.h" |
| 14 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 14 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 15 #include "chrome/browser/plugins/plugin_finder.h" | 15 #include "chrome/browser/plugins/plugin_finder.h" |
| 16 #include "chrome/browser/plugins/plugin_metadata.h" | 16 #include "chrome/browser/plugins/plugin_metadata.h" |
| 17 #include "chrome/browser/plugins/plugin_prefs.h" | 17 #include "chrome/browser/plugins/plugin_prefs.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/renderer_preferences_util.h" | 19 #include "chrome/browser/renderer_preferences_util.h" |
| 20 #include "chrome/browser/tab_contents/tab_util.h" | 20 #include "chrome/browser/tab_contents/tab_util.h" |
| 21 #include "chrome/browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h" | 21 #include "chrome/browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h" |
| 22 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" | 22 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" |
| 23 #include "chrome/common/chrome_content_client.h" | 23 #include "chrome/common/chrome_content_client.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "content/public/browser/interstitial_page.h" | 25 #include "content/public/browser/interstitial_page.h" |
| 26 #include "content/public/browser/interstitial_page_delegate.h" | 26 #include "content/public/browser/interstitial_page_delegate.h" |
| 27 #include "content/public/browser/navigation_details.h" | 27 #include "content/public/browser/navigation_details.h" |
| 28 #include "content/public/browser/navigation_entry.h" | 28 #include "content/public/browser/navigation_entry.h" |
| 29 #include "content/public/browser/plugin_service.h" | 29 #include "content/public/browser/plugin_service.h" |
| 30 #include "content/public/browser/render_frame_host.h" | |
| 30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 32 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 33 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/common/page_transition_types.h" | 35 #include "content/public/common/page_transition_types.h" |
| 35 #include "grit/browser_resources.h" | 36 #include "grit/browser_resources.h" |
| 36 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 37 #include "grit/theme_resources.h" | 38 #include "grit/theme_resources.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 OpenURLParams params( | 135 OpenURLParams params( |
| 135 GURL(kAdobeReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB, | 136 GURL(kAdobeReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB, |
| 136 content::PAGE_TRANSITION_LINK, false); | 137 content::PAGE_TRANSITION_LINK, false); |
| 137 web_contents->OpenURL(params); | 138 web_contents->OpenURL(params); |
| 138 } | 139 } |
| 139 | 140 |
| 140 // Opens the PDF using Adobe Reader. | 141 // Opens the PDF using Adobe Reader. |
| 141 void OpenUsingReader(WebContents* web_contents, | 142 void OpenUsingReader(WebContents* web_contents, |
| 142 const WebPluginInfo& reader_plugin, | 143 const WebPluginInfo& reader_plugin, |
| 143 OpenPDFInReaderPromptDelegate* delegate) { | 144 OpenPDFInReaderPromptDelegate* delegate) { |
| 144 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( | 145 ChromePluginServiceFilter::GetInstance()->OverridePluginForFrame( |
| 145 web_contents->GetRenderProcessHost()->GetID(), | 146 web_contents->GetRenderProcessHost()->GetID(), |
| 146 web_contents->GetRenderViewHost()->GetRoutingID(), | 147 web_contents->GetMainFrame()->GetRoutingID(), |
|
nasko
2013/12/05 22:43:45
Wouldn't this cause overrides to only be stored fo
jam
2013/12/05 23:14:07
we only show the page action for top-level pdfs, s
| |
| 147 web_contents->GetURL(), | 148 web_contents->GetURL(), |
| 148 reader_plugin); | 149 reader_plugin); |
| 149 web_contents->GetRenderViewHost()->ReloadFrame(); | 150 web_contents->GetRenderViewHost()->ReloadFrame(); |
| 150 | 151 |
| 151 PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents); | 152 PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents); |
| 152 if (delegate) | 153 if (delegate) |
| 153 pdf_tab_helper->ShowOpenInReaderPrompt(make_scoped_ptr(delegate)); | 154 pdf_tab_helper->ShowOpenInReaderPrompt(make_scoped_ptr(delegate)); |
| 154 } | 155 } |
| 155 | 156 |
| 156 // An interstitial to be used when the user chooses to open a PDF using Adobe | 157 // An interstitial to be used when the user chooses to open a PDF using Adobe |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 | 400 |
| 400 void PDFHasUnsupportedFeature(content::WebContents* web_contents) { | 401 void PDFHasUnsupportedFeature(content::WebContents* web_contents) { |
| 401 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) | 402 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
| 402 // Only works for Windows for now. For Mac, we'll have to launch the file | 403 // Only works for Windows for now. For Mac, we'll have to launch the file |
| 403 // externally since Adobe Reader doesn't work inside Chrome. | 404 // externally since Adobe Reader doesn't work inside Chrome. |
| 404 PluginService::GetInstance()->GetPlugins(base::Bind(&GotPluginsCallback, | 405 PluginService::GetInstance()->GetPlugins(base::Bind(&GotPluginsCallback, |
| 405 web_contents->GetRenderProcessHost()->GetID(), | 406 web_contents->GetRenderProcessHost()->GetID(), |
| 406 web_contents->GetRenderViewHost()->GetRoutingID())); | 407 web_contents->GetRenderViewHost()->GetRoutingID())); |
| 407 #endif | 408 #endif |
| 408 } | 409 } |
| OLD | NEW |