OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ |
6 #define CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ | 6 #define CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include "base/compiler_specific.h" |
10 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
11 #include "net/url_request/url_request_job_factory.h" | 12 #include "net/url_request/url_request_job_factory.h" |
12 | 13 |
13 namespace chromeos { | 14 namespace chromeos { |
14 | 15 |
15 // This class integrates the Google Document Viewer into ChromeOS, | 16 // This class integrates the Google Document Viewer into ChromeOS, |
16 // enabling the viewing of supported document types that the user | 17 // enabling the viewing of supported document types that the user |
17 // clicks on. This class will intercept requests to supported | 18 // clicks on. This class will intercept requests to supported |
18 // document types (such as PDF) and redirect the request to the Google | 19 // document types (such as PDF) and redirect the request to the Google |
19 // Document Viewer, including the document's original URL as a | 20 // Document Viewer, including the document's original URL as a |
20 // parameter. | 21 // parameter. |
21 class GViewRequestInterceptor : public net::URLRequestJobFactory::Interceptor { | 22 class GViewRequestInterceptor : public net::URLRequestJobFactory::Interceptor { |
22 public: | 23 public: |
23 GViewRequestInterceptor(); | 24 GViewRequestInterceptor(); |
24 virtual ~GViewRequestInterceptor(); | 25 virtual ~GViewRequestInterceptor(); |
25 | 26 |
26 // Always returns NULL because we don't want to attempt a redirect | 27 // Always returns NULL because we don't want to attempt a redirect |
27 // before seeing the detected mime type of the request. | 28 // before seeing the detected mime type of the request. |
28 virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request) const; | 29 virtual net::URLRequestJob* MaybeIntercept( |
| 30 net::URLRequest* request) const OVERRIDE; |
29 | 31 |
30 // Always returns NULL. | 32 // Always returns NULL. |
31 virtual net::URLRequestJob* MaybeInterceptRedirect( | 33 virtual net::URLRequestJob* MaybeInterceptRedirect( |
32 const GURL& location, | 34 const GURL& location, |
33 net::URLRequest* request) const; | 35 net::URLRequest* request) const OVERRIDE; |
34 | 36 |
35 // Determines if the requested document can be viewed by the Google | 37 // Determines if the requested document can be viewed by the Google |
36 // Document Viewer. If it can, returns a net::URLRequestJob that | 38 // Document Viewer. If it can, returns a net::URLRequestJob that |
37 // redirects the browser to the view URL. | 39 // redirects the browser to the view URL. |
38 virtual net::URLRequestJob* MaybeInterceptResponse( | 40 virtual net::URLRequestJob* MaybeInterceptResponse( |
39 net::URLRequest* request) const; | 41 net::URLRequest* request) const OVERRIDE; |
40 | 42 |
41 private: | 43 private: |
42 bool ShouldUsePdfPlugin(net::URLRequest* request) const; | 44 bool ShouldUsePdfPlugin(net::URLRequest* request) const; |
43 bool ShouldInterceptScheme(const std::string& scheme) const; | 45 bool ShouldInterceptScheme(const std::string& scheme) const; |
44 | 46 |
45 // The list of supported mime types. | 47 // The list of supported mime types. |
46 base::hash_set<std::string> supported_mime_types_; | 48 base::hash_set<std::string> supported_mime_types_; |
47 }; | 49 }; |
48 | 50 |
49 } // namespace chromeos | 51 } // namespace chromeos |
50 | 52 |
51 #endif // CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ | 53 #endif // CHROME_BROWSER_CHROMEOS_GVIEW_REQUEST_INTERCEPTOR_H__ |
OLD | NEW |