Index: components/web_contents_delegate_android/color_chooser_android.cc |
diff --git a/components/web_contents_delegate_android/color_chooser_android.cc b/components/web_contents_delegate_android/color_chooser_android.cc |
index 4eb3d03d7040fd0dc2f5f0c4e7ebbbd6025ea592..a1dcf409bf2aedebeb4c6170ff615b2ac88c4188 100644 |
--- a/components/web_contents_delegate_android/color_chooser_android.cc |
+++ b/components/web_contents_delegate_android/color_chooser_android.cc |
@@ -4,26 +4,52 @@ |
#include "components/web_contents_delegate_android/color_chooser_android.h" |
+#include "base/android/jni_array.h" |
+#include "base/android/jni_string.h" |
#include "content/public/browser/android/content_view_core.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_view.h" |
+#include "content/public/common/color_suggestion.h" |
#include "jni/ColorChooserAndroid_jni.h" |
+using base::android::ConvertUTF16ToJavaString; |
+ |
namespace web_contents_delegate_android { |
-ColorChooserAndroid::ColorChooserAndroid(content::WebContents* web_contents, |
- SkColor initial_color) |
+ColorChooserAndroid::ColorChooserAndroid( |
+ content::WebContents* web_contents, |
+ SkColor initial_color, |
+ const std::vector<content::ColorSuggestion>& suggestions) |
: web_contents_(web_contents) { |
JNIEnv* env = AttachCurrentThread(); |
content::ContentViewCore* content_view_core = |
content::ContentViewCore::FromWebContents(web_contents); |
DCHECK(content_view_core); |
+ ScopedJavaLocalRef<jobjectArray> suggestions_array; |
+ |
+ if (suggestions.size() > 0) { |
+ suggestions_array = Java_ColorChooserAndroid_createColorSuggestionArray( |
+ env, suggestions.size()); |
+ |
+ for (size_t i = 0; i < suggestions.size(); ++i) { |
+ const content::ColorSuggestion& suggestion = suggestions[i]; |
+ ScopedJavaLocalRef<jstring> label = ConvertUTF16ToJavaString( |
+ env, suggestion.label); |
+ Java_ColorChooserAndroid_addToColorSuggestionArray( |
+ env, |
+ suggestions_array.obj(), |
+ i, |
+ suggestion.color, |
+ label.obj()); |
+ } |
+ } |
j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid( |
env, |
reinterpret_cast<intptr_t>(this), |
content_view_core->GetJavaObject().obj(), |
- initial_color)); |
+ initial_color, |
+ suggestions_array.obj())); |
} |
ColorChooserAndroid::~ColorChooserAndroid() { |