1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mojo/services/network/cookie_store_impl.h"
7 #include "mojo/common/common_type_converters.h"
8 #include "mojo/services/network/network_context.h"
9 #include "net/cookies/cookie_store.h"
10 #include "net/url_request/url_request_context.h"
15 void AdaptGetCookiesCallback(const Callback
<void(String
)>& callback
,
16 const std::string
& cookies
) {
17 callback
.Run(cookies
);
20 void AdaptSetCookieCallback(const Callback
<void(bool)>& callback
,
22 callback
.Run(success
);
27 CookieStoreImpl::CookieStoreImpl(NetworkContext
* context
,
33 CookieStoreImpl::~CookieStoreImpl() {
36 void CookieStoreImpl::Get(const String
& url
,
37 const Callback
<void(String
)>& callback
) {
38 // TODO(darin): Perform origin restriction.
39 net::CookieStore
* store
= context_
->url_request_context()->cookie_store();
41 callback
.Run(String());
44 store
->GetCookiesWithOptionsAsync(
47 base::Bind(&AdaptGetCookiesCallback
, callback
));
50 void CookieStoreImpl::Set(const String
& url
,
52 const Callback
<void(bool)>& callback
) {
53 // TODO(darin): Perform origin restriction.
54 net::CookieStore
* store
= context_
->url_request_context()->cookie_store();
59 store
->SetCookieWithOptionsAsync(
63 base::Bind(&AdaptSetCookieCallback
, callback
));