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

Unified Diff: content/components/web_contents_delegate_android/color_chooser_android.cc

Issue 11316153: implement input type=color for android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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) :
Peter Beverloo 2012/11/23 17:55:48 nit: the colon should be on the next line, two spa
Miguel Garcia 2012/11/26 11:35:10 Done.
+ 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());
+}
+
+ColorChooserAndroid::~ColorChooserAndroid() {
+}
+
+void ColorChooserAndroid::End() {
Peter Beverloo 2012/11/23 17:55:48 When the WebContentsImpl gets destroyed, it will c
Miguel Garcia 2012/11/27 18:44:30 Done.
+}
+
+void ColorChooserAndroid::SetSelectedColor(SkColor color) {
Peter Beverloo 2012/11/23 17:55:48 This will also be used for setting the current col
Miguel Garcia 2012/11/27 18:44:30 This works fine as is, sinec the initial_color is
+}
+
+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);
+}
+}
Peter Beverloo 2012/11/23 17:55:48 nit: empty line above here, and add a "// namespac
Miguel Garcia 2012/11/26 11:35:10 Done.

Powered by Google App Engine
This is Rietveld 408576698