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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 env, j_result_obj, | 60 env, j_result_obj, |
61 ConvertUTF8ToJavaString(env, offline_page.url.spec()).obj(), | 61 ConvertUTF8ToJavaString(env, offline_page.url.spec()).obj(), |
62 offline_page.bookmark_id, | 62 offline_page.bookmark_id, |
63 ConvertUTF8ToJavaString(env, offline_page.GetOfflineURL().spec()).obj(), | 63 ConvertUTF8ToJavaString(env, offline_page.GetOfflineURL().spec()).obj(), |
64 offline_page.file_size); | 64 offline_page.file_size); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 static jboolean IsOfflinePagesEnabled(JNIEnv* env, jclass clazz) { | 70 static jboolean IsOfflinePagesEnabled(JNIEnv* env, |
| 71 const JavaParamRef<jclass>& clazz) { |
71 return offline_pages::IsOfflinePagesEnabled(); | 72 return offline_pages::IsOfflinePagesEnabled(); |
72 } | 73 } |
73 | 74 |
74 OfflinePageBridge::OfflinePageBridge(JNIEnv* env, | 75 OfflinePageBridge::OfflinePageBridge(JNIEnv* env, |
75 jobject obj, | 76 jobject obj, |
76 content::BrowserContext* browser_context) | 77 content::BrowserContext* browser_context) |
77 : weak_java_ref_(env, obj), | 78 : weak_java_ref_(env, obj), |
78 offline_page_model_(OfflinePageModelFactory::GetForBrowserContext( | 79 offline_page_model_(OfflinePageModelFactory::GetForBrowserContext( |
79 browser_context)), | 80 browser_context)), |
80 browser_context_(browser_context) { | 81 browser_context_(browser_context) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 content::DownloadManager* manager = | 209 content::DownloadManager* manager = |
209 content::BrowserContext::GetDownloadManager(browser_context); | 210 content::BrowserContext::GetDownloadManager(browser_context); |
210 if (!manager) { | 211 if (!manager) { |
211 DVLOG(1) << "No download manager available in offline page bridge"; | 212 DVLOG(1) << "No download manager available in offline page bridge"; |
212 return base::FilePath(); | 213 return base::FilePath(); |
213 } | 214 } |
214 | 215 |
215 return DownloadPrefs::FromDownloadManager(manager)->DownloadPath(); | 216 return DownloadPrefs::FromDownloadManager(manager)->DownloadPath(); |
216 } | 217 } |
217 | 218 |
218 static jlong Init(JNIEnv* env, jobject obj, jobject j_profile) { | 219 static jlong Init(JNIEnv* env, |
| 220 const JavaParamRef<jobject>& obj, |
| 221 const JavaParamRef<jobject>& j_profile) { |
219 return reinterpret_cast<jlong>(new OfflinePageBridge( | 222 return reinterpret_cast<jlong>(new OfflinePageBridge( |
220 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); | 223 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); |
221 } | 224 } |
222 | 225 |
223 bool RegisterOfflinePageBridge(JNIEnv* env) { | 226 bool RegisterOfflinePageBridge(JNIEnv* env) { |
224 return RegisterNativesImpl(env); | 227 return RegisterNativesImpl(env); |
225 } | 228 } |
226 | 229 |
227 } // namespace android | 230 } // namespace android |
228 } // namespace offline_pages | 231 } // namespace offline_pages |
OLD | NEW |