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