diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 20:08:47 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 20:08:47 +0000 |
commit | e0379d56b61dc1bca0ee1c66b93b9c19279332b3 (patch) | |
tree | 60962418d15fd8073fe59abe8472ab6bd9899cd0 /chrome/browser/chromeos/gview_request_interceptor.cc | |
parent | f49f5aa4139b80e4457587910d49199a9f9fe666 (diff) | |
download | chromium_src-e0379d56b61dc1bca0ee1c66b93b9c19279332b3.zip chromium_src-e0379d56b61dc1bca0ee1c66b93b9c19279332b3.tar.gz chromium_src-e0379d56b61dc1bca0ee1c66b93b9c19279332b3.tar.bz2 |
Use PluginPrefs to find out whether the PDF plugin is enabled in GViewRequestInterceptor.
BUG=80794
TEST=GViewRequestInterceptorTest.*
Review URL: http://codereview.chromium.org/7541076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/gview_request_interceptor.cc')
-rw-r--r-- | chrome/browser/chromeos/gview_request_interceptor.cc | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/chrome/browser/chromeos/gview_request_interceptor.cc b/chrome/browser/chromeos/gview_request_interceptor.cc index 3beab22..730767f 100644 --- a/chrome/browser/chromeos/gview_request_interceptor.cc +++ b/chrome/browser/chromeos/gview_request_interceptor.cc @@ -6,7 +6,10 @@ #include "base/file_path.h" #include "base/path_service.h" +#include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/common/chrome_paths.h" +#include "content/browser/renderer_host/resource_dispatcher_host.h" +#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "googleurl/src/gurl.h" #include "net/base/escape.h" #include "net/base/load_flags.h" @@ -52,6 +55,26 @@ net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptRedirect( return NULL; } +bool GViewRequestInterceptor::ShouldUsePdfPlugin( + net::URLRequest* request) const { + FilePath pdf_path; + PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); + ResourceDispatcherHostRequestInfo* info = + ResourceDispatcherHost::InfoForRequest(request); + if (!info) + return false; + + webkit::WebPluginInfo plugin; + if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( + pdf_path, &plugin)) { + return false; + } + + return ChromePluginServiceFilter::GetInstance()->ShouldUsePlugin( + info->child_id(), info->route_id(), info->context(), + request->url(), GURL(), &plugin); +} + net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( net::URLRequest* request) const { // Do not intercept this request if it is a download. @@ -63,15 +86,8 @@ net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( request->GetMimeType(&mime_type); // If the local PDF viewing plug-in is installed and enabled, don't // redirect PDF files to Google Document Viewer. - if (mime_type == kPdfMimeType) { - FilePath pdf_path; - webkit::WebPluginInfo info; - PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); - if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( - pdf_path, &info) && - webkit::IsPluginEnabled(info)) - return NULL; - } + if (mime_type == kPdfMimeType && ShouldUsePdfPlugin(request)) + return NULL; // If supported, build the URL to the Google Document Viewer // including the origial document's URL, then create a new job that // will redirect the browser to this new URL. |