Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_message_filter.h" | 5 #include "content/browser/frame_host/render_frame_message_filter.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "content/browser/bad_message.h" | 12 #include "content/browser/bad_message.h" |
| 13 #include "content/browser/child_process_security_policy_impl.h" | 13 #include "content/browser/child_process_security_policy_impl.h" |
| 14 #include "content/browser/frame_host/render_frame_host_impl.h" | 14 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 15 #include "content/browser/gpu/gpu_data_manager_impl.h" | 15 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 16 #include "content/browser/renderer_host/render_widget_helper.h" | 16 #include "content/browser/renderer_host/render_widget_helper.h" |
| 17 #include "content/common/frame_messages.h" | 17 #include "content/common/frame_messages.h" |
| 18 #include "content/common/view_messages.h" | 18 #include "content/common/view_messages.h" |
| 19 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/common/content_constants.h" | 21 #include "content/public/common/content_constants.h" |
| 22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "gpu/GLES2/gl2extchromium.h" | 23 #include "gpu/GLES2/gl2extchromium.h" |
| 24 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | |
| 24 #include "net/cookies/cookie_options.h" | 25 #include "net/cookies/cookie_options.h" |
| 25 #include "net/cookies/cookie_store.h" | 26 #include "net/cookies/cookie_store.h" |
| 26 #include "net/url_request/url_request_context.h" | 27 #include "net/url_request/url_request_context.h" |
| 27 #include "net/url_request/url_request_context_getter.h" | 28 #include "net/url_request/url_request_context_getter.h" |
| 28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 29 | 30 |
| 30 #if !defined(OS_MACOSX) | 31 #if !defined(OS_MACOSX) |
| 31 #include "third_party/khronos/GLES2/gl2.h" | 32 #include "third_party/khronos/GLES2/gl2.h" |
| 32 #include "third_party/khronos/GLES2/gl2ext.h" | 33 #include "third_party/khronos/GLES2/gl2ext.h" |
| 33 #endif | 34 #endif |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 render_process_id_, render_frame_id, options)) { | 368 render_process_id_, render_frame_id, options)) { |
| 368 net::URLRequestContext* context = GetRequestContextForURL(url); | 369 net::URLRequestContext* context = GetRequestContextForURL(url); |
| 369 // Pass a null callback since we don't care about when the 'set' completes. | 370 // Pass a null callback since we don't care about when the 'set' completes. |
| 370 context->cookie_store()->SetCookieWithOptionsAsync( | 371 context->cookie_store()->SetCookieWithOptionsAsync( |
| 371 url, cookie, options, net::CookieStore::SetCookiesCallback()); | 372 url, cookie, options, net::CookieStore::SetCookiesCallback()); |
| 372 } | 373 } |
| 373 } | 374 } |
| 374 | 375 |
| 375 void RenderFrameMessageFilter::OnGetCookies(int render_frame_id, | 376 void RenderFrameMessageFilter::OnGetCookies(int render_frame_id, |
| 376 const GURL& url, | 377 const GURL& url, |
| 377 const GURL& first_party_for_cookies, | 378 const GURL& first_party_for_cookies, |
|
mmenke
2016/03/18 15:58:12
first_party_for_cookies is the main frame URL here
| |
| 378 IPC::Message* reply_msg) { | 379 IPC::Message* reply_msg) { |
| 379 ChildProcessSecurityPolicyImpl* policy = | 380 ChildProcessSecurityPolicyImpl* policy = |
| 380 ChildProcessSecurityPolicyImpl::GetInstance(); | 381 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 381 if (!policy->CanAccessDataForOrigin(render_process_id_, url)) { | 382 if (!policy->CanAccessDataForOrigin(render_process_id_, url)) { |
| 382 bad_message::ReceivedBadMessage(this, | 383 bad_message::ReceivedBadMessage(this, |
| 383 bad_message::RFMF_GET_COOKIES_BAD_ORIGIN); | 384 bad_message::RFMF_GET_COOKIES_BAD_ORIGIN); |
| 384 delete reply_msg; | 385 delete reply_msg; |
| 385 return; | 386 return; |
| 386 } | 387 } |
| 387 | 388 |
| 388 // If we crash here, figure out what URL the renderer was requesting. | 389 // If we crash here, figure out what URL the renderer was requesting. |
| 389 // http://crbug.com/99242 | 390 // http://crbug.com/99242 |
| 390 char url_buf[128]; | 391 char url_buf[128]; |
| 391 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); | 392 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); |
| 392 base::debug::Alias(url_buf); | 393 base::debug::Alias(url_buf); |
| 393 | 394 |
| 394 net::URLRequestContext* context = GetRequestContextForURL(url); | 395 net::URLRequestContext* context = GetRequestContextForURL(url); |
| 395 | 396 |
| 396 net::CookieOptions options; | 397 net::CookieOptions options; |
| 397 options.set_include_same_site(); | 398 if (net::registry_controlled_domains::SameDomainOrHost( |
| 399 url, first_party_for_cookies, | |
| 400 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)) { | |
| 401 // TODO(mkwst): This check ought to further distinguish between frames | |
| 402 // initiated in a strict or lax same-site context.,[ | |
|
Mike West
2016/03/18 14:27:17
Honestly, I need to think about whether or not thi
mmenke
2016/03/18 15:58:12
My feeling is that the cookies we send while reque
mmenke
2016/03/18 15:58:13
nit: Remove the ",["
| |
| 403 options.set_same_site_cookie_mode( | |
| 404 net::CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX); | |
| 405 } else { | |
| 406 options.set_same_site_cookie_mode( | |
| 407 net::CookieOptions::SameSiteCookieMode::DO_NOT_INCLUDE); | |
| 408 } | |
| 409 | |
| 398 context->cookie_store()->GetCookieListWithOptionsAsync( | 410 context->cookie_store()->GetCookieListWithOptionsAsync( |
| 399 url, options, | 411 url, options, |
| 400 base::Bind(&RenderFrameMessageFilter::CheckPolicyForCookies, this, | 412 base::Bind(&RenderFrameMessageFilter::CheckPolicyForCookies, this, |
| 401 render_frame_id, url, first_party_for_cookies, reply_msg)); | 413 render_frame_id, url, first_party_for_cookies, reply_msg)); |
| 402 } | 414 } |
| 403 | 415 |
| 404 void RenderFrameMessageFilter::OnCookiesEnabled( | 416 void RenderFrameMessageFilter::OnCookiesEnabled( |
| 405 int render_frame_id, | 417 int render_frame_id, |
| 406 const GURL& url, | 418 const GURL& url, |
| 407 const GURL& first_party_for_cookies, | 419 const GURL& first_party_for_cookies, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 648 net::URLRequestContext* context = | 660 net::URLRequestContext* context = |
| 649 GetContentClient()->browser()->OverrideRequestContextForURL( | 661 GetContentClient()->browser()->OverrideRequestContextForURL( |
| 650 url, resource_context_); | 662 url, resource_context_); |
| 651 if (!context) | 663 if (!context) |
| 652 context = request_context_->GetURLRequestContext(); | 664 context = request_context_->GetURLRequestContext(); |
| 653 | 665 |
| 654 return context; | 666 return context; |
| 655 } | 667 } |
| 656 | 668 |
| 657 } // namespace content | 669 } // namespace content |
| OLD | NEW |