| OLD | NEW |
| 1 // Copyright (c) 2012 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 // This file contains an implementation of the ResourceLoaderBridge class. | 5 // This file contains an implementation of the ResourceLoaderBridge class. |
| 6 // The class is implemented using net::URLRequest, meaning it is a "simple" | 6 // The class is implemented using net::URLRequest, meaning it is a "simple" |
| 7 // version that directly issues requests. The more complicated one used in the | 7 // version that directly issues requests. The more complicated one used in the |
| 8 // browser uses IPC. | 8 // browser uses IPC. |
| 9 // | 9 // |
| 10 // Because net::URLRequest only provides an asynchronous resource loading API, | 10 // Because net::URLRequest only provides an asynchronous resource loading API, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 const string16& error) OVERRIDE { | 143 const string16& error) OVERRIDE { |
| 144 } | 144 } |
| 145 virtual AuthRequiredResponse OnAuthRequired( | 145 virtual AuthRequiredResponse OnAuthRequired( |
| 146 net::URLRequest* request, | 146 net::URLRequest* request, |
| 147 const net::AuthChallengeInfo& auth_info, | 147 const net::AuthChallengeInfo& auth_info, |
| 148 const AuthCallback& callback, | 148 const AuthCallback& callback, |
| 149 net::AuthCredentials* credentials) OVERRIDE { | 149 net::AuthCredentials* credentials) OVERRIDE { |
| 150 return AUTH_REQUIRED_RESPONSE_NO_ACTION; | 150 return AUTH_REQUIRED_RESPONSE_NO_ACTION; |
| 151 } | 151 } |
| 152 virtual bool CanGetCookies( | 152 virtual bool CanGetCookies( |
| 153 const net::URLRequest* request, | 153 const net::URLRequest& request, |
| 154 const net::CookieList& cookie_list) OVERRIDE { | 154 const net::CookieList& cookie_list) OVERRIDE { |
| 155 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? | 155 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? |
| 156 StaticCookiePolicy::ALLOW_ALL_COOKIES : | 156 StaticCookiePolicy::ALLOW_ALL_COOKIES : |
| 157 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; | 157 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; |
| 158 | 158 |
| 159 StaticCookiePolicy policy(policy_type); | 159 StaticCookiePolicy policy(policy_type); |
| 160 int rv = policy.CanGetCookies( | 160 int rv = policy.CanGetCookies( |
| 161 request->url(), request->first_party_for_cookies()); | 161 request.url(), request.first_party_for_cookies()); |
| 162 return rv == net::OK; | 162 return rv == net::OK; |
| 163 } | 163 } |
| 164 virtual bool CanSetCookie(const net::URLRequest* request, | 164 virtual bool CanSetCookie(const net::URLRequest& request, |
| 165 const std::string& cookie_line, | 165 const std::string& cookie_line, |
| 166 net::CookieOptions* options) OVERRIDE { | 166 net::CookieOptions* options) OVERRIDE { |
| 167 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? | 167 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? |
| 168 StaticCookiePolicy::ALLOW_ALL_COOKIES : | 168 StaticCookiePolicy::ALLOW_ALL_COOKIES : |
| 169 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; | 169 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; |
| 170 | 170 |
| 171 StaticCookiePolicy policy(policy_type); | 171 StaticCookiePolicy policy(policy_type); |
| 172 int rv = policy.CanSetCookie( | 172 int rv = policy.CanSetCookie( |
| 173 request->url(), request->first_party_for_cookies()); | 173 request.url(), request.first_party_for_cookies()); |
| 174 return rv == net::OK; | 174 return rv == net::OK; |
| 175 } | 175 } |
| 176 virtual bool CanAccessFile(const net::URLRequest& request, |
| 177 const FilePath& path) const OVERRIDE { |
| 178 return true; |
| 179 } |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 TestShellRequestContextParams* g_request_context_params = NULL; | 182 TestShellRequestContextParams* g_request_context_params = NULL; |
| 179 TestShellRequestContext* g_request_context = NULL; | 183 TestShellRequestContext* g_request_context = NULL; |
| 180 TestShellNetworkDelegate* g_network_delegate = NULL; | 184 TestShellNetworkDelegate* g_network_delegate = NULL; |
| 181 base::Thread* g_cache_thread = NULL; | 185 base::Thread* g_cache_thread = NULL; |
| 182 | 186 |
| 183 struct FileOverHTTPParams { | 187 struct FileOverHTTPParams { |
| 184 FileOverHTTPParams(std::string in_file_path_template, GURL in_http_prefix) | 188 FileOverHTTPParams(std::string in_file_path_template, GURL in_http_prefix) |
| 185 : file_path_template(in_file_path_template), | 189 : file_path_template(in_file_path_template), |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); | 1119 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); |
| 1116 g_file_over_http_params = new FileOverHTTPParams(file_path_template, | 1120 g_file_over_http_params = new FileOverHTTPParams(file_path_template, |
| 1117 http_prefix); | 1121 http_prefix); |
| 1118 } | 1122 } |
| 1119 | 1123 |
| 1120 // static | 1124 // static |
| 1121 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( | 1125 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( |
| 1122 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { | 1126 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |
| 1123 return new ResourceLoaderBridgeImpl(request_info); | 1127 return new ResourceLoaderBridgeImpl(request_info); |
| 1124 } | 1128 } |
| OLD | NEW |