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_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_
8 #include "base/android/jni_android.h"
9 #include "base/android/jni_weak_ref.h"
10 #include "components/offline_pages/offline_page_model.h"
20 namespace offline_pages
{
24 * Bridge between C++ and Java for exposing native implementation of offline
25 * pages model in managed code.
27 class OfflinePageBridge
: public OfflinePageModel::Observer
{
29 // Returns true if |url| might points to an offline page.
30 static bool MightBeOfflineURL(const GURL
& url
);
32 OfflinePageBridge(JNIEnv
* env
,
34 content::BrowserContext
* browser_context
);
35 void Destroy(JNIEnv
*, jobject
);
37 // OfflinePageModel::Observer implementation.
38 void OfflinePageModelLoaded(OfflinePageModel
* model
) override
;
40 void GetAllPages(JNIEnv
* env
,
42 jobject j_result_obj
);
43 void GetPagesToCleanUp(JNIEnv
* env
, jobject obj
, jobject j_result_obj
);
45 base::android::ScopedJavaLocalRef
<jobject
>
46 GetPageByBookmarkId(JNIEnv
* env
, jobject obj
, jlong bookmark_id
);
48 void SavePage(JNIEnv
* env
,
50 jobject j_callback_obj
,
51 jobject j_web_contents
,
54 void DeletePage(JNIEnv
* env
,
56 jobject j_callback_obj
,
59 void DeletePages(JNIEnv
* env
,
61 jobject j_callback_obj
,
62 jlongArray bookmark_ids_array
);
65 void NotifyIfDoneLoading() const;
66 static base::FilePath
GetDownloadsPath(
67 content::BrowserContext
* browser_context
);
69 JavaObjectWeakGlobalRef weak_java_ref_
;
71 OfflinePageModel
* offline_page_model_
;
73 content::BrowserContext
* browser_context_
;
74 DISALLOW_COPY_AND_ASSIGN(OfflinePageBridge
);
77 bool RegisterOfflinePageBridge(JNIEnv
* env
);
79 } // namespace android
80 } // namespace offline_pages
82 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_BRIDGE_H_