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 #include "chrome/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 net::AuthCredentials* credentials) { | 616 net::AuthCredentials* credentials) { |
617 return ExtensionWebRequestEventRouter::GetInstance()->OnAuthRequired( | 617 return ExtensionWebRequestEventRouter::GetInstance()->OnAuthRequired( |
618 profile_, extension_info_map_.get(), request, auth_info, | 618 profile_, extension_info_map_.get(), request, auth_info, |
619 callback, credentials); | 619 callback, credentials); |
620 } | 620 } |
621 | 621 |
622 bool ChromeNetworkDelegate::OnCanGetCookies( | 622 bool ChromeNetworkDelegate::OnCanGetCookies( |
623 const net::URLRequest& request, | 623 const net::URLRequest& request, |
624 const net::CookieList& cookie_list) { | 624 const net::CookieList& cookie_list) { |
625 // NULL during tests, or when we're running in the system context. | 625 // NULL during tests, or when we're running in the system context. |
626 if (!cookie_settings_) | 626 if (!cookie_settings_.get()) |
627 return true; | 627 return true; |
628 | 628 |
629 bool allow = cookie_settings_->IsReadingCookieAllowed( | 629 bool allow = cookie_settings_->IsReadingCookieAllowed( |
630 request.url(), request.first_party_for_cookies()); | 630 request.url(), request.first_party_for_cookies()); |
631 | 631 |
632 int render_process_id = -1; | 632 int render_process_id = -1; |
633 int render_view_id = -1; | 633 int render_view_id = -1; |
634 if (content::ResourceRequestInfo::GetRenderViewForRequest( | 634 if (content::ResourceRequestInfo::GetRenderViewForRequest( |
635 &request, &render_process_id, &render_view_id)) { | 635 &request, &render_process_id, &render_view_id)) { |
636 BrowserThread::PostTask( | 636 BrowserThread::PostTask( |
637 BrowserThread::UI, FROM_HERE, | 637 BrowserThread::UI, FROM_HERE, |
638 base::Bind(&TabSpecificContentSettings::CookiesRead, | 638 base::Bind(&TabSpecificContentSettings::CookiesRead, |
639 render_process_id, render_view_id, | 639 render_process_id, render_view_id, |
640 request.url(), request.first_party_for_cookies(), | 640 request.url(), request.first_party_for_cookies(), |
641 cookie_list, !allow)); | 641 cookie_list, !allow)); |
642 } | 642 } |
643 | 643 |
644 return allow; | 644 return allow; |
645 } | 645 } |
646 | 646 |
647 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, | 647 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, |
648 const std::string& cookie_line, | 648 const std::string& cookie_line, |
649 net::CookieOptions* options) { | 649 net::CookieOptions* options) { |
650 // NULL during tests, or when we're running in the system context. | 650 // NULL during tests, or when we're running in the system context. |
651 if (!cookie_settings_) | 651 if (!cookie_settings_.get()) |
652 return true; | 652 return true; |
653 | 653 |
654 bool allow = cookie_settings_->IsSettingCookieAllowed( | 654 bool allow = cookie_settings_->IsSettingCookieAllowed( |
655 request.url(), request.first_party_for_cookies()); | 655 request.url(), request.first_party_for_cookies()); |
656 | 656 |
657 int render_process_id = -1; | 657 int render_process_id = -1; |
658 int render_view_id = -1; | 658 int render_view_id = -1; |
659 if (content::ResourceRequestInfo::GetRenderViewForRequest( | 659 if (content::ResourceRequestInfo::GetRenderViewForRequest( |
660 &request, &render_process_id, &render_view_id)) { | 660 &request, &render_process_id, &render_view_id)) { |
661 BrowserThread::PostTask( | 661 BrowserThread::PostTask( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 731 } |
732 | 732 |
733 return request.first_party_for_cookies().scheme() == | 733 return request.first_party_for_cookies().scheme() == |
734 extensions::kExtensionScheme; | 734 extensions::kExtensionScheme; |
735 } | 735 } |
736 | 736 |
737 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( | 737 bool ChromeNetworkDelegate::OnCanEnablePrivacyMode( |
738 const GURL& url, | 738 const GURL& url, |
739 const GURL& first_party_for_cookies) const { | 739 const GURL& first_party_for_cookies) const { |
740 // NULL during tests, or when we're running in the system context. | 740 // NULL during tests, or when we're running in the system context. |
741 if (!cookie_settings_) | 741 if (!cookie_settings_.get()) |
742 return false; | 742 return false; |
743 | 743 |
744 bool reading_cookie_allowed = cookie_settings_->IsReadingCookieAllowed( | 744 bool reading_cookie_allowed = cookie_settings_->IsReadingCookieAllowed( |
745 url, first_party_for_cookies); | 745 url, first_party_for_cookies); |
746 bool setting_cookie_allowed = cookie_settings_->IsSettingCookieAllowed( | 746 bool setting_cookie_allowed = cookie_settings_->IsSettingCookieAllowed( |
747 url, first_party_for_cookies); | 747 url, first_party_for_cookies); |
748 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed); | 748 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed); |
749 return privacy_mode; | 749 return privacy_mode; |
750 } | 750 } |
751 | 751 |
(...skipping 23 matching lines...) Expand all Loading... |
775 | 775 |
776 void ChromeNetworkDelegate::AccumulateContentLength( | 776 void ChromeNetworkDelegate::AccumulateContentLength( |
777 int64 received_content_length, int64 original_content_length) { | 777 int64 received_content_length, int64 original_content_length) { |
778 DCHECK_GE(received_content_length, 0); | 778 DCHECK_GE(received_content_length, 0); |
779 DCHECK_GE(original_content_length, 0); | 779 DCHECK_GE(original_content_length, 0); |
780 StoreAccumulatedContentLength(received_content_length, | 780 StoreAccumulatedContentLength(received_content_length, |
781 original_content_length); | 781 original_content_length); |
782 received_content_length_ += received_content_length; | 782 received_content_length_ += received_content_length; |
783 original_content_length_ += original_content_length; | 783 original_content_length_ += original_content_length; |
784 } | 784 } |
OLD | NEW |