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