| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 virtual void OnPACScriptError(int line_number, | 142 virtual void OnPACScriptError(int line_number, |
| 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 OnCanGetCookies(const net::URLRequest& request, |
| 153 const net::URLRequest* request, | 153 const net::CookieList& cookie_list) OVERRIDE { |
| 154 const net::CookieList& cookie_list) OVERRIDE { | |
| 155 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? | 154 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? |
| 156 StaticCookiePolicy::ALLOW_ALL_COOKIES : | 155 StaticCookiePolicy::ALLOW_ALL_COOKIES : |
| 157 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; | 156 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; |
| 158 | 157 |
| 159 StaticCookiePolicy policy(policy_type); | 158 StaticCookiePolicy policy(policy_type); |
| 160 int rv = policy.CanGetCookies( | 159 int rv = policy.CanGetCookies( |
| 161 request->url(), request->first_party_for_cookies()); | 160 request.url(), request.first_party_for_cookies()); |
| 162 return rv == net::OK; | 161 return rv == net::OK; |
| 163 } | 162 } |
| 164 virtual bool CanSetCookie(const net::URLRequest* request, | 163 virtual bool OnCanSetCookie(const net::URLRequest& request, |
| 165 const std::string& cookie_line, | 164 const std::string& cookie_line, |
| 166 net::CookieOptions* options) OVERRIDE { | 165 net::CookieOptions* options) OVERRIDE { |
| 167 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? | 166 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? |
| 168 StaticCookiePolicy::ALLOW_ALL_COOKIES : | 167 StaticCookiePolicy::ALLOW_ALL_COOKIES : |
| 169 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; | 168 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; |
| 170 | 169 |
| 171 StaticCookiePolicy policy(policy_type); | 170 StaticCookiePolicy policy(policy_type); |
| 172 int rv = policy.CanSetCookie( | 171 int rv = policy.CanSetCookie( |
| 173 request->url(), request->first_party_for_cookies()); | 172 request.url(), request.first_party_for_cookies()); |
| 174 return rv == net::OK; | 173 return rv == net::OK; |
| 175 } | 174 } |
| 175 virtual bool OnCanAccessFile(const net::URLRequest& request, |
| 176 const FilePath& path) const OVERRIDE { |
| 177 return true; |
| 178 } |
| 176 }; | 179 }; |
| 177 | 180 |
| 178 TestShellRequestContextParams* g_request_context_params = NULL; | 181 TestShellRequestContextParams* g_request_context_params = NULL; |
| 179 TestShellRequestContext* g_request_context = NULL; | 182 TestShellRequestContext* g_request_context = NULL; |
| 180 TestShellNetworkDelegate* g_network_delegate = NULL; | 183 TestShellNetworkDelegate* g_network_delegate = NULL; |
| 181 base::Thread* g_cache_thread = NULL; | 184 base::Thread* g_cache_thread = NULL; |
| 182 | 185 |
| 183 struct FileOverHTTPParams { | 186 struct FileOverHTTPParams { |
| 184 FileOverHTTPParams(std::string in_file_path_template, GURL in_http_prefix) | 187 FileOverHTTPParams(std::string in_file_path_template, GURL in_http_prefix) |
| 185 : file_path_template(in_file_path_template), | 188 : file_path_template(in_file_path_template), |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); | 1120 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); |
| 1118 g_file_over_http_params = new FileOverHTTPParams(file_path_template, | 1121 g_file_over_http_params = new FileOverHTTPParams(file_path_template, |
| 1119 http_prefix); | 1122 http_prefix); |
| 1120 } | 1123 } |
| 1121 | 1124 |
| 1122 // static | 1125 // static |
| 1123 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( | 1126 webkit_glue::ResourceLoaderBridge* SimpleResourceLoaderBridge::Create( |
| 1124 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { | 1127 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |
| 1125 return new ResourceLoaderBridgeImpl(request_info); | 1128 return new ResourceLoaderBridgeImpl(request_info); |
| 1126 } | 1129 } |
| OLD | NEW |