Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / android / offline_pages / offline_page_bridge.h
bloba0b3007a70415539b131c2e3bc6d05a81baee0ff
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"
12 namespace base {
13 class FilePath;
16 namespace content {
17 class BrowserContext;
20 namespace offline_pages {
21 namespace android {
23 /**
24 * Bridge between C++ and Java for exposing native implementation of offline
25 * pages model in managed code.
27 class OfflinePageBridge : public OfflinePageModel::Observer {
28 public:
29 // Returns true if |url| might points to an offline page.
30 static bool MightBeOfflineURL(const GURL& url);
32 OfflinePageBridge(JNIEnv* env,
33 jobject obj,
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,
41 jobject obj,
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,
49 jobject obj,
50 jobject j_callback_obj,
51 jobject j_web_contents,
52 jlong bookmark_id);
54 void DeletePage(JNIEnv* env,
55 jobject obj,
56 jobject j_callback_obj,
57 jlong bookmark_id);
59 void DeletePages(JNIEnv* env,
60 jobject obj,
61 jobject j_callback_obj,
62 jlongArray bookmark_ids_array);
64 private:
65 void NotifyIfDoneLoading() const;
66 static base::FilePath GetDownloadsPath(
67 content::BrowserContext* browser_context);
69 JavaObjectWeakGlobalRef weak_java_ref_;
70 // Not owned.
71 OfflinePageModel* offline_page_model_;
72 // Not owned.
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_