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