| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_ | 6 #define CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/android/jni_weak_ref.h" | 10 #include "base/android/jni_weak_ref.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "net/cookies/canonical_cookie.h" | 13 #include "net/cookies/canonical_cookie.h" |
| 14 #include "net/url_request/url_request_context_getter.h" | 14 #include "net/url_request/url_request_context_getter.h" |
| 15 | 15 |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 // This class can be used to retrieve an array of cookies from the cookie jar | 18 // This class can be used to retrieve an array of cookies from the cookie jar |
| 19 // as well as insert an array of cookies into it. This class is the underlying | 19 // as well as insert an array of cookies into it. This class is the underlying |
| 20 // glue that interacts with CookiesFetch.java and its lifetime is governed by | 20 // glue that interacts with CookiesFetch.java and its lifetime is governed by |
| 21 // the Java counter part. | 21 // the Java counter part. |
| 22 class CookiesFetcher { | 22 class CookiesFetcher { |
| 23 public: | 23 public: |
| 24 // Constructs a fetcher that can interact with the cookie jar in the | 24 // Constructs a fetcher that can interact with the cookie jar in the |
| 25 // specified profile. | 25 // specified profile. |
| 26 explicit CookiesFetcher(JNIEnv* env, jobject obj, Profile* profile); | 26 explicit CookiesFetcher(JNIEnv* env, jobject obj, Profile* profile); |
| 27 | 27 |
| 28 ~CookiesFetcher(); | 28 ~CookiesFetcher(); |
| 29 | 29 |
| 30 // Called by the Java object when it is getting GC'd. | |
| 31 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
| 32 | |
| 33 // Callback used after the cookie jar populate the cookie list for us. | |
| 34 void OnCookiesFetchFinished(const net::CookieList& cookies); | |
| 35 | |
| 36 // Fetches all cookies from the cookie jar. | 30 // Fetches all cookies from the cookie jar. |
| 37 void PersistCookies(JNIEnv* env, | 31 void PersistCookies(JNIEnv* env, |
| 38 const base::android::JavaParamRef<jobject>& obj); | 32 const base::android::JavaParamRef<jobject>& obj); |
| 39 | 33 |
| 40 private: | 34 private: |
| 41 void PersistCookiesInternal(net::URLRequestContextGetter* getter); | 35 void PersistCookiesInternal(net::URLRequestContextGetter* getter); |
| 42 | 36 |
| 37 // Callback used after the cookie jar populate the cookie list for us. |
| 38 void OnCookiesFetchFinished(const net::CookieList& cookies); |
| 39 |
| 43 base::android::ScopedJavaGlobalRef<jobject> jobject_; | 40 base::android::ScopedJavaGlobalRef<jobject> jobject_; |
| 44 | 41 |
| 45 DISALLOW_COPY_AND_ASSIGN(CookiesFetcher); | 42 DISALLOW_COPY_AND_ASSIGN(CookiesFetcher); |
| 46 }; | 43 }; |
| 47 | 44 |
| 48 // Registers the CookiesFetcher native method. | 45 // Registers the CookiesFetcher native method. |
| 49 bool RegisterCookiesFetcher(JNIEnv* env); | 46 bool RegisterCookiesFetcher(JNIEnv* env); |
| 50 | 47 |
| 51 #endif // CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_ | 48 #endif // CHROME_BROWSER_ANDROID_COOKIES_COOKIES_FETCHER_H_ |
| OLD | NEW |