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