Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: chrome/browser/chromeos/gview_request_interceptor.cc

Issue 9580002: Add ResourceRequestInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
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->GetChildID(), info->GetRouteID(), info->GetContext(),
82 request->url(), GURL(), &plugin); 81 request->url(), GURL(), &plugin);
83 } 82 }
84 83
85 bool GViewRequestInterceptor::ShouldInterceptScheme( 84 bool GViewRequestInterceptor::ShouldInterceptScheme(
86 const std::string& scheme) const { 85 const std::string& scheme) const {
87 return scheme == chrome::kHttpScheme; 86 return scheme == chrome::kHttpScheme;
88 } 87 }
89 88
90 net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse( 89 net::URLRequestJob* GViewRequestInterceptor::MaybeInterceptResponse(
91 net::URLRequest* request) const { 90 net::URLRequest* request) const {
(...skipping 20 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « chrome/browser/automation/url_request_automation_job.cc ('k') | chrome/browser/chromeos/gview_request_interceptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698