Chromium Code Reviews| 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/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 13 #include "jni/DateTimeChooserAndroid_jni.h" | 13 #include "jni/DateTimeChooserAndroid_jni.h" |
| 14 #include "third_party/icu/source/common/unicode/uchar.h" | 14 #include "third_party/icu/source/common/unicode/uchar.h" |
| 15 #include "third_party/icu/source/common/unicode/unistr.h" | 15 #include "third_party/icu/source/common/unicode/unistr.h" |
| 16 #include "ui/android/window_android.h" | 16 #include "ui/android/window_android.h" |
| 17 | 17 |
| 18 using base::android::AttachCurrentThread; | 18 using base::android::AttachCurrentThread; |
| 19 using base::android::ConvertJavaStringToUTF16; | 19 using base::android::ConvertJavaStringToUTF16; |
| 20 using base::android::ConvertUTF8ToJavaString; | 20 using base::android::ConvertUTF8ToJavaString; |
| 21 using base::android::ConvertUTF16ToJavaString; | 21 using base::android::ConvertUTF16ToJavaString; |
| 22 using base::android::JavaRef; | |
| 22 | 23 |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 base::string16 SanitizeSuggestionString(const base::string16& string) { | 27 base::string16 SanitizeSuggestionString(const base::string16& string) { |
| 27 base::string16 trimmed = string.substr(0, 255); | 28 base::string16 trimmed = string.substr(0, 255); |
| 28 icu::UnicodeString sanitized; | 29 icu::UnicodeString sanitized; |
| 29 base::i18n::UTF16CharIterator sanitized_iterator(&trimmed); | 30 base::i18n::UTF16CharIterator sanitized_iterator(&trimmed); |
| 30 while (!sanitized_iterator.end()) { | 31 while (!sanitized_iterator.end()) { |
| 31 UChar c = sanitized_iterator.get(); | 32 UChar c = sanitized_iterator.get(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 43 | 44 |
| 44 // DateTimeChooserAndroid implementation | 45 // DateTimeChooserAndroid implementation |
| 45 DateTimeChooserAndroid::DateTimeChooserAndroid() | 46 DateTimeChooserAndroid::DateTimeChooserAndroid() |
| 46 : host_(NULL) { | 47 : host_(NULL) { |
| 47 } | 48 } |
| 48 | 49 |
| 49 DateTimeChooserAndroid::~DateTimeChooserAndroid() { | 50 DateTimeChooserAndroid::~DateTimeChooserAndroid() { |
| 50 } | 51 } |
| 51 | 52 |
| 52 void DateTimeChooserAndroid::ReplaceDateTime(JNIEnv* env, | 53 void DateTimeChooserAndroid::ReplaceDateTime(JNIEnv* env, |
| 53 jobject, | 54 const JavaRef<jobject>&, |
|
Torne
2015/11/30 11:47:06
I'm using JavaRef instead of JavaParamRef in this
| |
| 54 jdouble value) { | 55 jdouble value) { |
| 55 host_->Send(new ViewMsg_ReplaceDateTime(host_->GetRoutingID(), value)); | 56 host_->Send(new ViewMsg_ReplaceDateTime(host_->GetRoutingID(), value)); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void DateTimeChooserAndroid::CancelDialog(JNIEnv* env, jobject) { | 59 void DateTimeChooserAndroid::CancelDialog(JNIEnv* env, |
| 60 const JavaRef<jobject>&) { | |
| 59 host_->Send(new ViewMsg_CancelDateTimeDialog(host_->GetRoutingID())); | 61 host_->Send(new ViewMsg_CancelDateTimeDialog(host_->GetRoutingID())); |
| 60 } | 62 } |
| 61 | 63 |
| 62 void DateTimeChooserAndroid::ShowDialog( | 64 void DateTimeChooserAndroid::ShowDialog( |
| 63 gfx::NativeWindow native_window, | 65 gfx::NativeWindow native_window, |
| 64 RenderViewHost* host, | 66 RenderViewHost* host, |
| 65 ui::TextInputType dialog_type, | 67 ui::TextInputType dialog_type, |
| 66 double dialog_value, | 68 double dialog_value, |
| 67 double min, | 69 double min, |
| 68 double max, | 70 double max, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 93 env, | 95 env, |
| 94 native_window->GetJavaObject().obj(), | 96 native_window->GetJavaObject().obj(), |
| 95 reinterpret_cast<intptr_t>(this), | 97 reinterpret_cast<intptr_t>(this), |
| 96 dialog_type, | 98 dialog_type, |
| 97 dialog_value, | 99 dialog_value, |
| 98 min, | 100 min, |
| 99 max, | 101 max, |
| 100 step, | 102 step, |
| 101 suggestions_array.obj())); | 103 suggestions_array.obj())); |
| 102 if (j_date_time_chooser_.is_null()) | 104 if (j_date_time_chooser_.is_null()) |
| 103 ReplaceDateTime(env, j_date_time_chooser_.obj(), dialog_value); | 105 ReplaceDateTime(env, j_date_time_chooser_, dialog_value); |
| 104 } | 106 } |
| 105 | 107 |
| 106 // ---------------------------------------------------------------------------- | 108 // ---------------------------------------------------------------------------- |
| 107 // Native JNI methods | 109 // Native JNI methods |
| 108 // ---------------------------------------------------------------------------- | 110 // ---------------------------------------------------------------------------- |
| 109 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { | 111 bool RegisterDateTimeChooserAndroid(JNIEnv* env) { |
| 110 return RegisterNativesImpl(env); | 112 return RegisterNativesImpl(env); |
| 111 } | 113 } |
| 112 | 114 |
| 113 } // namespace content | 115 } // namespace content |
| OLD | NEW |