Rename GetIconID to GetIconId
[chromium-blink-merge.git] / chrome / browser / android / cookies / cookies_fetcher.h
blob2601670f405867f99bf3a9b8b414efd71dbee583
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"
14 class Profile;
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 {
21 public:
22 // Constructs a fetcher that can interact with the cookie jar in the
23 // specified profile.
24 explicit CookiesFetcher(JNIEnv* env, jobject obj, Profile* profile);
26 ~CookiesFetcher();
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,
39 jobject obj,
40 jstring url,
41 jstring name,
42 jstring value,
43 jstring domain,
44 jstring path,
45 int64 creation,
46 int64 expiration,
47 int64 last_access,
48 bool secure,
49 bool httponly,
50 bool firstpartyonly,
51 int priority);
53 private:
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_