Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2011)

Unified Diff: chrome/browser/chromeos/gview_request_interceptor.cc

Issue 8357019: Restricting set of URL requests that get intercepted to gview to GET methods with scheme http (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gview_request_interceptor.cc
diff --git a/chrome/browser/chromeos/gview_request_interceptor.cc b/chrome/browser/chromeos/gview_request_interceptor.cc
index 70fa0261d32d7be9774c58b92f7194ff8c2ba420..281f7fdb77822444bcd1506828630e52af4302c1 100644
--- a/chrome/browser/chromeos/gview_request_interceptor.cc
+++ b/chrome/browser/chromeos/gview_request_interceptor.cc
@@ -20,19 +20,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 +79,11 @@ bool GViewRequestInterceptor::ShouldUsePdfPlugin(
request->url(), GURL(), &plugin);
}
+bool GViewRequestInterceptor::ShouldInterceptScheme(
+ const std::string& scheme) const {
+ return scheme == "http";
zel 2011/10/19 21:57:49 there is a constant for chrome scheme already defi
tbarzic 2011/10/19 23:30:28 Done.
+}
+
net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse(
net::URLRequest* request) const {
// Do not intercept this request if it is a download.
@@ -84,10 +93,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.

Powered by Google App Engine
This is Rietveld 408576698