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