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

Side by Side Diff: mojo/services/html_viewer/webcookiejar_impl.cc

Issue 409883007: Mojo: add support for cookies to HTMLViewer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing files Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "mojo/services/html_viewer/webcookiejar_impl.h"
6
7 #include "base/bind.h"
8 #include "third_party/WebKit/public/platform/WebURL.h"
9
10 namespace mojo {
11 namespace {
12
13 void CopyBool(bool* output, bool input) {
14 *output = input;
15 }
16
17 void CopyString(String* output, const String& input) {
18 *output = input;
19 }
20
21 } // namespace
22
23 WebCookieJarImpl::WebCookieJarImpl(CookieStorePtr store)
24 : store_(store.Pass()) {
25 }
26
27 WebCookieJarImpl::~WebCookieJarImpl() {
28 }
29
30 void WebCookieJarImpl::setCookie(const blink::WebURL& url,
31 const blink::WebURL& first_party_for_cookies,
32 const blink::WebString& cookie) {
33 bool success;
34 store_->Set(url.string().utf8(), cookie.utf8(),
35 base::Bind(&CopyBool, &success));
36
37 // Wait to ensure the cookie was set before advancing. That way any
jamesr 2014/07/22 23:53:44 in content's cookie jar Gets are blocking but Sets
38 // subsequent URL request will see the changes to the cookie store.
39 store_.WaitForIncomingMethodCall();
40 }
41
42 blink::WebString WebCookieJarImpl::cookies(
43 const blink::WebURL& url,
44 const blink::WebURL& first_party_for_cookies) {
45 String result;
46 store_->Get(url.string().utf8(), base::Bind(&CopyString, &result));
47
48 // Wait for the result. Since every outbound request we make to the cookie
49 // store is followed up with WaitForIncomingMethodCall, we can be sure that
50 // the next incoming method call will be the response to our request.
51 store_.WaitForIncomingMethodCall();
jamesr 2014/07/22 23:53:44 or is it that if we allow multiple set calls to be
52 if (!result)
53 return blink::WebString();
54
55 return blink::WebString::fromUTF8(result);
56 }
57
58 blink::WebString WebCookieJarImpl::cookieRequestHeaderFieldValue(
59 const blink::WebURL& url,
60 const blink::WebURL& first_party_for_cookies) {
61 return cookies(url, first_party_for_cookies);
62 }
63
64 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698