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

Side by Side Diff: chrome/browser/extensions/api/cookies/cookies_api.cc

Issue 1393193005: Implement $Secure- cookie prefix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fix Created 5 years, 2 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
OLDNEW
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 <vector> 9 #include <vector>
10 10
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 base::Time expiration_time; 375 base::Time expiration_time;
376 if (parsed_args_->details.expiration_date.get()) { 376 if (parsed_args_->details.expiration_date.get()) {
377 // Time::FromDoubleT converts double time 0 to empty Time object. So we need 377 // Time::FromDoubleT converts double time 0 to empty Time object. So we need
378 // to do special handling here. 378 // to do special handling here.
379 expiration_time = (*parsed_args_->details.expiration_date == 0) ? 379 expiration_time = (*parsed_args_->details.expiration_date == 0) ?
380 base::Time::UnixEpoch() : 380 base::Time::UnixEpoch() :
381 base::Time::FromDoubleT(*parsed_args_->details.expiration_date); 381 base::Time::FromDoubleT(*parsed_args_->details.expiration_date);
382 } 382 }
383 383
384 cookie_monster->SetCookieWithDetailsAsync( 384 cookie_monster->SetCookieWithDetailsAsync(
385 url_, 385 url_, parsed_args_->details.name.get() ? *parsed_args_->details.name
386 parsed_args_->details.name.get() ? *parsed_args_->details.name 386 : std::string(),
387 : std::string(),
388 parsed_args_->details.value.get() ? *parsed_args_->details.value 387 parsed_args_->details.value.get() ? *parsed_args_->details.value
389 : std::string(), 388 : std::string(),
390 parsed_args_->details.domain.get() ? *parsed_args_->details.domain 389 parsed_args_->details.domain.get() ? *parsed_args_->details.domain
391 : std::string(), 390 : std::string(),
392 parsed_args_->details.path.get() ? *parsed_args_->details.path 391 parsed_args_->details.path.get() ? *parsed_args_->details.path
393 : std::string(), 392 : std::string(),
394 expiration_time, 393 expiration_time,
395 parsed_args_->details.secure.get() ? *parsed_args_->details.secure.get() 394 parsed_args_->details.secure.get() ? *parsed_args_->details.secure.get()
396 : false, 395 : false,
397 parsed_args_->details.http_only.get() ? *parsed_args_->details.http_only 396 parsed_args_->details.http_only.get() ? *parsed_args_->details.http_only
398 : false, 397 : false,
399 // TODO(mkwst): If we decide to ship First-party-only cookies, we'll need 398 // TODO(mkwst): If we decide to ship First-party-only cookies, we'll need
400 // to extend the extension API to support them. For the moment, we'll set 399 // to extend the extension API to support them. For the moment, we'll set
401 // all cookies as non-First-party-only. 400 // all cookies as non-First-party-only.
402 false, 401 false, store_browser_context_->GetURLRequestContext()
402 ->network_delegate()
403 ->AreExperimentalCookieFeaturesEnabled(),
403 net::COOKIE_PRIORITY_DEFAULT, 404 net::COOKIE_PRIORITY_DEFAULT,
404 base::Bind(&CookiesSetFunction::PullCookie, this)); 405 base::Bind(&CookiesSetFunction::PullCookie, this));
405 } 406 }
406 407
407 void CookiesSetFunction::PullCookie(bool set_cookie_result) { 408 void CookiesSetFunction::PullCookie(bool set_cookie_result) {
408 // Pull the newly set cookie. 409 // Pull the newly set cookie.
409 net::CookieMonster* cookie_monster = 410 net::CookieMonster* cookie_monster =
410 store_browser_context_->GetURLRequestContext() 411 store_browser_context_->GetURLRequestContext()
411 ->cookie_store() 412 ->cookie_store()
412 ->GetCookieMonster(); 413 ->GetCookieMonster();
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() { 579 BrowserContextKeyedAPIFactory<CookiesAPI>* CookiesAPI::GetFactoryInstance() {
579 return g_factory.Pointer(); 580 return g_factory.Pointer();
580 } 581 }
581 582
582 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) { 583 void CookiesAPI::OnListenerAdded(const EventListenerInfo& details) {
583 cookies_event_router_.reset(new CookiesEventRouter(browser_context_)); 584 cookies_event_router_.reset(new CookiesEventRouter(browser_context_));
584 EventRouter::Get(browser_context_)->UnregisterObserver(this); 585 EventRouter::Get(browser_context_)->UnregisterObserver(this);
585 } 586 }
586 587
587 } // namespace extensions 588 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698