| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/native/cookie_manager.h" | 5 #include "android_webview/native/cookie_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 380 } |
| 381 | 381 |
| 382 void CookieManager::SetCookieHelper( | 382 void CookieManager::SetCookieHelper( |
| 383 const GURL& host, | 383 const GURL& host, |
| 384 const std::string& value, | 384 const std::string& value, |
| 385 const BoolCallback callback) { | 385 const BoolCallback callback) { |
| 386 net::CookieOptions options; | 386 net::CookieOptions options; |
| 387 options.set_include_httponly(); | 387 options.set_include_httponly(); |
| 388 | 388 |
| 389 // Log message for catching strict secure cookies related bugs. | 389 // Log message for catching strict secure cookies related bugs. |
| 390 if (!host.has_scheme() || host.SchemeIs(url::kHttpScheme)) { | 390 // TODO(sgurun) temporary. Add UMA stats to monitor, and remove afterwards. |
| 391 if (host.is_valid() && |
| 392 (!host.has_scheme() || host.SchemeIs(url::kHttpScheme))) { |
| 391 net::ParsedCookie parsed_cookie(value); | 393 net::ParsedCookie parsed_cookie(value); |
| 392 if (parsed_cookie.IsValid() && parsed_cookie.IsSecure()) { | 394 if (parsed_cookie.IsValid() && parsed_cookie.IsSecure()) { |
| 393 LOG(WARNING) << "Strict Secure Cookie policy does not allow setting a " | 395 LOG(WARNING) << "Strict Secure Cookie policy does not allow setting a " |
| 394 "secure cookie for " | 396 "secure cookie for " |
| 395 << host.spec(); | 397 << host.spec(); |
| 398 GURL::Replacements replace_host; |
| 399 replace_host.SetSchemeStr("https"); |
| 400 GURL new_host = host.ReplaceComponents(replace_host); |
| 401 GetCookieStore()->SetCookieWithOptionsAsync(new_host, value, options, |
| 402 callback); |
| 403 return; |
| 396 } | 404 } |
| 397 } | 405 } |
| 398 | 406 |
| 399 GetCookieStore()->SetCookieWithOptionsAsync(host, value, options, callback); | 407 GetCookieStore()->SetCookieWithOptionsAsync(host, value, options, callback); |
| 400 } | 408 } |
| 401 | 409 |
| 402 std::string CookieManager::GetCookie(const GURL& host) { | 410 std::string CookieManager::GetCookie(const GURL& host) { |
| 403 std::string cookie_value; | 411 std::string cookie_value; |
| 404 ExecCookieTaskSync(base::Bind(&CookieManager::GetCookieValueAsyncHelper, | 412 ExecCookieTaskSync(base::Bind(&CookieManager::GetCookieValueAsyncHelper, |
| 405 base::Unretained(this), | 413 base::Unretained(this), |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 637 |
| 630 net::CookieStore* GetCookieStore() { | 638 net::CookieStore* GetCookieStore() { |
| 631 return CookieManager::GetInstance()->GetCookieStore(); | 639 return CookieManager::GetInstance()->GetCookieStore(); |
| 632 } | 640 } |
| 633 | 641 |
| 634 bool RegisterCookieManager(JNIEnv* env) { | 642 bool RegisterCookieManager(JNIEnv* env) { |
| 635 return RegisterNativesImpl(env); | 643 return RegisterNativesImpl(env); |
| 636 } | 644 } |
| 637 | 645 |
| 638 } // android_webview namespace | 646 } // android_webview namespace |
| OLD | NEW |