| Index: chrome/browser/ui/views/color_chooser_aura.cc
|
| diff --git a/chrome/browser/ui/views/color_chooser_aura.cc b/chrome/browser/ui/views/color_chooser_aura.cc
|
| index b1087963cac05ba26a4d3919f61c568c7f0af261..76734220e8d3898f726271e65ff86e3cf9d1be0b 100644
|
| --- a/chrome/browser/ui/views/color_chooser_aura.cc
|
| +++ b/chrome/browser/ui/views/color_chooser_aura.cc
|
| @@ -3,12 +3,85 @@
|
| // found in the LICENSE file.
|
|
|
| #include "content/public/browser/color_chooser.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "ui/views/color_chooser/color_chooser_listener.h"
|
| +#include "ui/views/color_chooser/color_chooser_view.h"
|
| +#include "ui/views/widget/widget.h"
|
|
|
| -#include "base/logging.h"
|
| +
|
| +namespace {
|
| +
|
| +class ColorChooserAura : public content::ColorChooser,
|
| + public views::ColorChooserListener {
|
| + public:
|
| + ColorChooserAura(int identifier,
|
| + content::WebContents* tab,
|
| + SkColor initial_color);
|
| +
|
| + private:
|
| + // content::ColorChooser overrides:
|
| + virtual void End() OVERRIDE;
|
| + virtual void SetSelectedColor(SkColor color) OVERRIDE;
|
| +
|
| + // views::ColorChooserListener overrides:
|
| + virtual void OnColorChosen(SkColor color) OVERRIDE;
|
| + virtual void OnColorChooserDialogClosed() OVERRIDE;
|
| +
|
| + // The web contents invoking the color chooser. No ownership because it will
|
| + // outlive this class.
|
| + content::WebContents* tab_;
|
| +
|
| + // The actual view of the color chooser. No ownership because its parent
|
| + // view will take care of its lifetime.
|
| + views::ColorChooserView* view_;
|
| +
|
| + // The widget for the color chooser. No ownership because it's released
|
| + // automatically when closed.
|
| + views::Widget* widget_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ColorChooserAura);
|
| +};
|
| +
|
| +ColorChooserAura::ColorChooserAura(int identifier,
|
| + content::WebContents* tab,
|
| + SkColor initial_color)
|
| + : ColorChooser(identifier),
|
| + tab_(tab) {
|
| + view_ = new views::ColorChooserView(this, initial_color);
|
| + widget_ = views::Widget::CreateWindow(view_);
|
| + widget_->SetAlwaysOnTop(true);
|
| + widget_->Show();
|
| +}
|
| +
|
| +void ColorChooserAura::OnColorChosen(SkColor color) {
|
| + if (tab_)
|
| + tab_->DidChooseColorInColorChooser(identifier(), color);
|
| +}
|
| +
|
| +void ColorChooserAura::OnColorChooserDialogClosed() {
|
| + if (tab_)
|
| + tab_->DidEndColorChooser(identifier());
|
| + view_ = NULL;
|
| + widget_ = NULL;
|
| +}
|
| +
|
| +void ColorChooserAura::End() {
|
| + if (widget_ && widget_->IsVisible()) {
|
| + widget_->Close();
|
| + view_ = NULL;
|
| + widget_ = NULL;
|
| + }
|
| +}
|
| +
|
| +void ColorChooserAura::SetSelectedColor(SkColor color) {
|
| + if (view_)
|
| + view_->OnColorChanged(color);
|
| +}
|
| +
|
| +} // namespace
|
|
|
| // static
|
| content::ColorChooser* content::ColorChooser::Create(
|
| int identifier, content::WebContents* tab, SkColor initial_color) {
|
| - NOTIMPLEMENTED();
|
| - return NULL;
|
| + return new ColorChooserAura(identifier, tab, initial_color);
|
| }
|
|
|