| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_
BRIDGE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATION_
BRIDGE_H_ |
| 7 |
| 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_weak_ref.h" |
| 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/macros.h" |
| 12 #include "components/offline_pages/background/request_coordinator.h" |
| 13 #include "components/offline_pages/background/request_notifier.h" |
| 14 #include "components/offline_pages/offline_page_model.h" |
| 15 |
| 16 namespace content { |
| 17 class BrowserContext; |
| 18 } |
| 19 |
| 20 namespace offline_pages { |
| 21 |
| 22 struct OfflinePageItem; |
| 23 |
| 24 namespace android { |
| 25 |
| 26 /** |
| 27 * Bridge for exposing native implementation which are used by evaluation. |
| 28 */ |
| 29 class OfflinePageEvaluationBridge : public OfflinePageModel::Observer, |
| 30 public RequestCoordinator::Observer { |
| 31 public: |
| 32 static bool Register(JNIEnv* env); |
| 33 |
| 34 OfflinePageEvaluationBridge(JNIEnv* env, |
| 35 content::BrowserContext* browser_context, |
| 36 OfflinePageModel* offline_page_model, |
| 37 RequestCoordinator* request_coordinator); |
| 38 |
| 39 ~OfflinePageEvaluationBridge() override; |
| 40 |
| 41 // OfflinePageModel::Observer implementation. |
| 42 void OfflinePageModelLoaded(OfflinePageModel* model) override; |
| 43 void OfflinePageModelChanged(OfflinePageModel* model) override; |
| 44 void OfflinePageDeleted(int64_t offline_id, |
| 45 const ClientId& client_id) override; |
| 46 |
| 47 // RequestCoordinator::Observer implementation. |
| 48 void OnAdded(const SavePageRequest& request) override; |
| 49 void OnCompleted(const SavePageRequest& request, |
| 50 RequestNotifier::BackgroundSavePageResult status) override; |
| 51 void OnChanged(const SavePageRequest& request) override; |
| 52 |
| 53 void GetAllPages(JNIEnv* env, |
| 54 const base::android::JavaParamRef<jobject>& obj, |
| 55 const base::android::JavaParamRef<jobject>& j_result_obj, |
| 56 const base::android::JavaParamRef<jobject>& j_callback_obj); |
| 57 |
| 58 void PushRequestProcessing( |
| 59 JNIEnv* env, |
| 60 const base::android::JavaParamRef<jobject>& obj, |
| 61 const base::android::JavaParamRef<jobject>& j_callback_obj); |
| 62 |
| 63 void SavePageLater(JNIEnv* env, |
| 64 const base::android::JavaParamRef<jobject>& obj, |
| 65 const base::android::JavaParamRef<jstring>& url, |
| 66 const base::android::JavaParamRef<jstring>& j_namespace, |
| 67 const base::android::JavaParamRef<jstring>& j_client_id, |
| 68 jboolean user_requested); |
| 69 |
| 70 base::android::ScopedJavaGlobalRef<jobject> java_ref() { return java_ref_; } |
| 71 |
| 72 private: |
| 73 void NotifyIfDoneLoading() const; |
| 74 |
| 75 base::android::ScopedJavaLocalRef<jobject> CreateClientId( |
| 76 JNIEnv* env, |
| 77 const ClientId& clientId) const; |
| 78 |
| 79 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 80 // Not owned. |
| 81 content::BrowserContext* browser_context_; |
| 82 // Not owned. |
| 83 OfflinePageModel* offline_page_model_; |
| 84 // Not owned. |
| 85 RequestCoordinator* request_coordinator_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(OfflinePageEvaluationBridge); |
| 88 }; |
| 89 |
| 90 } // namespace android |
| 91 } // namespace offline_pages |
| 92 |
| 93 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_EVALUATION_OFFLINE_PAGE_EVALUATI
ON_BRIDGE_H_ |
| OLD | NEW |