| 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/strings/string_util.h" | |
| 11 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 10 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
| 12 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 11 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_android.h" | 13 #include "chrome/browser/profiles/profile_android.h" |
| 15 #include "components/offline_pages/offline_page_feature.h" | 14 #include "components/offline_pages/offline_page_feature.h" |
| 16 #include "components/offline_pages/offline_page_item.h" | 15 #include "components/offline_pages/offline_page_item.h" |
| 17 #include "components/offline_pages/offline_page_model.h" | 16 #include "components/offline_pages/offline_page_model.h" |
| 18 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 19 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 20 #include "jni/OfflinePageBridge_jni.h" | 19 #include "jni/OfflinePageBridge_jni.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 return Java_OfflinePageBridge_createOfflinePageItem( | 240 return Java_OfflinePageBridge_createOfflinePageItem( |
| 242 env, ConvertUTF8ToJavaString(env, offline_page.url.spec()).obj(), | 241 env, ConvertUTF8ToJavaString(env, offline_page.url.spec()).obj(), |
| 243 offline_page.bookmark_id, | 242 offline_page.bookmark_id, |
| 244 ConvertUTF8ToJavaString(env, offline_page.GetOfflineURL().spec()).obj(), | 243 ConvertUTF8ToJavaString(env, offline_page.GetOfflineURL().spec()).obj(), |
| 245 offline_page.file_size, | 244 offline_page.file_size, |
| 246 offline_page.creation_time.ToJavaTime(), | 245 offline_page.creation_time.ToJavaTime(), |
| 247 offline_page.access_count, | 246 offline_page.access_count, |
| 248 offline_page.last_access_time.ToJavaTime()); | 247 offline_page.last_access_time.ToJavaTime()); |
| 249 } | 248 } |
| 250 | 249 |
| 251 // static | |
| 252 bool OfflinePageBridge::MightBeOfflineURL(const GURL& url) { | |
| 253 // It has to be a file URL ending with .mhtml extension. | |
| 254 return url.is_valid() && | |
| 255 url.SchemeIsFile() && | |
| 256 base::EndsWith(url.spec(), | |
| 257 OfflinePageMHTMLArchiver::GetFileNameExtension(), | |
| 258 base::CompareCase::INSENSITIVE_ASCII); | |
| 259 } | |
| 260 | |
| 261 static jlong Init(JNIEnv* env, | 250 static jlong Init(JNIEnv* env, |
| 262 const JavaParamRef<jobject>& obj, | 251 const JavaParamRef<jobject>& obj, |
| 263 const JavaParamRef<jobject>& j_profile) { | 252 const JavaParamRef<jobject>& j_profile) { |
| 264 return reinterpret_cast<jlong>(new OfflinePageBridge( | 253 return reinterpret_cast<jlong>(new OfflinePageBridge( |
| 265 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); | 254 env, obj, ProfileAndroid::FromProfileAndroid(j_profile))); |
| 266 } | 255 } |
| 267 | 256 |
| 268 bool RegisterOfflinePageBridge(JNIEnv* env) { | 257 bool RegisterOfflinePageBridge(JNIEnv* env) { |
| 269 return RegisterNativesImpl(env); | 258 return RegisterNativesImpl(env); |
| 270 } | 259 } |
| 271 | 260 |
| 272 } // namespace android | 261 } // namespace android |
| 273 } // namespace offline_pages | 262 } // namespace offline_pages |
| OLD | NEW |