| 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..91607ed439536835416163f69fee39c809e1f0bc
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/color_chooser_win.cc
|
| @@ -0,0 +1,67 @@
|
| +// 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.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 End() OVERRIDE {}
|
| + virtual void SetSelectedColor(SkColor color) OVERRIDE {}
|
| +
|
| + virtual void DidChooseColor(SkColor color);
|
| + virtual void DidEnd();
|
| +
|
| + ColorChooserWin(int identifier, RenderViewHost* rvh, SkColor initial_color);
|
| + ~ColorChooserWin();
|
| +
|
| + virtual int GetIdentifier() const OVERRIDE { return identifier_; }
|
| + virtual RenderViewHost* GetRenderViewHost() const OVERRIDE {
|
| + return render_view_host_;
|
| + }
|
| +
|
| + private:
|
| + int identifier_;
|
| + RenderViewHost* render_view_host_;
|
| + scoped_refptr<ColorChooserDialog> color_chooser_dialog_;
|
| +};
|
| +
|
| +ColorChooser* ColorChooser::Create(
|
| + int identifier, RenderViewHost* rvh, SkColor initial_color) {
|
| + return new ColorChooserWin(identifier, rvh, initial_color);
|
| +}
|
| +
|
| +ColorChooserWin::ColorChooserWin(
|
| + int identifier, RenderViewHost* rvh, SkColor initial_color)
|
| + : identifier_(identifier),
|
| + render_view_host_(rvh),
|
| + color_chooser_dialog_(NULL) {
|
| + gfx::NativeWindow owning_window = platform_util::GetTopLevel(
|
| + render_view_host_->view()->GetNativeView());
|
| + color_chooser_dialog_ = new ColorChooserDialog(this,
|
| + initial_color,
|
| + owning_window);
|
| +}
|
| +
|
| +ColorChooserWin::~ColorChooserWin() {
|
| + // Always call End() before destroying.
|
| + DCHECK(!color_chooser_dialog_);
|
| +}
|
| +
|
| +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;
|
| + render_view_host_->DidEndColorChooser(identifier_);
|
| +}
|
|
|