| 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_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "components/offline_pages/offline_page_model.h" | 10 #include "components/offline_pages/offline_page_model.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class FilePath; | 13 class FilePath; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace offline_pages { | 20 namespace offline_pages { |
| 21 namespace android { | 21 namespace android { |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Bridge between C++ and Java for exposing native implementation of offline | 24 * Bridge between C++ and Java for exposing native implementation of offline |
| 25 * pages model in managed code. | 25 * pages model in managed code. |
| 26 */ | 26 */ |
| 27 class OfflinePageBridge : public OfflinePageModel::Observer { | 27 class OfflinePageBridge : public OfflinePageModel::Observer { |
| 28 public: | 28 public: |
| 29 // Returns true if |url| might points to an offline page. |
| 30 static bool MightBeOfflineURL(const GURL& url); |
| 31 |
| 29 OfflinePageBridge(JNIEnv* env, | 32 OfflinePageBridge(JNIEnv* env, |
| 30 jobject obj, | 33 jobject obj, |
| 31 content::BrowserContext* browser_context); | 34 content::BrowserContext* browser_context); |
| 32 void Destroy(JNIEnv*, jobject); | 35 void Destroy(JNIEnv*, jobject); |
| 33 | 36 |
| 34 // OfflinePageModel::Observer implementation. | 37 // OfflinePageModel::Observer implementation. |
| 35 void OfflinePageModelLoaded(OfflinePageModel* model) override; | 38 void OfflinePageModelLoaded(OfflinePageModel* model) override; |
| 36 | 39 |
| 37 void GetAllPages(JNIEnv* env, | 40 void GetAllPages(JNIEnv* env, |
| 38 jobject obj, | 41 jobject obj, |
| 39 jobject j_result_obj); | 42 jobject j_result_obj); |
| 43 void GetPagesToCleanUp(JNIEnv* env, jobject obj, jobject j_result_obj); |
| 40 | 44 |
| 41 base::android::ScopedJavaLocalRef<jobject> | 45 base::android::ScopedJavaLocalRef<jobject> |
| 42 GetPageByBookmarkId(JNIEnv* env, jobject obj, jlong bookmark_id); | 46 GetPageByBookmarkId(JNIEnv* env, jobject obj, jlong bookmark_id); |
| 43 | 47 |
| 44 void SavePage(JNIEnv* env, | 48 void SavePage(JNIEnv* env, |
| 45 jobject obj, | 49 jobject obj, |
| 46 jobject j_callback_obj, | 50 jobject j_callback_obj, |
| 47 jobject j_web_contents, | 51 jobject j_web_contents, |
| 48 jlong bookmark_id); | 52 jlong bookmark_id); |
| 49 | 53 |
| 50 void DeletePage(JNIEnv* env, | 54 void DeletePage(JNIEnv* env, |
| 51 jobject obj, | 55 jobject obj, |
| 52 jobject j_callback_obj, | 56 jobject j_callback_obj, |
| 53 jlong bookmark_id); | 57 jlong bookmark_id); |
| 54 | 58 |
| 55 // Returns true if |url| might points to an offline page. | 59 void DeletePages(JNIEnv* env, |
| 56 static bool MightBeOfflineURL(const GURL& url); | 60 jobject obj, |
| 61 jobject j_callback_obj, |
| 62 jlongArray bookmark_ids_array); |
| 57 | 63 |
| 58 private: | 64 private: |
| 59 void NotifyIfDoneLoading() const; | 65 void NotifyIfDoneLoading() const; |
| 60 static base::FilePath GetDownloadsPath( | 66 static base::FilePath GetDownloadsPath( |
| 61 content::BrowserContext* browser_context); | 67 content::BrowserContext* browser_context); |
| 62 | 68 |
| 63 JavaObjectWeakGlobalRef weak_java_ref_; | 69 JavaObjectWeakGlobalRef weak_java_ref_; |
| 64 // Not owned. | 70 // Not owned. |
| 65 OfflinePageModel* offline_page_model_; | 71 OfflinePageModel* offline_page_model_; |
| 66 // Not owned. | 72 // Not owned. |
| 67 content::BrowserContext* browser_context_; | 73 content::BrowserContext* browser_context_; |
| 68 DISALLOW_COPY_AND_ASSIGN(OfflinePageBridge); | 74 DISALLOW_COPY_AND_ASSIGN(OfflinePageBridge); |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 bool RegisterOfflinePageBridge(JNIEnv* env); | 77 bool RegisterOfflinePageBridge(JNIEnv* env); |
| 72 | 78 |
| 73 } // namespace android | 79 } // namespace android |
| 74 } // namespace offline_pages | 80 } // namespace offline_pages |
| 75 | 81 |
| 76 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_ | 82 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_ |
| 77 | 83 |
| OLD | NEW |