Chromium Code Reviews| Index: chrome/browser/ui/views/color_chooser_win.cc |
| diff --git a/chrome/browser/ui/views/color_chooser_win.cc b/chrome/browser/ui/views/color_chooser_win.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0643bf0fe88497616e5d06f08dfb4e947bc32b32 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/color_chooser_win.cc |
| @@ -0,0 +1,63 @@ |
| +// 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 <windows.h> |
| + |
| +#include "chrome/browser/platform_util.h" |
| +#include "chrome/browser/ui/color_chooser.h" |
| +#include "chrome/browser/ui/views/color_chooser_dialog_win.h" |
| +#include "content/browser/renderer_host/render_view_host.h" |
| +#include "content/browser/renderer_host/render_widget_host_view.h" |
| + |
| +class ColorChooserWin : public ColorChooser, |
| + public ColorChooserDialog::Listener { |
| + public: |
| + virtual void Open(SkColor initial_color); |
| + virtual void End() {} |
|
Peter Kasting
2012/02/07 01:46:24
Shouldn't these two functions do something?
keishi
2012/02/17 11:31:05
Unlike other platforms the Windows color chooser w
|
| + virtual void SetSelectedColor(SkColor color) {} |
| + |
| + virtual void DidChooseColor(SkColor color); |
| + virtual void DidEnd(); |
| + |
| + ColorChooserWin(unsigned identifier, RenderViewHost* rvh) |
| + : identifier_(identifier), |
| + render_view_host_(rvh), |
| + color_chooser_dialog_(NULL) {} |
|
Peter Kasting
2012/02/07 01:46:24
Nit: Don't inline this constructor
keishi
2012/02/17 11:31:05
Done.
|
| + ~ColorChooserWin(); |
| + |
| + virtual unsigned identifier() { return identifier_; } |
| + virtual RenderViewHost* render_view_host() { return render_view_host_; } |
| + |
| + private: |
| + unsigned identifier_; |
| + RenderViewHost* render_view_host_; |
| + scoped_refptr<ColorChooserDialog> color_chooser_dialog_; |
| +}; |
| + |
| +ColorChooser* ColorChooser::Create(unsigned identifier, RenderViewHost* rvh) { |
| + return new ColorChooserWin(identifier, rvh); |
| +} |
| + |
| +void ColorChooserWin::Open(SkColor initial_color) { |
| + gfx::NativeWindow owning_window = platform_util::GetTopLevel( |
| + render_view_host_->view()->GetNativeView()); |
| + color_chooser_dialog_ = ColorChooserDialog::Create(this); |
| + color_chooser_dialog_->SelectColor(initial_color, owning_window); |
| +} |
| + |
| +ColorChooserWin::~ColorChooserWin() { |
| + if (color_chooser_dialog_.get()) |
| + color_chooser_dialog_->ListenerDestroyed(); |
| +} |
| + |
| +void ColorChooserWin::DidChooseColor(SkColor color) { |
| + if (render_view_host_) |
| + render_view_host_->DidChooseColorInColorChooser(identifier_, color); |
| +} |
| + |
| +void ColorChooserWin::DidEnd() { |
| + if (color_chooser_dialog_.get()) |
| + color_chooser_dialog_ = NULL; |
|
Peter Kasting
2012/02/07 01:46:24
Nit: Use .reset()
keishi
2012/02/17 11:31:05
color_chooser_dialog_ is a scoped_refptr so I can'
|
| + render_view_host_->DidEndColorChooser(identifier_); |
| +} |