diff options
author | tbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-31 19:24:41 +0000 |
---|---|---|
committer | tbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-31 19:24:41 +0000 |
commit | 3392748a24a79f2cc37a538c64ff853b44f8ca38 (patch) | |
tree | 7d9a02308caa4cd72aff189e75c64d0458385d06 /chrome/browser/chromeos/gview_request_interceptor.cc | |
parent | 016624b91f17495e48c6657473d6ca460135089a (diff) | |
download | chromium_src-3392748a24a79f2cc37a538c64ff853b44f8ca38.zip chromium_src-3392748a24a79f2cc37a538c64ff853b44f8ca38.tar.gz chromium_src-3392748a24a79f2cc37a538c64ff853b44f8ca38.tar.bz2 |
Restricting set of URL requests that get intercepted to gview to GET methods with scheme http
This should not affect official build since requests with pdf mime type already don't get intercepted when pdf plugin is present.
TEST=Verified pdf can be copied in chromium OS file browser.
unit_tests:GViewRequestInterceptorTest.*
BUG=chromium-os:21560
Review URL: http://codereview.chromium.org/8357019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107991 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 | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/gview_request_interceptor.cc b/chrome/browser/chromeos/gview_request_interceptor.cc index 70fa026..d5b7106 100644 --- a/chrome/browser/chromeos/gview_request_interceptor.cc +++ b/chrome/browser/chromeos/gview_request_interceptor.cc @@ -8,6 +8,7 @@ #include "base/path_service.h" #include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/url_constants.h" #include "content/browser/plugin_service.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" @@ -20,19 +21,23 @@ namespace chromeos { +namespace { + // The PDF mime type is treated special if the browser has a built-in // PDF viewer plug-in installed - we want to intercept only if we're // told to. -static const char kPdfMimeType[] = "application/pdf"; +const char kPdfMimeType[] = "application/pdf"; // This is the list of mime types currently supported by the Google // Document Viewer. -static const char* const kSupportedMimeTypeList[] = { +const char* const kSupportedMimeTypeList[] = { kPdfMimeType, "application/vnd.ms-powerpoint" }; -static const char kGViewUrlPrefix[] = "http://docs.google.com/gview?url="; +const char kGViewUrlPrefix[] = "http://docs.google.com/gview?url="; + +} // namespace GViewRequestInterceptor::GViewRequestInterceptor() { for (size_t i = 0; i < arraysize(kSupportedMimeTypeList); ++i) { @@ -75,6 +80,11 @@ bool GViewRequestInterceptor::ShouldUsePdfPlugin( request->url(), GURL(), &plugin); } +bool GViewRequestInterceptor::ShouldInterceptScheme( + const std::string& scheme) const { + return scheme == chrome::kHttpScheme; +} + net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( net::URLRequest* request) const { // Do not intercept this request if it is a download. @@ -84,10 +94,17 @@ net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( std::string mime_type; request->GetMimeType(&mime_type); + + if (request->method() != "GET" || + !ShouldInterceptScheme(request->original_url().scheme())) { + return NULL; + } + // If the local PDF viewing plug-in is installed and enabled, don't // redirect PDF files to Google Document Viewer. 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. |