| 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 #include "chrome/browser/chromeos/gview_request_interceptor.h" | 5 #include "chrome/browser/chromeos/gview_request_interceptor.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/browser/chrome_plugin_service_filter.h" | 9 #include "chrome/browser/chrome_plugin_service_filter.h" |
| 10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "content/browser/renderer_host/resource_dispatcher_host.h" | |
| 13 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | |
| 14 #include "content/public/browser/plugin_service.h" | 12 #include "content/public/browser/plugin_service.h" |
| 13 #include "content/public/browser/resource_request_info.h" |
| 15 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 16 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 17 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 18 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 19 #include "net/url_request/url_request_redirect_job.h" | 18 #include "net/url_request/url_request_redirect_job.h" |
| 20 #include "webkit/plugins/webplugininfo.h" | 19 #include "webkit/plugins/webplugininfo.h" |
| 21 | 20 |
| 22 using content::PluginService; | 21 using content::PluginService; |
| 22 using content::ResourceRequestInfo; |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // The PDF mime type is treated special if the browser has a built-in | 28 // The PDF mime type is treated special if the browser has a built-in |
| 29 // PDF viewer plug-in installed - we want to intercept only if we're | 29 // PDF viewer plug-in installed - we want to intercept only if we're |
| 30 // told to. | 30 // told to. |
| 31 const char kPdfMimeType[] = "application/pdf"; | 31 const char kPdfMimeType[] = "application/pdf"; |
| 32 | 32 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 60 net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptRedirect( | 60 net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptRedirect( |
| 61 const GURL& location, | 61 const GURL& location, |
| 62 net::URLRequest* request) const { | 62 net::URLRequest* request) const { |
| 63 return NULL; | 63 return NULL; |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool GViewRequestInterceptor::ShouldUsePdfPlugin( | 66 bool GViewRequestInterceptor::ShouldUsePdfPlugin( |
| 67 net::URLRequest* request) const { | 67 net::URLRequest* request) const { |
| 68 FilePath pdf_path; | 68 FilePath pdf_path; |
| 69 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); | 69 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); |
| 70 ResourceDispatcherHostRequestInfo* info = | 70 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 71 ResourceDispatcherHost::InfoForRequest(request); | |
| 72 if (!info) | 71 if (!info) |
| 73 return false; | 72 return false; |
| 74 | 73 |
| 75 webkit::WebPluginInfo plugin; | 74 webkit::WebPluginInfo plugin; |
| 76 if (!PluginService::GetInstance()->GetPluginInfoByPath(pdf_path, &plugin)) { | 75 if (!PluginService::GetInstance()->GetPluginInfoByPath(pdf_path, &plugin)) { |
| 77 return false; | 76 return false; |
| 78 } | 77 } |
| 79 | 78 |
| 80 return ChromePluginServiceFilter::GetInstance()->ShouldUsePlugin( | 79 return ChromePluginServiceFilter::GetInstance()->ShouldUsePlugin( |
| 81 info->child_id(), info->route_id(), info->context(), | 80 info->child_id(), info->route_id(), info->context(), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 112 // will redirect the browser to this new URL. | 111 // will redirect the browser to this new URL. |
| 113 if (supported_mime_types_.count(mime_type) > 0) { | 112 if (supported_mime_types_.count(mime_type) > 0) { |
| 114 std::string url(kGViewUrlPrefix); | 113 std::string url(kGViewUrlPrefix); |
| 115 url += net::EscapePath(request->url().spec()); | 114 url += net::EscapePath(request->url().spec()); |
| 116 return new net::URLRequestRedirectJob(request, GURL(url)); | 115 return new net::URLRequestRedirectJob(request, GURL(url)); |
| 117 } | 116 } |
| 118 return NULL; | 117 return NULL; |
| 119 } | 118 } |
| 120 | 119 |
| 121 } // namespace chromeos | 120 } // namespace chromeos |
| OLD | NEW |