Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: components/web_contents_delegate_android/color_chooser_android.cc

Issue 23026006: Add support for color input datalist on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/web_contents_delegate_android/color_chooser_android.h" 5 #include "components/web_contents_delegate_android/color_chooser_android.h"
6 6
7 #include "base/android/jni_array.h"
7 #include "content/public/browser/android/content_view_core.h" 8 #include "content/public/browser/android/content_view_core.h"
8 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_view.h" 10 #include "content/public/browser/web_contents_view.h"
10 #include "jni/ColorChooserAndroid_jni.h" 11 #include "jni/ColorChooserAndroid_jni.h"
11 12
12 namespace web_contents_delegate_android { 13 namespace web_contents_delegate_android {
13 14
14 ColorChooserAndroid::ColorChooserAndroid(content::WebContents* web_contents, 15 ColorChooserAndroid::ColorChooserAndroid(
15 SkColor initial_color) 16 content::WebContents* web_contents,
17 SkColor initial_color,
18 const std::vector<SkColor>& suggestions,
Miguel Garcia 2013/08/19 14:43:27 Can you rename "suggestions" to "suggested_colors"
keishi 2013/08/26 05:28:54 I changed it to a vector of ColorSugestion struct
19 const std::vector<string16>& suggestion_labels)
16 : web_contents_(web_contents) { 20 : web_contents_(web_contents) {
17 JNIEnv* env = AttachCurrentThread(); 21 JNIEnv* env = AttachCurrentThread();
18 content::ContentViewCore* content_view_core = 22 content::ContentViewCore* content_view_core =
19 content::ContentViewCore::FromWebContents(web_contents); 23 content::ContentViewCore::FromWebContents(web_contents);
20 DCHECK(content_view_core); 24 DCHECK(content_view_core);
21 25
26 ScopedJavaLocalRef<jintArray> suggestions_array(
27 env, env->NewIntArray(suggestions.size()));
28 jint* suggestions_array_elements =
29 env->GetIntArrayElements(suggestions_array.obj(), NULL);
30 for (size_t i = 0; i < suggestions.size(); ++i) {
31 suggestions_array_elements[i] = suggestions[i];
32 }
33 env->ReleaseIntArrayElements(suggestions_array.obj(),
Miguel Garcia 2013/08/19 14:43:27 Could you upgrade jni_array.cc/h with a ToJavaArra
keishi 2013/08/26 05:28:54 I changed it to an array of ColorSuggestion object
34 suggestions_array_elements,
35 0);
36
22 j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid( 37 j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid(
23 env, 38 env,
24 reinterpret_cast<intptr_t>(this), 39 reinterpret_cast<intptr_t>(this),
25 content_view_core->GetJavaObject().obj(), 40 content_view_core->GetJavaObject().obj(),
26 initial_color)); 41 initial_color,
42 suggestions_array.obj(),
43 base::android::ToJavaArrayOfStrings(env, suggestion_labels).obj()));
27 } 44 }
28 45
29 ColorChooserAndroid::~ColorChooserAndroid() { 46 ColorChooserAndroid::~ColorChooserAndroid() {
30 } 47 }
31 48
32 void ColorChooserAndroid::End() { 49 void ColorChooserAndroid::End() {
33 if (!j_color_chooser_.is_null()) { 50 if (!j_color_chooser_.is_null()) {
34 JNIEnv* env = AttachCurrentThread(); 51 JNIEnv* env = AttachCurrentThread();
35 Java_ColorChooserAndroid_closeColorChooser(env, j_color_chooser_.obj()); 52 Java_ColorChooserAndroid_closeColorChooser(env, j_color_chooser_.obj());
36 } 53 }
(...skipping 11 matching lines...) Expand all
48 } 65 }
49 66
50 // ---------------------------------------------------------------------------- 67 // ----------------------------------------------------------------------------
51 // Native JNI methods 68 // Native JNI methods
52 // ---------------------------------------------------------------------------- 69 // ----------------------------------------------------------------------------
53 bool RegisterColorChooserAndroid(JNIEnv* env) { 70 bool RegisterColorChooserAndroid(JNIEnv* env) {
54 return RegisterNativesImpl(env); 71 return RegisterNativesImpl(env);
55 } 72 }
56 73
57 } // namespace web_contents_delegate_android 74 } // namespace web_contents_delegate_android
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698