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