Chromium Code Reviews| 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 "android_webview/browser/aw_cookie_access_policy.h" | 5 #include "android_webview/browser/aw_cookie_access_policy.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_contents_io_thread_client.h" | 9 #include "android_webview/browser/aw_contents_io_thread_client.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/resource_request_info.h" | 12 #include "content/public/browser/resource_request_info.h" |
| 13 #include "content/public/browser/websocket_handshake_request_info.h" | |
| 13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 14 | 15 |
| 15 using base::AutoLock; | 16 using base::AutoLock; |
| 16 using content::BrowserThread; | 17 using content::BrowserThread; |
| 17 using content::ResourceRequestInfo; | 18 using content::ResourceRequestInfo; |
| 19 using content::WebSocketHandshakeRequestInfo; | |
| 18 using net::StaticCookiePolicy; | 20 using net::StaticCookiePolicy; |
| 19 | 21 |
| 20 namespace android_webview { | 22 namespace android_webview { |
| 21 | 23 |
| 22 namespace { | 24 namespace { |
| 23 base::LazyInstance<AwCookieAccessPolicy>::Leaky g_lazy_instance; | 25 base::LazyInstance<AwCookieAccessPolicy>::Leaky g_lazy_instance; |
| 24 } // namespace | 26 } // namespace |
| 25 | 27 |
| 26 AwCookieAccessPolicy::~AwCookieAccessPolicy() { | 28 AwCookieAccessPolicy::~AwCookieAccessPolicy() { |
| 27 } | 29 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 50 std::unique_ptr<AwContentsIoThreadClient> io_thread_client = | 52 std::unique_ptr<AwContentsIoThreadClient> io_thread_client = |
| 51 AwContentsIoThreadClient::FromID(render_process_id, render_frame_id); | 53 AwContentsIoThreadClient::FromID(render_process_id, render_frame_id); |
| 52 if (!io_thread_client) { | 54 if (!io_thread_client) { |
| 53 return false; | 55 return false; |
| 54 } | 56 } |
| 55 return io_thread_client->ShouldAcceptThirdPartyCookies(); | 57 return io_thread_client->ShouldAcceptThirdPartyCookies(); |
| 56 } | 58 } |
| 57 | 59 |
| 58 bool AwCookieAccessPolicy::GetShouldAcceptThirdPartyCookies( | 60 bool AwCookieAccessPolicy::GetShouldAcceptThirdPartyCookies( |
| 59 const net::URLRequest& request) { | 61 const net::URLRequest& request) { |
| 62 bool has_id = false; | |
| 63 int child_id = 0; | |
| 64 int frame_id = 0; | |
| 60 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); | 65 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request); |
| 61 if (!info) { | 66 if (info) { |
| 67 has_id = true; | |
| 68 child_id = info->GetChildID(); | |
| 69 frame_id = info->GetRenderFrameID(); | |
| 70 } else { | |
| 71 const WebSocketHandshakeRequestInfo* websocketInfo = | |
|
Adam Rice
2016/10/12 06:38:25
s/websocketInfo/websocket_info/?
yhirano
2016/10/12 10:47:15
Done.
| |
| 72 WebSocketHandshakeRequestInfo::ForRequest(&request); | |
| 73 if (websocketInfo) { | |
|
Adam Rice
2016/10/12 06:38:25
Maybe instead write
if (!websocket_info)
return
yhirano
2016/10/12 10:47:15
Done.
| |
| 74 has_id = true; | |
| 75 child_id = websocketInfo->GetChildId(); | |
| 76 frame_id = websocketInfo->GetFrameId(); | |
| 77 } | |
| 78 } | |
| 79 if (!has_id) | |
| 62 return false; | 80 return false; |
| 63 } | 81 return GetShouldAcceptThirdPartyCookies(child_id, frame_id); |
| 64 return GetShouldAcceptThirdPartyCookies(info->GetChildID(), | |
| 65 info->GetRenderFrameID()); | |
| 66 } | 82 } |
| 67 | 83 |
| 68 bool AwCookieAccessPolicy::OnCanGetCookies(const net::URLRequest& request, | 84 bool AwCookieAccessPolicy::OnCanGetCookies(const net::URLRequest& request, |
| 69 const net::CookieList& cookie_list) { | 85 const net::CookieList& cookie_list) { |
| 70 bool global = GetShouldAcceptCookies(); | 86 bool global = GetShouldAcceptCookies(); |
| 71 bool thirdParty = GetShouldAcceptThirdPartyCookies(request); | 87 bool thirdParty = GetShouldAcceptThirdPartyCookies(request); |
| 72 return AwStaticCookiePolicy(global, thirdParty) | 88 return AwStaticCookiePolicy(global, thirdParty) |
| 73 .AllowGet(request.url(), request.first_party_for_cookies()); | 89 .AllowGet(request.url(), request.first_party_for_cookies()); |
| 74 } | 90 } |
| 75 | 91 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 net::OK; | 152 net::OK; |
| 137 } | 153 } |
| 138 | 154 |
| 139 bool AwStaticCookiePolicy::AllowGet(const GURL& url, | 155 bool AwStaticCookiePolicy::AllowGet(const GURL& url, |
| 140 const GURL& first_party) const { | 156 const GURL& first_party) const { |
| 141 return StaticCookiePolicy(GetPolicy(url)).CanGetCookies(url, first_party) == | 157 return StaticCookiePolicy(GetPolicy(url)).CanGetCookies(url, first_party) == |
| 142 net::OK; | 158 net::OK; |
| 143 } | 159 } |
| 144 | 160 |
| 145 } // namespace android_webview | 161 } // namespace android_webview |
| OLD | NEW |