| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/android/date_time_chooser_android.h" | 5 #include "content/browser/android/date_time_chooser_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
| 9 #include "content/public/browser/android/content_view_core.h" | 9 #include "content/public/browser/android/content_view_core.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 JNIEnv* env = AttachCurrentThread(); | 33 JNIEnv* env = AttachCurrentThread(); |
| 34 Java_DateTimeChooserAndroid_initializeDateInputTypes( | 34 Java_DateTimeChooserAndroid_initializeDateInputTypes( |
| 35 env, | 35 env, |
| 36 text_input_type_date, text_input_type_date_time, | 36 text_input_type_date, text_input_type_date_time, |
| 37 text_input_type_date_time_local, text_input_type_month, | 37 text_input_type_date_time_local, text_input_type_month, |
| 38 text_input_type_time, text_input_type_week); | 38 text_input_type_time, text_input_type_week); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void DateTimeChooserAndroid::ReplaceDateTime(JNIEnv* env, | 41 void DateTimeChooserAndroid::ReplaceDateTime(JNIEnv* env, |
| 42 jobject, | 42 jobject, |
| 43 int dialog_type, | 43 jdouble value) { |
| 44 int year, | |
| 45 int month, | |
| 46 int day, | |
| 47 int hour, | |
| 48 int minute, | |
| 49 int second, | |
| 50 int milli, | |
| 51 int week) { | |
| 52 ViewHostMsg_DateTimeDialogValue_Params value; | |
| 53 value.year = year; | |
| 54 value.month = month; | |
| 55 value.day = day; | |
| 56 value.hour = hour; | |
| 57 value.minute = minute; | |
| 58 value.second = second; | |
| 59 value.milli = milli; | |
| 60 value.week = week; | |
| 61 value.dialog_type = dialog_type; | |
| 62 host_->Send(new ViewMsg_ReplaceDateTime(host_->GetRoutingID(), value)); | 44 host_->Send(new ViewMsg_ReplaceDateTime(host_->GetRoutingID(), value)); |
| 63 } | 45 } |
| 64 | 46 |
| 65 void DateTimeChooserAndroid::CancelDialog(JNIEnv* env, jobject) { | 47 void DateTimeChooserAndroid::CancelDialog(JNIEnv* env, jobject) { |
| 66 host_->Send(new ViewMsg_CancelDateTimeDialog(host_->GetRoutingID())); | 48 host_->Send(new ViewMsg_CancelDateTimeDialog(host_->GetRoutingID())); |
| 67 } | 49 } |
| 68 | 50 |
| 69 void DateTimeChooserAndroid::ShowDialog(ContentViewCore* content, | 51 void DateTimeChooserAndroid::ShowDialog(ContentViewCore* content, |
| 70 RenderViewHost* host, | 52 RenderViewHost* host, |
| 71 int type, | 53 int dialog_type, |
| 72 int year, | 54 double dialog_value, |
| 73 int month, | |
| 74 int day, | |
| 75 int hour, | |
| 76 int minute, | |
| 77 int second, | |
| 78 int milli, | |
| 79 int week, | |
| 80 double min, | 55 double min, |
| 81 double max, | 56 double max, |
| 82 double step) { | 57 double step) { |
| 83 host_ = host; | 58 host_ = host; |
| 84 | 59 |
| 85 JNIEnv* env = AttachCurrentThread(); | 60 JNIEnv* env = AttachCurrentThread(); |
| 86 j_date_time_chooser_.Reset(Java_DateTimeChooserAndroid_createDateTimeChooser( | 61 j_date_time_chooser_.Reset(Java_DateTimeChooserAndroid_createDateTimeChooser( |
| 87 env, | 62 env, |
| 88 content->GetJavaObject().obj(), | 63 content->GetJavaObject().obj(), |
| 89 reinterpret_cast<intptr_t>(this), | 64 reinterpret_cast<intptr_t>(this), |
| 90 type, | 65 dialog_type, |
| 91 year, | 66 dialog_value, |
| 92 month, | |
| 93 day, | |
| 94 hour, | |
| 95 minute, | |
| 96 second, | |
| 97 milli, | |
| 98 week, | |
| 99 min, | 67 min, |
| 100 max, | 68 max, |
| 101 step)); | 69 step)); |
| 102 } | 70 } |
| 103 | 71 |
| 104 // ---------------------------------------------------------------------------- | 72 // ---------------------------------------------------------------------------- |
| 105 // Native JNI methods | 73 // Native JNI methods |
| 106 // ---------------------------------------------------------------------------- | 74 // ---------------------------------------------------------------------------- |
| 107 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { | 75 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { |
| 108 bool registered = RegisterNativesImpl(env); | 76 bool registered = RegisterNativesImpl(env); |
| 109 if (registered) | 77 if (registered) |
| 110 DateTimeChooserAndroid::InitializeDateInputTypes( | 78 DateTimeChooserAndroid::InitializeDateInputTypes( |
| 111 ui::TEXT_INPUT_TYPE_DATE, | 79 ui::TEXT_INPUT_TYPE_DATE, |
| 112 ui::TEXT_INPUT_TYPE_DATE_TIME, | 80 ui::TEXT_INPUT_TYPE_DATE_TIME, |
| 113 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL, | 81 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL, |
| 114 ui::TEXT_INPUT_TYPE_MONTH, | 82 ui::TEXT_INPUT_TYPE_MONTH, |
| 115 ui::TEXT_INPUT_TYPE_TIME, | 83 ui::TEXT_INPUT_TYPE_TIME, |
| 116 ui::TEXT_INPUT_TYPE_WEEK); | 84 ui::TEXT_INPUT_TYPE_WEEK); |
| 117 return registered; | 85 return registered; |
| 118 } | 86 } |
| 119 | 87 |
| 120 } // namespace content | 88 } // namespace content |
| OLD | NEW |