| Index: content/browser/android/date_time_chooser_android.cc
|
| diff --git a/content/browser/android/date_time_chooser_android.cc b/content/browser/android/date_time_chooser_android.cc
|
| index 7c91ff0977da8114969a2e3efc98bed3126e15f4..a2463dcceb3279bd29f9c0ff7f085aa1c144a229 100644
|
| --- a/content/browser/android/date_time_chooser_android.cc
|
| +++ b/content/browser/android/date_time_chooser_android.cc
|
| @@ -8,11 +8,13 @@
|
| #include "content/common/view_messages.h"
|
| #include "content/public/browser/android/content_view_core.h"
|
| #include "content/public/browser/render_view_host_observer.h"
|
| +#include "content/public/common/date_time_suggestion.h"
|
| #include "jni/DateTimeChooserAndroid_jni.h"
|
|
|
| using base::android::AttachCurrentThread;
|
| using base::android::ConvertJavaStringToUTF16;
|
| using base::android::ConvertUTF8ToJavaString;
|
| +using base::android::ConvertUTF16ToJavaString;
|
|
|
|
|
| namespace content {
|
| @@ -33,6 +35,7 @@ class DateTimeChooserAndroid::DateTimeIPCSender :
|
| int milli,
|
| int week);
|
| void CancelDialog();
|
| + void AcceptDataListSuggestion(const string16& value);
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(DateTimeIPCSender);
|
| @@ -69,6 +72,11 @@ void DateTimeChooserAndroid::DateTimeIPCSender::CancelDialog() {
|
| Send(new ViewMsg_CancelDateTimeDialog(routing_id()));
|
| }
|
|
|
| +void DateTimeChooserAndroid::DateTimeIPCSender::AcceptDataListSuggestion(
|
| + const string16& value) {
|
| + Send(new ViewMsg_AcceptDataListSuggestion(routing_id(), value));
|
| +}
|
| +
|
| // DateTimeChooserAndroid implementation
|
| DateTimeChooserAndroid::DateTimeChooserAndroid()
|
| : sender_(NULL) {
|
| @@ -109,25 +117,59 @@ void DateTimeChooserAndroid::CancelDialog(JNIEnv* env, jobject) {
|
| sender_->CancelDialog();
|
| }
|
|
|
| -void DateTimeChooserAndroid::ShowDialog(ContentViewCore* content,
|
| - RenderViewHost* sender,
|
| - int type,
|
| - int year,
|
| - int month,
|
| - int day,
|
| - int hour,
|
| - int minute,
|
| - int second,
|
| - int milli,
|
| - int week,
|
| - double min,
|
| - double max,
|
| - double step) {
|
| +void DateTimeChooserAndroid::AcceptDataListSuggestion(JNIEnv* env,
|
| + jobject,
|
| + jstring value) {
|
| + sender_->AcceptDataListSuggestion(ConvertJavaStringToUTF16(env, value));
|
| +}
|
| +
|
| +void DateTimeChooserAndroid::ShowDialog(
|
| + ContentViewCore* content,
|
| + RenderViewHost* sender,
|
| + int type,
|
| + int year,
|
| + int month,
|
| + int day,
|
| + int hour,
|
| + int minute,
|
| + int second,
|
| + int milli,
|
| + int week,
|
| + double min,
|
| + double max,
|
| + double step,
|
| + std::vector<DateTimeSuggestion> suggestions) {
|
| if (sender_)
|
| delete sender_;
|
| sender_ = new DateTimeIPCSender(sender);
|
|
|
| JNIEnv* env = AttachCurrentThread();
|
| + ScopedJavaLocalRef<jobjectArray> suggestions_array;
|
| +
|
| + if (suggestions.size() > 0) {
|
| + suggestions_array =
|
| + Java_DateTimeChooserAndroid_createDateTimeSuggestionArray(
|
| + env,
|
| + suggestions.size());
|
| +
|
| + for (size_t i = 0; i < suggestions.size(); ++i) {
|
| + const content::DateTimeSuggestion& suggestion = suggestions[i];
|
| + ScopedJavaLocalRef<jstring> value = ConvertUTF16ToJavaString(
|
| + env, suggestion.value);
|
| + ScopedJavaLocalRef<jstring> localizedValue = ConvertUTF16ToJavaString(
|
| + env, suggestion.localizedValue);
|
| + ScopedJavaLocalRef<jstring> label = ConvertUTF16ToJavaString(
|
| + env, suggestion.label);
|
| + Java_DateTimeChooserAndroid_addToDateTimeSuggestionArray(
|
| + env,
|
| + suggestions_array.obj(),
|
| + i,
|
| + value.obj(),
|
| + localizedValue.obj(),
|
| + label.obj());
|
| + }
|
| + }
|
| +
|
| j_date_time_chooser_.Reset(Java_DateTimeChooserAndroid_createDateTimeChooser(
|
| env,
|
| content->GetJavaObject().obj(),
|
| @@ -143,7 +185,8 @@ void DateTimeChooserAndroid::ShowDialog(ContentViewCore* content,
|
| week,
|
| min,
|
| max,
|
| - step));
|
| + step,
|
| + suggestions_array.obj()));
|
| }
|
|
|
| // ----------------------------------------------------------------------------
|
|
|