Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: android_webview/native/cookie_manager.cc

Issue 2817343002: Allow WebView setCookie api to set secure cookies for http urls. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 382
383 void CookieManager::SetCookieHelper( 383 void CookieManager::SetCookieHelper(
384 const GURL& host, 384 const GURL& host,
385 const std::string& value, 385 const std::string& value,
386 const BoolCallback callback) { 386 const BoolCallback callback) {
387 net::CookieOptions options; 387 net::CookieOptions options;
388 options.set_include_httponly(); 388 options.set_include_httponly();
389 389
390 // Log message for catching strict secure cookies related bugs. 390 // Log message for catching strict secure cookies related bugs.
391 if (!host.has_scheme() || host.SchemeIs(url::kHttpScheme)) { 391 // TODO(sgurun) temporary. Add UMA stats to monitor, and remove afterwards.
392 if (host.is_valid() &&
393 (!host.has_scheme() || host.SchemeIs(url::kHttpScheme))) {
392 net::ParsedCookie parsed_cookie(value); 394 net::ParsedCookie parsed_cookie(value);
393 if (parsed_cookie.IsValid() && parsed_cookie.IsSecure()) { 395 if (parsed_cookie.IsValid() && parsed_cookie.IsSecure()) {
394 LOG(WARNING) << "Strict Secure Cookie policy does not allow setting a " 396 LOG(WARNING) << "Strict Secure Cookie policy does not allow setting a "
395 "secure cookie for " 397 "secure cookie for "
396 << host.spec(); 398 << host.spec();
399 GURL::Replacements replace_host;
400 replace_host.SetSchemeStr("https");
401 GURL new_host = host.ReplaceComponents(replace_host);
402 GetCookieStore()->SetCookieWithOptionsAsync(new_host, value, options,
403 callback);
404 return;
397 } 405 }
398 } 406 }
399 407
400 GetCookieStore()->SetCookieWithOptionsAsync(host, value, options, callback); 408 GetCookieStore()->SetCookieWithOptionsAsync(host, value, options, callback);
401 } 409 }
402 410
403 std::string CookieManager::GetCookie(const GURL& host) { 411 std::string CookieManager::GetCookie(const GURL& host) {
404 std::string cookie_value; 412 std::string cookie_value;
405 ExecCookieTaskSync(base::Bind(&CookieManager::GetCookieValueAsyncHelper, 413 ExecCookieTaskSync(base::Bind(&CookieManager::GetCookieValueAsyncHelper,
406 base::Unretained(this), 414 base::Unretained(this),
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 638
631 net::CookieStore* GetCookieStore() { 639 net::CookieStore* GetCookieStore() {
632 return CookieManager::GetInstance()->GetCookieStore(); 640 return CookieManager::GetInstance()->GetCookieStore();
633 } 641 }
634 642
635 bool RegisterCookieManager(JNIEnv* env) { 643 bool RegisterCookieManager(JNIEnv* env) {
636 return RegisterNativesImpl(env); 644 return RegisterNativesImpl(env);
637 } 645 }
638 646
639 } // android_webview namespace 647 } // android_webview namespace
OLDNEW
« no previous file with comments | « android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698