| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_ | 5 #ifndef COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_ |
| 6 #define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_ | 6 #define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <vector> |
| 8 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/strings/string16.h" |
| 11 #include "content/public/browser/color_chooser.h" | 13 #include "content/public/browser/color_chooser.h" |
| 12 | 14 |
| 13 using base::android::AttachCurrentThread; | 15 using base::android::AttachCurrentThread; |
| 14 using base::android::ScopedJavaLocalRef; | 16 using base::android::ScopedJavaLocalRef; |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 class WebContents; | 19 class WebContents; |
| 20 struct ColorSuggestion; |
| 18 } | 21 } |
| 19 | 22 |
| 20 namespace web_contents_delegate_android { | 23 namespace web_contents_delegate_android { |
| 21 | 24 |
| 22 // Glues the Java (ColorPickerChooser.java) picker with the native part. | 25 // Glues the Java (ColorPickerChooser.java) picker with the native part. |
| 23 class ColorChooserAndroid : public content::ColorChooser { | 26 class ColorChooserAndroid : public content::ColorChooser { |
| 24 public: | 27 public: |
| 25 ColorChooserAndroid(content::WebContents* tab, | 28 ColorChooserAndroid(content::WebContents* tab, |
| 26 SkColor initial_color); | 29 SkColor initial_color, |
| 30 const std::vector<content::ColorSuggestion>& suggestions); |
| 27 virtual ~ColorChooserAndroid(); | 31 virtual ~ColorChooserAndroid(); |
| 28 | 32 |
| 29 void OnColorChosen(JNIEnv* env, jobject obj, jint color); | 33 void OnColorChosen(JNIEnv* env, jobject obj, jint color); |
| 30 | 34 |
| 31 // ColorChooser interface | 35 // ColorChooser interface |
| 32 virtual void End() OVERRIDE; | 36 virtual void End() OVERRIDE; |
| 33 virtual void SetSelectedColor(SkColor color) OVERRIDE; | 37 virtual void SetSelectedColor(SkColor color) OVERRIDE; |
| 34 | 38 |
| 35 private: | 39 private: |
| 36 base::android::ScopedJavaGlobalRef<jobject> j_color_chooser_; | 40 base::android::ScopedJavaGlobalRef<jobject> j_color_chooser_; |
| 37 | 41 |
| 38 // The web contents invoking the color chooser. No ownership. because it will | 42 // The web contents invoking the color chooser. No ownership. because it will |
| 39 // outlive this class. | 43 // outlive this class. |
| 40 content::WebContents* web_contents_; | 44 content::WebContents* web_contents_; |
| 41 | 45 |
| 42 DISALLOW_COPY_AND_ASSIGN(ColorChooserAndroid); | 46 DISALLOW_COPY_AND_ASSIGN(ColorChooserAndroid); |
| 43 }; | 47 }; |
| 44 | 48 |
| 45 // Native JNI methods | 49 // Native JNI methods |
| 46 bool RegisterColorChooserAndroid(JNIEnv* env); | 50 bool RegisterColorChooserAndroid(JNIEnv* env); |
| 47 | 51 |
| 48 } // namespace web_contents_delegate_android | 52 } // namespace web_contents_delegate_android |
| 49 | 53 |
| 50 #endif // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_ | 54 #endif // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_COLOR_CHOOSER_ANDROID_H_ |
| OLD | NEW |