Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / web_contents_delegate_android / color_chooser_android.h
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.
4
5 #ifndef COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_
6 #define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_
7
8 #include <vector>
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"
14
15 using base::android::AttachCurrentThread;
16 using base::android::ScopedJavaLocalRef;
17
18 namespace content {
19 class WebContents;
20 struct ColorSuggestion;
21 }
22
23 namespace web_contents_delegate_android {
24
25 // Glues the Java (ColorPickerChooser.java) picker with the native part.
26 class ColorChooserAndroid : public content::ColorChooser {
27  public:
28   ColorChooserAndroid(content::WebContents* tab,
29                       SkColor initial_color,
30                       const std::vector<content::ColorSuggestion>& suggestions);
31   virtual ~ColorChooserAndroid();
32
33   void OnColorChosen(JNIEnv* env, jobject obj, jint color);
34
35   // ColorChooser interface
36   virtual void End() override;
37   virtual void SetSelectedColor(SkColor color) override;
38
39  private:
40   base::android::ScopedJavaGlobalRef<jobject> j_color_chooser_;
41
42   // The web contents invoking the color chooser.  No ownership. because it will
43   // outlive this class.
44   content::WebContents* web_contents_;
45
46   DISALLOW_COPY_AND_ASSIGN(ColorChooserAndroid);
47 };
48
49 // Native JNI methods
50 bool RegisterColorChooserAndroid(JNIEnv* env);
51
52 }  // namespace web_contents_delegate_android
53
54 #endif  // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_