| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 bool ChromeNetworkDelegate::OnCanGetCookies( | 426 bool ChromeNetworkDelegate::OnCanGetCookies( |
| 427 const net::URLRequest& request, | 427 const net::URLRequest& request, |
| 428 const net::CookieList& cookie_list) { | 428 const net::CookieList& cookie_list) { |
| 429 // nullptr during tests, or when we're running in the system context. | 429 // nullptr during tests, or when we're running in the system context. |
| 430 if (!cookie_settings_.get()) | 430 if (!cookie_settings_.get()) |
| 431 return true; | 431 return true; |
| 432 | 432 |
| 433 bool allow = cookie_settings_->IsReadingCookieAllowed( | 433 bool allow = cookie_settings_->IsReadingCookieAllowed( |
| 434 request.url(), request.first_party_for_cookies()); | 434 request.url(), request.first_party_for_cookies()); |
| 435 | 435 |
| 436 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); | 436 int render_process_id = -1; |
| 437 if (info) { | 437 int render_frame_id = -1; |
| 438 if (content::ResourceRequestInfo::GetRenderFrameForRequest( |
| 439 &request, &render_process_id, &render_frame_id)) { |
| 438 BrowserThread::PostTask( | 440 BrowserThread::PostTask( |
| 439 BrowserThread::UI, FROM_HERE, | 441 BrowserThread::UI, FROM_HERE, |
| 440 base::Bind(&TabSpecificContentSettings::CookiesRead, | 442 base::Bind(&TabSpecificContentSettings::CookiesRead, |
| 441 info->GetWebContentsGetterForRequest(), | 443 render_process_id, render_frame_id, |
| 442 request.url(), request.first_party_for_cookies(), | 444 request.url(), request.first_party_for_cookies(), |
| 443 cookie_list, !allow)); | 445 cookie_list, !allow)); |
| 444 } | 446 } |
| 445 | 447 |
| 446 return allow; | 448 return allow; |
| 447 } | 449 } |
| 448 | 450 |
| 449 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, | 451 bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, |
| 450 const std::string& cookie_line, | 452 const std::string& cookie_line, |
| 451 net::CookieOptions* options) { | 453 net::CookieOptions* options) { |
| 452 // nullptr during tests, or when we're running in the system context. | 454 // nullptr during tests, or when we're running in the system context. |
| 453 if (!cookie_settings_.get()) | 455 if (!cookie_settings_.get()) |
| 454 return true; | 456 return true; |
| 455 | 457 |
| 456 bool allow = cookie_settings_->IsSettingCookieAllowed( | 458 bool allow = cookie_settings_->IsSettingCookieAllowed( |
| 457 request.url(), request.first_party_for_cookies()); | 459 request.url(), request.first_party_for_cookies()); |
| 458 | 460 |
| 459 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); | 461 int render_process_id = -1; |
| 460 if (info) { | 462 int render_frame_id = -1; |
| 463 if (content::ResourceRequestInfo::GetRenderFrameForRequest( |
| 464 &request, &render_process_id, &render_frame_id)) { |
| 461 BrowserThread::PostTask( | 465 BrowserThread::PostTask( |
| 462 BrowserThread::UI, FROM_HERE, | 466 BrowserThread::UI, FROM_HERE, |
| 463 base::Bind(&TabSpecificContentSettings::CookieChanged, | 467 base::Bind(&TabSpecificContentSettings::CookieChanged, |
| 464 info->GetWebContentsGetterForRequest(), | 468 render_process_id, render_frame_id, |
| 465 request.url(), request.first_party_for_cookies(), | 469 request.url(), request.first_party_for_cookies(), |
| 466 cookie_line, *options, !allow)); | 470 cookie_line, *options, !allow)); |
| 467 } | 471 } |
| 468 | 472 |
| 469 return allow; | 473 return allow; |
| 470 } | 474 } |
| 471 | 475 |
| 472 bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, | 476 bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, |
| 473 const base::FilePath& path) const { | 477 const base::FilePath& path) const { |
| 474 if (g_allow_file_access_) | 478 if (g_allow_file_access_) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 if (!data_use_aggregator_) | 586 if (!data_use_aggregator_) |
| 583 return; | 587 return; |
| 584 | 588 |
| 585 if (is_data_usage_off_the_record_) { | 589 if (is_data_usage_off_the_record_) { |
| 586 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); | 590 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); |
| 587 return; | 591 return; |
| 588 } | 592 } |
| 589 | 593 |
| 590 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); | 594 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); |
| 591 } | 595 } |
| OLD | NEW |