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( |
70 RenderViewHost* host, | 52 ContentViewCore* content, |
71 int type, | 53 RenderViewHost* host, |
72 int year, | 54 ui::TextInputType dialog_type, |
73 int month, | 55 double dialog_value, |
74 int day, | 56 double min, |
75 int hour, | 57 double max, |
76 int minute, | 58 double step) { |
77 int second, | |
78 int milli, | |
79 int week, | |
80 double min, | |
81 double max, | |
82 double step) { | |
83 host_ = host; | 59 host_ = host; |
84 | 60 |
85 JNIEnv* env = AttachCurrentThread(); | 61 JNIEnv* env = AttachCurrentThread(); |
86 j_date_time_chooser_.Reset(Java_DateTimeChooserAndroid_createDateTimeChooser( | 62 j_date_time_chooser_.Reset(Java_DateTimeChooserAndroid_createDateTimeChooser( |
87 env, | 63 env, |
88 content->GetJavaObject().obj(), | 64 content->GetJavaObject().obj(), |
89 reinterpret_cast<intptr_t>(this), | 65 reinterpret_cast<intptr_t>(this), |
90 type, | 66 dialog_type, |
91 year, | 67 dialog_value, |
92 month, | |
93 day, | |
94 hour, | |
95 minute, | |
96 second, | |
97 milli, | |
98 week, | |
99 min, | 68 min, |
100 max, | 69 max, |
101 step)); | 70 step)); |
102 } | 71 } |
103 | 72 |
104 // ---------------------------------------------------------------------------- | 73 // ---------------------------------------------------------------------------- |
105 // Native JNI methods | 74 // Native JNI methods |
106 // ---------------------------------------------------------------------------- | 75 // ---------------------------------------------------------------------------- |
107 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { | 76 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { |
108 bool registered = RegisterNativesImpl(env); | 77 bool registered = RegisterNativesImpl(env); |
109 if (registered) | 78 if (registered) |
110 DateTimeChooserAndroid::InitializeDateInputTypes( | 79 DateTimeChooserAndroid::InitializeDateInputTypes( |
111 ui::TEXT_INPUT_TYPE_DATE, | 80 ui::TEXT_INPUT_TYPE_DATE, |
112 ui::TEXT_INPUT_TYPE_DATE_TIME, | 81 ui::TEXT_INPUT_TYPE_DATE_TIME, |
113 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL, | 82 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL, |
114 ui::TEXT_INPUT_TYPE_MONTH, | 83 ui::TEXT_INPUT_TYPE_MONTH, |
115 ui::TEXT_INPUT_TYPE_TIME, | 84 ui::TEXT_INPUT_TYPE_TIME, |
116 ui::TEXT_INPUT_TYPE_WEEK); | 85 ui::TEXT_INPUT_TYPE_WEEK); |
117 return registered; | 86 return registered; |
118 } | 87 } |
119 | 88 |
120 } // namespace content | 89 } // namespace content |
OLD | NEW |