| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/history/browsing_history_bridge.h" | 5 #include "chrome/browser/android/history/browsing_history_bridge.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 void BrowsingHistoryBridge::QueryHistory( | 36 void BrowsingHistoryBridge::QueryHistory( |
| 37 JNIEnv* env, | 37 JNIEnv* env, |
| 38 const JavaParamRef<jobject>& obj, | 38 const JavaParamRef<jobject>& obj, |
| 39 const JavaParamRef<jobject>& j_result_obj, | 39 const JavaParamRef<jobject>& j_result_obj, |
| 40 jstring j_query, | 40 jstring j_query, |
| 41 int64_t j_query_end_time) { | 41 int64_t j_query_end_time) { |
| 42 j_query_result_obj_.Reset(env, j_result_obj); | 42 j_query_result_obj_.Reset(env, j_result_obj); |
| 43 | 43 |
| 44 history::QueryOptions options; | 44 history::QueryOptions options; |
| 45 options.max_count = kMaxQueryCount; | 45 options.max_count = kMaxQueryCount; |
| 46 options.end_time = base::Time::FromJavaTime(j_query_end_time); | 46 if (j_query_end_time == 0) { |
| 47 options.end_time = base::Time(); |
| 48 } else { |
| 49 options.end_time = base::Time::FromJavaTime(j_query_end_time); |
| 50 } |
| 47 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; | 51 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; |
| 48 | 52 |
| 49 browsing_history_service_->QueryHistory( | 53 browsing_history_service_->QueryHistory( |
| 50 base::android::ConvertJavaStringToUTF16(env, j_query), options); | 54 base::android::ConvertJavaStringToUTF16(env, j_query), options); |
| 51 } | 55 } |
| 52 | 56 |
| 53 // BrowsingHistoryServiceHandler implementation | 57 // BrowsingHistoryServiceHandler implementation |
| 54 void BrowsingHistoryBridge::OnQueryComplete( | 58 void BrowsingHistoryBridge::OnQueryComplete( |
| 55 std::vector<BrowsingHistoryService::HistoryEntry>* results, | 59 std::vector<BrowsingHistoryService::HistoryEntry>* results, |
| 56 BrowsingHistoryService::QueryResultsInfo* query_results_info) { | 60 BrowsingHistoryService::QueryResultsInfo* query_results_info) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 135 } |
| 132 | 136 |
| 133 void BrowsingHistoryBridge::HistoryDeleted() { | 137 void BrowsingHistoryBridge::HistoryDeleted() { |
| 134 JNIEnv* env = base::android::AttachCurrentThread(); | 138 JNIEnv* env = base::android::AttachCurrentThread(); |
| 135 Java_BrowsingHistoryBridge_onHistoryDeleted(env, | 139 Java_BrowsingHistoryBridge_onHistoryDeleted(env, |
| 136 j_history_service_obj_.obj()); | 140 j_history_service_obj_.obj()); |
| 137 } | 141 } |
| 138 | 142 |
| 139 void BrowsingHistoryBridge::HasOtherFormsOfBrowsingHistory( | 143 void BrowsingHistoryBridge::HasOtherFormsOfBrowsingHistory( |
| 140 bool has_other_forms, bool has_synced_results) { | 144 bool has_other_forms, bool has_synced_results) { |
| 141 // TODO(twellington): implement | 145 JNIEnv* env = base::android::AttachCurrentThread(); |
| 146 Java_BrowsingHistoryBridge_hasOtherFormsOfBrowsingData( |
| 147 env, j_history_service_obj_.obj(), has_other_forms, has_synced_results); |
| 142 } | 148 } |
| 143 | 149 |
| 144 bool RegisterBrowsingHistoryBridge(JNIEnv* env) { | 150 bool RegisterBrowsingHistoryBridge(JNIEnv* env) { |
| 145 return RegisterNativesImpl(env); | 151 return RegisterNativesImpl(env); |
| 146 } | 152 } |
| 147 | 153 |
| 148 static jlong Init(JNIEnv* env, | 154 static jlong Init(JNIEnv* env, |
| 149 const JavaParamRef<jobject>& obj, | 155 const JavaParamRef<jobject>& obj, |
| 150 const JavaParamRef<jobject>& j_profile) { | 156 const JavaParamRef<jobject>& j_profile) { |
| 151 BrowsingHistoryBridge* bridge = | 157 BrowsingHistoryBridge* bridge = |
| 152 new BrowsingHistoryBridge(env, obj, j_profile); | 158 new BrowsingHistoryBridge(env, obj, j_profile); |
| 153 return reinterpret_cast<intptr_t>(bridge); | 159 return reinterpret_cast<intptr_t>(bridge); |
| 154 } | 160 } |
| OLD | NEW |