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_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/i18n/char_iterator.h" | 9 #include "base/i18n/char_iterator.h" |
10 #include "content/common/date_time_suggestion.h" | 10 #include "content/common/date_time_suggestion.h" |
11 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
12 #include "content/public/browser/android/content_view_core.h" | |
13 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
14 #include "jni/DateTimeChooserAndroid_jni.h" | 13 #include "jni/DateTimeChooserAndroid_jni.h" |
15 #include "third_party/icu/source/common/unicode/uchar.h" | 14 #include "third_party/icu/source/common/unicode/uchar.h" |
16 #include "third_party/icu/source/common/unicode/unistr.h" | 15 #include "third_party/icu/source/common/unicode/unistr.h" |
17 | 16 |
18 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
19 using base::android::ConvertJavaStringToUTF16; | 18 using base::android::ConvertJavaStringToUTF16; |
20 using base::android::ConvertUTF8ToJavaString; | 19 using base::android::ConvertUTF8ToJavaString; |
21 using base::android::ConvertUTF16ToJavaString; | 20 using base::android::ConvertUTF16ToJavaString; |
22 | 21 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 jobject, | 65 jobject, |
67 jdouble value) { | 66 jdouble value) { |
68 host_->Send(new ViewMsg_ReplaceDateTime(host_->GetRoutingID(), value)); | 67 host_->Send(new ViewMsg_ReplaceDateTime(host_->GetRoutingID(), value)); |
69 } | 68 } |
70 | 69 |
71 void DateTimeChooserAndroid::CancelDialog(JNIEnv* env, jobject) { | 70 void DateTimeChooserAndroid::CancelDialog(JNIEnv* env, jobject) { |
72 host_->Send(new ViewMsg_CancelDateTimeDialog(host_->GetRoutingID())); | 71 host_->Send(new ViewMsg_CancelDateTimeDialog(host_->GetRoutingID())); |
73 } | 72 } |
74 | 73 |
75 void DateTimeChooserAndroid::ShowDialog( | 74 void DateTimeChooserAndroid::ShowDialog( |
76 ContentViewCore* content, | 75 WebContents* webcontents, |
77 RenderViewHost* host, | 76 RenderViewHost* host, |
78 ui::TextInputType dialog_type, | 77 ui::TextInputType dialog_type, |
79 double dialog_value, | 78 double dialog_value, |
80 double min, | 79 double min, |
81 double max, | 80 double max, |
82 double step, | 81 double step, |
83 const std::vector<DateTimeSuggestion>& suggestions) { | 82 const std::vector<DateTimeSuggestion>& suggestions) { |
84 host_ = host; | 83 host_ = host; |
85 | 84 |
86 JNIEnv* env = AttachCurrentThread(); | 85 JNIEnv* env = AttachCurrentThread(); |
(...skipping 10 matching lines...) Expand all Loading... | |
97 ScopedJavaLocalRef<jstring> label = ConvertUTF16ToJavaString( | 96 ScopedJavaLocalRef<jstring> label = ConvertUTF16ToJavaString( |
98 env, SanitizeSuggestionString(suggestion.label)); | 97 env, SanitizeSuggestionString(suggestion.label)); |
99 Java_DateTimeChooserAndroid_setDateTimeSuggestionAt(env, | 98 Java_DateTimeChooserAndroid_setDateTimeSuggestionAt(env, |
100 suggestions_array.obj(), i, | 99 suggestions_array.obj(), i, |
101 suggestion.value, localized_value.obj(), label.obj()); | 100 suggestion.value, localized_value.obj(), label.obj()); |
102 } | 101 } |
103 } | 102 } |
104 | 103 |
105 j_date_time_chooser_.Reset(Java_DateTimeChooserAndroid_createDateTimeChooser( | 104 j_date_time_chooser_.Reset(Java_DateTimeChooserAndroid_createDateTimeChooser( |
106 env, | 105 env, |
107 content->GetJavaObject().obj(), | 106 webcontents->GetJavaWebContents().obj(), |
Ted C
2014/10/15 21:32:42
I want to agree with Yaron that context definitely
AKVT
2014/10/29 18:13:28
Done. Thank you
| |
108 reinterpret_cast<intptr_t>(this), | 107 reinterpret_cast<intptr_t>(this), |
109 dialog_type, | 108 dialog_type, |
110 dialog_value, | 109 dialog_value, |
111 min, | 110 min, |
112 max, | 111 max, |
113 step, | 112 step, |
114 suggestions_array.obj())); | 113 suggestions_array.obj())); |
115 } | 114 } |
116 | 115 |
117 // ---------------------------------------------------------------------------- | 116 // ---------------------------------------------------------------------------- |
118 // Native JNI methods | 117 // Native JNI methods |
119 // ---------------------------------------------------------------------------- | 118 // ---------------------------------------------------------------------------- |
120 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { | 119 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { |
121 bool registered = RegisterNativesImpl(env); | 120 bool registered = RegisterNativesImpl(env); |
122 if (registered) | 121 if (registered) |
123 DateTimeChooserAndroid::InitializeDateInputTypes( | 122 DateTimeChooserAndroid::InitializeDateInputTypes( |
124 ui::TEXT_INPUT_TYPE_DATE, | 123 ui::TEXT_INPUT_TYPE_DATE, |
125 ui::TEXT_INPUT_TYPE_DATE_TIME, | 124 ui::TEXT_INPUT_TYPE_DATE_TIME, |
126 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL, | 125 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL, |
127 ui::TEXT_INPUT_TYPE_MONTH, | 126 ui::TEXT_INPUT_TYPE_MONTH, |
128 ui::TEXT_INPUT_TYPE_TIME, | 127 ui::TEXT_INPUT_TYPE_TIME, |
129 ui::TEXT_INPUT_TYPE_WEEK); | 128 ui::TEXT_INPUT_TYPE_WEEK); |
130 return registered; | 129 return registered; |
131 } | 130 } |
132 | 131 |
133 } // namespace content | 132 } // namespace content |
OLD | NEW |