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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_
6 #define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_
9 #include "base/android/jni_android.h"
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/strings/string16.h"
13 #include "content/public/browser/color_chooser.h"
15 using base::android::AttachCurrentThread;
16 using base::android::ScopedJavaLocalRef;
20 struct ColorSuggestion;
23 namespace web_contents_delegate_android {
25 // Glues the Java (ColorPickerChooser.java) picker with the native part.
26 class ColorChooserAndroid : public content::ColorChooser {
28 ColorChooserAndroid(content::WebContents* tab,
29 SkColor initial_color,
30 const std::vector<content::ColorSuggestion>& suggestions);
31 virtual ~ColorChooserAndroid();
33 void OnColorChosen(JNIEnv* env, jobject obj, jint color);
35 // ColorChooser interface
36 virtual void End() override;
37 virtual void SetSelectedColor(SkColor color) override;
40 base::android::ScopedJavaGlobalRef<jobject> j_color_chooser_;
42 // The web contents invoking the color chooser. No ownership. because it will
43 // outlive this class.
44 content::WebContents* web_contents_;
46 DISALLOW_COPY_AND_ASSIGN(ColorChooserAndroid);
50 bool RegisterColorChooserAndroid(JNIEnv* env);
52 } // namespace web_contents_delegate_android
54 #endif // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_