Chromium Code Reviews| Index: content/components/web_contents_delegate_android/color_chooser_android.cc |
| diff --git a/content/components/web_contents_delegate_android/color_chooser_android.cc b/content/components/web_contents_delegate_android/color_chooser_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aa53080bab1dc226f9c5f1d2050ebf8bcddd62d0 |
| --- /dev/null |
| +++ b/content/components/web_contents_delegate_android/color_chooser_android.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/components/web_contents_delegate_android/color_chooser_android.h" |
| + |
| +#include "content/public/browser/android/content_view_core.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "jni/ColorChooserAndroid_jni.h" |
| + |
| +namespace content { |
| + |
| +ColorChooserAndroid::ColorChooserAndroid(int identifier, |
| + content::WebContents* tab, |
| + SkColor initial_color) : |
| + ColorChooser::ColorChooser(identifier), |
| + content::WebContentsObserver(tab) { |
| + JNIEnv* env = AttachCurrentThread(); |
| + ContentViewCore* content_view_core = tab->GetContentNativeView(); |
| + DCHECK(content_view_core); |
| + |
| + j_color_chooser_.Reset(Java_ColorChooserAndroid_createColorChooserAndroid( |
| + env, |
| + reinterpret_cast<intptr_t>(this), |
| + content_view_core->GetJavaObject().obj(), initial_color)); |
| + |
| + Java_ColorChooserAndroid_openColorChooser(env, j_color_chooser_.obj()); |
|
bulach
2012/11/26 09:05:32
here and 22 is crossing twice the jni boundaries t
Miguel Garcia
2012/11/26 11:35:10
I really wanted to split the creation of the objec
|
| +} |
| + |
| +ColorChooserAndroid::~ColorChooserAndroid() { |
| +} |
| + |
| +void ColorChooserAndroid::End() { |
| +} |
| + |
| +void ColorChooserAndroid::SetSelectedColor(SkColor color) { |
| +} |
| + |
| +void ColorChooserAndroid::OnColorChosen(JNIEnv* env, jobject obj, jint color) { |
| + web_contents()->DidChooseColorInColorChooser(identifier(), color); |
| + web_contents()->DidEndColorChooser(identifier()); |
| +} |
| + |
| +content::ColorChooser* content::ColorChooser::Create( |
| + int identifier, content::WebContents* tab, SkColor initial_color) { |
| + return new ColorChooserAndroid(identifier, tab, initial_color); |
| +} |
| + |
| + |
| +// ---------------------------------------------------------------------------- |
| +// Native JNI methods |
| +// ---------------------------------------------------------------------------- |
| +bool RegisterColorChooserAndroid(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
|
bulach
2012/11/26 09:05:32
nit: add a \n
Miguel Garcia
2012/11/26 11:35:10
Done.
|
| +} |
|
bulach
2012/11/26 09:05:32
nit: // namespace content
Miguel Garcia
2012/11/26 11:35:10
Done.
|