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 // 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 net::X509Certificate* cert) OVERRIDE { | 462 net::X509Certificate* cert) OVERRIDE { |
463 // Allow all certificate errors. | 463 // Allow all certificate errors. |
464 request->ContinueDespiteLastError(); | 464 request->ContinueDespiteLastError(); |
465 } | 465 } |
466 | 466 |
467 virtual bool CanGetCookies( | 467 virtual bool CanGetCookies( |
468 const net::URLRequest* request, | 468 const net::URLRequest* request, |
469 const net::CookieList& cookie_list) const OVERRIDE { | 469 const net::CookieList& cookie_list) const OVERRIDE { |
470 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? | 470 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? |
471 StaticCookiePolicy::ALLOW_ALL_COOKIES : | 471 StaticCookiePolicy::ALLOW_ALL_COOKIES : |
472 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; | 472 StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES; |
473 | 473 |
474 StaticCookiePolicy policy(policy_type); | 474 StaticCookiePolicy policy(policy_type); |
475 int rv = policy.CanGetCookies( | 475 int rv = policy.CanGetCookies( |
476 request->url(), request->first_party_for_cookies()); | 476 request->url(), request->first_party_for_cookies()); |
477 return rv == net::OK; | 477 return rv == net::OK; |
478 } | 478 } |
479 | 479 |
480 virtual bool CanSetCookie(const net::URLRequest* request, | 480 virtual bool CanSetCookie(const net::URLRequest* request, |
481 const std::string& cookie_line, | 481 const std::string& cookie_line, |
482 net::CookieOptions* options) const OVERRIDE { | 482 net::CookieOptions* options) const OVERRIDE { |
483 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? | 483 StaticCookiePolicy::Type policy_type = g_accept_all_cookies ? |
484 StaticCookiePolicy::ALLOW_ALL_COOKIES : | 484 StaticCookiePolicy::ALLOW_ALL_COOKIES : |
485 StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES; | 485 StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES; |
486 | 486 |
487 StaticCookiePolicy policy(policy_type); | 487 StaticCookiePolicy policy(policy_type); |
488 int rv = policy.CanSetCookie( | 488 int rv = policy.CanSetCookie( |
489 request->url(), request->first_party_for_cookies()); | 489 request->url(), request->first_party_for_cookies()); |
490 return rv == net::OK; | 490 return rv == net::OK; |
491 } | 491 } |
492 | 492 |
493 virtual void OnReadCompleted(net::URLRequest* request, | 493 virtual void OnReadCompleted(net::URLRequest* request, |
494 int bytes_read) OVERRIDE { | 494 int bytes_read) OVERRIDE { |
495 if (request->status().is_success() && bytes_read > 0) { | 495 if (request->status().is_success() && bytes_read > 0) { |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 | 1032 |
1033 // static | 1033 // static |
1034 void SimpleResourceLoaderBridge::AllowFileOverHTTP( | 1034 void SimpleResourceLoaderBridge::AllowFileOverHTTP( |
1035 const std::string& file_path_template, const GURL& http_prefix) { | 1035 const std::string& file_path_template, const GURL& http_prefix) { |
1036 DCHECK(!file_path_template.empty()); | 1036 DCHECK(!file_path_template.empty()); |
1037 DCHECK(http_prefix.is_valid() && | 1037 DCHECK(http_prefix.is_valid() && |
1038 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); | 1038 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); |
1039 g_file_over_http_params = new FileOverHTTPParams(file_path_template, | 1039 g_file_over_http_params = new FileOverHTTPParams(file_path_template, |
1040 http_prefix); | 1040 http_prefix); |
1041 } | 1041 } |
OLD | NEW |