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 // Implements the Chrome Extensions Cookies API. | 5 // Implements the Chrome Extensions Cookies API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/cookies/cookies_api.h" | 7 #include "chrome/browser/extensions/api/cookies/cookies_api.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 same_site = net::CookieSameSite::DEFAULT_MODE; | 384 same_site = net::CookieSameSite::DEFAULT_MODE; |
385 break; | 385 break; |
386 case cookies::SAME_SITE_STATUS_LAX: | 386 case cookies::SAME_SITE_STATUS_LAX: |
387 same_site = net::CookieSameSite::LAX_MODE; | 387 same_site = net::CookieSameSite::LAX_MODE; |
388 break; | 388 break; |
389 case cookies::SAME_SITE_STATUS_STRICT: | 389 case cookies::SAME_SITE_STATUS_STRICT: |
390 same_site = net::CookieSameSite::STRICT_MODE; | 390 same_site = net::CookieSameSite::STRICT_MODE; |
391 break; | 391 break; |
392 } | 392 } |
393 | 393 |
394 bool are_experimental_cookie_features_enabled = | |
395 store_browser_context_->GetURLRequestContext() | |
396 ->network_delegate() | |
397 ->AreExperimentalCookieFeaturesEnabled(); | |
398 | |
399 // clang-format off | 394 // clang-format off |
400 cookie_store->SetCookieWithDetailsAsync( | 395 cookie_store->SetCookieWithDetailsAsync( |
401 url_, parsed_args_->details.name.get() ? *parsed_args_->details.name | 396 url_, parsed_args_->details.name.get() ? *parsed_args_->details.name |
402 : std::string(), | 397 : std::string(), |
403 parsed_args_->details.value.get() ? *parsed_args_->details.value | 398 parsed_args_->details.value.get() ? *parsed_args_->details.value |
404 : std::string(), | 399 : std::string(), |
405 parsed_args_->details.domain.get() ? *parsed_args_->details.domain | 400 parsed_args_->details.domain.get() ? *parsed_args_->details.domain |
406 : std::string(), | 401 : std::string(), |
407 parsed_args_->details.path.get() ? *parsed_args_->details.path | 402 parsed_args_->details.path.get() ? *parsed_args_->details.path |
408 : std::string(), | 403 : std::string(), |
409 base::Time(), | 404 base::Time(), |
410 expiration_time, | 405 expiration_time, |
411 base::Time(), | 406 base::Time(), |
412 parsed_args_->details.secure.get() ? *parsed_args_->details.secure | 407 parsed_args_->details.secure.get() ? *parsed_args_->details.secure |
413 : false, | 408 : false, |
414 parsed_args_->details.http_only.get() ? *parsed_args_->details.http_only | 409 parsed_args_->details.http_only.get() ? *parsed_args_->details.http_only |
415 : false, | 410 : false, |
416 same_site, | 411 same_site, |
417 are_experimental_cookie_features_enabled, | |
418 net::COOKIE_PRIORITY_DEFAULT, | 412 net::COOKIE_PRIORITY_DEFAULT, |
419 base::Bind(&CookiesSetFunction::PullCookie, this)); | 413 base::Bind(&CookiesSetFunction::PullCookie, this)); |
420 // clang-format on | 414 // clang-format on |
421 } | 415 } |
422 | 416 |
423 void CookiesSetFunction::PullCookie(bool set_cookie_result) { | 417 void CookiesSetFunction::PullCookie(bool set_cookie_result) { |
424 // Pull the newly set cookie. | 418 // Pull the newly set cookie. |
425 net::CookieStore* cookie_store = | 419 net::CookieStore* cookie_store = |
426 store_browser_context_->GetURLRequestContext()->cookie_store(); | 420 store_browser_context_->GetURLRequestContext()->cookie_store(); |
427 success_ = set_cookie_result; | 421 success_ = set_cookie_result; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { | 582 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { |
589 return g_factory.Pointer(); | 583 return g_factory.Pointer(); |
590 } | 584 } |
591 | 585 |
592 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { | 586 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { |
593 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); | 587 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); |
594 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 588 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
595 } | 589 } |
596 | 590 |
597 } // namespace extensions | 591 } // namespace extensions |
OLD | NEW |