OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "mojo/services/network/cookie_store_impl.h" | 5 #include "mojo/services/network/cookie_store_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "mojo/common/url_type_converters.h" | 9 #include "mojo/common/url_type_converters.h" |
8 #include "mojo/services/network/network_context.h" | 10 #include "mojo/services/network/network_context.h" |
9 #include "net/cookies/cookie_store.h" | 11 #include "net/cookies/cookie_store.h" |
10 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request_context.h" |
11 | 13 |
12 namespace mojo { | 14 namespace mojo { |
13 namespace { | 15 namespace { |
14 | 16 |
15 void AdaptGetCookiesCallback(const Callback<void(String)>& callback, | 17 void AdaptGetCookiesCallback(const Callback<void(String)>& callback, |
16 const std::string& cookies) { | 18 const std::string& cookies) { |
17 callback.Run(cookies); | 19 callback.Run(cookies); |
18 } | 20 } |
19 | 21 |
20 void AdaptSetCookieCallback(const Callback<void(bool)>& callback, | 22 void AdaptSetCookieCallback(const Callback<void(bool)>& callback, |
21 bool success) { | 23 bool success) { |
22 callback.Run(success); | 24 callback.Run(success); |
23 } | 25 } |
24 | 26 |
25 } // namespace | 27 } // namespace |
26 | 28 |
27 CookieStoreImpl::CookieStoreImpl( | 29 CookieStoreImpl::CookieStoreImpl(NetworkContext* context, |
28 NetworkContext* context, | 30 const GURL& origin, |
29 const GURL& origin, | 31 scoped_ptr<mojo::AppRefCount> app_refcount, |
30 scoped_ptr<mojo::AppRefCount> app_refcount, | 32 InterfaceRequest<CookieStore> request) |
31 InterfaceRequest<CookieStore> request) | |
32 : context_(context), | 33 : context_(context), |
33 origin_(origin), | 34 origin_(origin), |
34 app_refcount_(app_refcount.Pass()), | 35 app_refcount_(std::move(app_refcount)), |
35 binding_(this, request.Pass()) { | 36 binding_(this, std::move(request)) {} |
36 } | |
37 | 37 |
38 CookieStoreImpl::~CookieStoreImpl() { | 38 CookieStoreImpl::~CookieStoreImpl() { |
39 } | 39 } |
40 | 40 |
41 void CookieStoreImpl::Get(const String& url, | 41 void CookieStoreImpl::Get(const String& url, |
42 const Callback<void(String)>& callback) { | 42 const Callback<void(String)>& callback) { |
43 // TODO(darin): Perform origin restriction. | 43 // TODO(darin): Perform origin restriction. |
44 net::CookieStore* store = context_->url_request_context()->cookie_store(); | 44 net::CookieStore* store = context_->url_request_context()->cookie_store(); |
45 if (!store) { | 45 if (!store) { |
46 callback.Run(String()); | 46 callback.Run(String()); |
(...skipping 15 matching lines...) Expand all Loading... |
62 return; | 62 return; |
63 } | 63 } |
64 store->SetCookieWithOptionsAsync( | 64 store->SetCookieWithOptionsAsync( |
65 url.To<GURL>(), | 65 url.To<GURL>(), |
66 cookie, | 66 cookie, |
67 net::CookieOptions(), | 67 net::CookieOptions(), |
68 base::Bind(&AdaptSetCookieCallback, callback)); | 68 base::Bind(&AdaptSetCookieCallback, callback)); |
69 } | 69 } |
70 | 70 |
71 } // namespace mojo | 71 } // namespace mojo |
OLD | NEW |