| 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 "content/browser/plugin_service.h" |
| 11 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 12 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 12 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 13 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 16 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_redirect_job.h" | 18 #include "net/url_request/url_request_redirect_job.h" |
| 18 #include "webkit/plugins/npapi/plugin_list.h" | 19 #include "webkit/plugins/webplugininfo.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 // The PDF mime type is treated special if the browser has a built-in | 23 // The PDF mime type is treated special if the browser has a built-in |
| 23 // PDF viewer plug-in installed - we want to intercept only if we're | 24 // PDF viewer plug-in installed - we want to intercept only if we're |
| 24 // told to. | 25 // told to. |
| 25 static const char kPdfMimeType[] = "application/pdf"; | 26 static const char kPdfMimeType[] = "application/pdf"; |
| 26 | 27 |
| 27 // This is the list of mime types currently supported by the Google | 28 // This is the list of mime types currently supported by the Google |
| 28 // Document Viewer. | 29 // Document Viewer. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 58 bool GViewRequestInterceptor::ShouldUsePdfPlugin( | 59 bool GViewRequestInterceptor::ShouldUsePdfPlugin( |
| 59 net::URLRequest* request) const { | 60 net::URLRequest* request) const { |
| 60 FilePath pdf_path; | 61 FilePath pdf_path; |
| 61 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); | 62 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); |
| 62 ResourceDispatcherHostRequestInfo* info = | 63 ResourceDispatcherHostRequestInfo* info = |
| 63 ResourceDispatcherHost::InfoForRequest(request); | 64 ResourceDispatcherHost::InfoForRequest(request); |
| 64 if (!info) | 65 if (!info) |
| 65 return false; | 66 return false; |
| 66 | 67 |
| 67 webkit::WebPluginInfo plugin; | 68 webkit::WebPluginInfo plugin; |
| 68 if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 69 if (!PluginService::GetInstance()->GetPluginInfoByPath(pdf_path, &plugin)) { |
| 69 pdf_path, &plugin)) { | |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 return ChromePluginServiceFilter::GetInstance()->ShouldUsePlugin( | 73 return ChromePluginServiceFilter::GetInstance()->ShouldUsePlugin( |
| 74 info->child_id(), info->route_id(), info->context(), | 74 info->child_id(), info->route_id(), info->context(), |
| 75 request->url(), GURL(), &plugin); | 75 request->url(), GURL(), &plugin); |
| 76 } | 76 } |
| 77 | 77 |
| 78 net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( | 78 net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( |
| 79 net::URLRequest* request) const { | 79 net::URLRequest* request) const { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 // will redirect the browser to this new URL. | 93 // will redirect the browser to this new URL. |
| 94 if (supported_mime_types_.count(mime_type) > 0) { | 94 if (supported_mime_types_.count(mime_type) > 0) { |
| 95 std::string url(kGViewUrlPrefix); | 95 std::string url(kGViewUrlPrefix); |
| 96 url += EscapePath(request->url().spec()); | 96 url += EscapePath(request->url().spec()); |
| 97 return new net::URLRequestRedirectJob(request, GURL(url)); | 97 return new net::URLRequestRedirectJob(request, GURL(url)); |
| 98 } | 98 } |
| 99 return NULL; | 99 return NULL; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace chromeos | 102 } // namespace chromeos |
| OLD | NEW |