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 #include <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "chrome/browser/platform_util.h" | 7 #include "chrome/browser/platform_util.h" |
8 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
9 #include "chrome/browser/ui/host_desktop.h" | 9 #include "chrome/browser/ui/host_desktop.h" |
10 #include "chrome/browser/ui/views/color_chooser_aura.h" | 10 #include "chrome/browser/ui/views/color_chooser_aura.h" |
11 #include "chrome/browser/ui/views/color_chooser_dialog.h" | 11 #include "chrome/browser/ui/views/color_chooser_dialog.h" |
12 #include "content/public/browser/color_chooser.h" | 12 #include "content/public/browser/color_chooser.h" |
13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
14 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "ui/views/color_chooser/color_chooser_listener.h" | 16 #include "ui/views/color_chooser/color_chooser_listener.h" |
17 | 17 |
18 class ColorChooserWin : public content::ColorChooser, | 18 class ColorChooserWin : public content::ColorChooser, |
19 public views::ColorChooserListener { | 19 public views::ColorChooserListener { |
20 public: | 20 public: |
21 static ColorChooserWin* Open(content::WebContents* web_contents, | 21 static ColorChooserWin* Open(content::WebContents* web_contents, |
22 SkColor initial_color); | 22 SkColor initial_color); |
23 | 23 |
24 ColorChooserWin(content::WebContents* web_contents, | 24 ColorChooserWin(content::WebContents* web_contents, |
25 SkColor initial_color); | 25 SkColor initial_color); |
26 ~ColorChooserWin(); | 26 ~ColorChooserWin() override; |
27 | 27 |
28 // content::ColorChooser overrides: | 28 // content::ColorChooser overrides: |
29 virtual void End() override; | 29 void End() override; |
30 virtual void SetSelectedColor(SkColor color) override {} | 30 void SetSelectedColor(SkColor color) override {} |
31 | 31 |
32 // views::ColorChooserListener overrides: | 32 // views::ColorChooserListener overrides: |
33 virtual void OnColorChosen(SkColor color); | 33 void OnColorChosen(SkColor color) override; |
34 virtual void OnColorChooserDialogClosed(); | 34 void OnColorChooserDialogClosed() override; |
35 | 35 |
36 private: | 36 private: |
37 static ColorChooserWin* current_color_chooser_; | 37 static ColorChooserWin* current_color_chooser_; |
38 | 38 |
39 // The web contents invoking the color chooser. No ownership. because it will | 39 // The web contents invoking the color chooser. No ownership. because it will |
40 // outlive this class. | 40 // outlive this class. |
41 content::WebContents* web_contents_; | 41 content::WebContents* web_contents_; |
42 | 42 |
43 // The color chooser dialog which maintains the native color chooser UI. | 43 // The color chooser dialog which maintains the native color chooser UI. |
44 scoped_refptr<ColorChooserDialog> color_chooser_dialog_; | 44 scoped_refptr<ColorChooserDialog> color_chooser_dialog_; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 content::ColorChooser* ShowColorChooser(content::WebContents* web_contents, | 100 content::ColorChooser* ShowColorChooser(content::WebContents* web_contents, |
101 SkColor initial_color) { | 101 SkColor initial_color) { |
102 gfx::NativeView native_view = web_contents->GetNativeView(); | 102 gfx::NativeView native_view = web_contents->GetNativeView(); |
103 if (GetHostDesktopTypeForNativeView(native_view) == HOST_DESKTOP_TYPE_ASH) | 103 if (GetHostDesktopTypeForNativeView(native_view) == HOST_DESKTOP_TYPE_ASH) |
104 return ColorChooserAura::Open(web_contents, initial_color); | 104 return ColorChooserAura::Open(web_contents, initial_color); |
105 | 105 |
106 return ColorChooserWin::Open(web_contents, initial_color); | 106 return ColorChooserWin::Open(web_contents, initial_color); |
107 } | 107 } |
108 | 108 |
109 } // namespace chrome | 109 } // namespace chrome |
OLD | NEW |