1 // Copyright 2015 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 #ifndef CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_
6 #define CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_
8 #include "base/android/jni_weak_ref.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/basictypes.h"
11 #include "net/cookies/canonical_cookie.h"
12 #include "net/url_request/url_request_context_getter.h"
16 // This class can be used to retrieve an array of cookies from the cookie jar
17 // as well as insert an array of cookies into it. This class is the underlying
18 // glue that interacts with CookiesFetch.java and its lifetime is governed by
19 // the Java counter part.
20 class CookiesFetcher
{
22 // Constructs a fetcher that can interact with the cookie jar in the
24 explicit CookiesFetcher(JNIEnv
* env
, jobject obj
, Profile
* profile
);
28 // Called by the Java object when it is getting GC'd.
29 void Destroy(JNIEnv
* env
, jobject obj
);
31 // Callback used after the cookie jar populate the cookie list for us.
32 void OnCookiesFetchFinished(const net::CookieList
& cookies
);
34 // Fetches all cookies from the cookie jar.
35 void PersistCookies(JNIEnv
* env
, jobject obj
);
37 // Saves a cookie to the cookie jar.
38 void RestoreCookies(JNIEnv
* env
,
54 void PersistCookiesInternal(net::URLRequestContextGetter
* getter
);
55 void RestoreToCookieJarInternal(net::URLRequestContextGetter
* getter
,
56 const net::CanonicalCookie
& cookie
);
58 base::android::ScopedJavaGlobalRef
<jobject
> jobject_
;
60 DISALLOW_COPY_AND_ASSIGN(CookiesFetcher
);
63 // Registers the CookiesFetcher native method.
64 bool RegisterCookiesFetcher(JNIEnv
* env
);
66 #endif // CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_