diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 20:01:45 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 20:01:45 +0000 |
commit | 56d83182c6d4c815aab837e82ccccc6103bc4b6a (patch) | |
tree | 34944feee64dfe06f287c1ab6a063144e4c3958f /chrome/browser/chromeos/gview_request_interceptor.h | |
parent | 42f4f8bc7eb5b3d7e5af6b066c13e70d39e60d5d (diff) | |
download | chromium_src-56d83182c6d4c815aab837e82ccccc6103bc4b6a.zip chromium_src-56d83182c6d4c815aab837e82ccccc6103bc4b6a.tar.gz chromium_src-56d83182c6d4c815aab837e82ccccc6103bc4b6a.tar.bz2 |
Intercept HTTP requests for documents that GView is capable of displaying (such
as pdf) and redirect the user to the appropriate URL for viewing.
Original patch by skrulx@gmail.com
http://codereview.chromium.org/174016
Review URL: http://codereview.chromium.org/199019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/gview_request_interceptor.h')
-rw-r--r-- | chrome/browser/chromeos/gview_request_interceptor.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/gview_request_interceptor.h b/chrome/browser/chromeos/gview_request_interceptor.h new file mode 100644 index 0000000..ca6d2ae --- /dev/null +++ b/chrome/browser/chromeos/gview_request_interceptor.h @@ -0,0 +1,41 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ +#define CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ + +#include <string> +#include "base/hash_tables.h" +#include "net/url_request/url_request.h" + +// This class integrates the Google Document Viewer into ChromeOS, +// enabling the viewing of supported document types that the user +// clicks on. This class will intercept requests to supported +// document types (such as PDF) and redirect the request to the Google +// Document Viewer, including the document's original URL as a +// parameter. +class GViewRequestInterceptor : public URLRequest::Interceptor { + public: + GViewRequestInterceptor(); + virtual ~GViewRequestInterceptor(); + + // Always returns NULL because we don't want to attempt a redirect + // before seeing the detected mime type of the request. + virtual URLRequestJob* MaybeIntercept(URLRequest* request); + + // Determines if the requested document can be viewed by the Google + // Document Viewer. If it can, returns a URLRequestJob that + // redirects the browser to the view URL. + virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request); + + // Singleton accessor. + static URLRequest::Interceptor* GetGViewRequestInterceptor(); + + private: + // The list of supported mime types. + base::hash_set<std::string> supported_mime_types_; +}; + +#endif // CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ + |