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 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_bridge.h" |
6 | 6 |
7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void OfflinePageBridge::Destroy(JNIEnv*, jobject) { | 87 void OfflinePageBridge::Destroy(JNIEnv*, jobject) { |
88 offline_page_model_->RemoveObserver(this); | 88 offline_page_model_->RemoveObserver(this); |
89 delete this; | 89 delete this; |
90 } | 90 } |
91 | 91 |
92 void OfflinePageBridge::OfflinePageModelLoaded(OfflinePageModel* model) { | 92 void OfflinePageBridge::OfflinePageModelLoaded(OfflinePageModel* model) { |
93 DCHECK_EQ(offline_page_model_, model); | 93 DCHECK_EQ(offline_page_model_, model); |
94 NotifyIfDoneLoading(); | 94 NotifyIfDoneLoading(); |
95 } | 95 } |
96 | 96 |
| 97 void OfflinePageBridge::OfflinePageModelChanged(OfflinePageModel* model) { |
| 98 DCHECK_EQ(offline_page_model_, model); |
| 99 JNIEnv* env = base::android::AttachCurrentThread(); |
| 100 ScopedJavaLocalRef<jobject> obj = weak_java_ref_.get(env); |
| 101 if (obj.is_null()) |
| 102 return; |
| 103 Java_OfflinePageBridge_offlinePageModelChanged(env, obj.obj()); |
| 104 } |
| 105 |
97 void OfflinePageBridge::GetAllPages(JNIEnv* env, | 106 void OfflinePageBridge::GetAllPages(JNIEnv* env, |
98 jobject obj, | 107 jobject obj, |
99 jobject j_result_obj) { | 108 jobject j_result_obj) { |
100 DCHECK(offline_page_model_->is_loaded()); | 109 DCHECK(offline_page_model_->is_loaded()); |
101 DCHECK(j_result_obj); | 110 DCHECK(j_result_obj); |
102 const std::vector<OfflinePageItem>& offline_pages = | 111 const std::vector<OfflinePageItem>& offline_pages = |
103 offline_page_model_->GetAllPages(); | 112 offline_page_model_->GetAllPages(); |
104 ToJavaOfflinePageList(env, j_result_obj, offline_pages); | 113 ToJavaOfflinePageList(env, j_result_obj, offline_pages); |
105 } | 114 } |
106 | 115 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return reinterpret_cast<jlong>(new OfflinePageBridge( | 240 return reinterpret_cast<jlong>(new OfflinePageBridge( |
232 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); | 241 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); |
233 } | 242 } |
234 | 243 |
235 bool RegisterOfflinePageBridge(JNIEnv* env) { | 244 bool RegisterOfflinePageBridge(JNIEnv* env) { |
236 return RegisterNativesImpl(env); | 245 return RegisterNativesImpl(env); |
237 } | 246 } |
238 | 247 |
239 } // namespace android | 248 } // namespace android |
240 } // namespace offline_pages | 249 } // namespace offline_pages |
OLD | NEW |