Commit 0f4f8ddc authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Commit Bot

[Autofill Assistant] Fix details date.

Before this patch, we unsuccessfully converted the date as a timestamp
in native before transfering it to Java side.

This patch directly pass the different values of the date instead.

Bug: 806868
Change-Id: I99b4aa6903bc36168a68a41d641ed0d0000f4ff2
Reviewed-on: https://chromium-review.googlesource.com/c/1277655
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599221}
parent 1f44cfc2
......@@ -224,10 +224,12 @@ public class AutofillAssistantUiController implements AutofillAssistantUiDelegat
}
@CalledByNative
private void onShowDetails(String title, String url, long msSinceEpoch, String description) {
private void onShowDetails(String title, String url, String description, int year, int month,
int day, int hour, int minute, int second) {
Date date = null;
if (msSinceEpoch > 0) {
date = new Date(msSinceEpoch);
if (year > 0 && month > 0 && day > 0 && hour >= 0 && minute >= 0 && second >= 0) {
// Month in Java Date is 0-based, but the one we receive from the server is 1-based.
date = new Date(year, month - 1, day, hour, minute, second);
}
mUiDelegate.showDetails(
......
......@@ -12,7 +12,6 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/command_line.h"
#include "base/time/time.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -215,26 +214,20 @@ void UiControllerAndroid::HideDetails() {
}
void UiControllerAndroid::ShowDetails(const DetailsProto& details) {
base::Time time;
base::Time::Exploded exploded;
exploded.year = details.datetime().date().year();
exploded.month = details.datetime().date().month();
exploded.day_of_month = details.datetime().date().day();
exploded.hour = details.datetime().time().hour();
exploded.minute = details.datetime().time().minute();
exploded.second = details.datetime().time().second();
long java_time = 0;
if (base::Time::FromUTCExploded(exploded, &time)) {
java_time = time.ToJavaTime();
}
int year = details.datetime().date().year();
int month = details.datetime().date().month();
int day = details.datetime().date().day();
int hour = details.datetime().time().hour();
int minute = details.datetime().time().minute();
int second = details.datetime().time().second();
JNIEnv* env = AttachCurrentThread();
Java_AutofillAssistantUiController_onShowDetails(
env, java_autofill_assistant_ui_controller_,
base::android::ConvertUTF8ToJavaString(env, details.title()),
base::android::ConvertUTF8ToJavaString(env, details.url()), java_time,
base::android::ConvertUTF8ToJavaString(env, details.description()));
base::android::ConvertUTF8ToJavaString(env, details.url()),
base::android::ConvertUTF8ToJavaString(env, details.description()), year,
month, day, hour, minute, second);
}
std::string UiControllerAndroid::GetApiKey() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment