Chromium Code Reviews| 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..a9dd5165901e50edcc82ea10386142da4ae938fb 100644 |
| --- a/chrome/browser/ui/views/color_chooser_aura.cc |
| +++ b/chrome/browser/ui/views/color_chooser_aura.cc |
| @@ -3,12 +3,78 @@ |
| // 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. |
|
Peter Kasting
2012/06/21 18:46:16
Nit: Does "No ownership" here mean "We don't own t
Jun Mukai
2012/06/22 09:39:35
it will outlives this class. Added it to the comm
|
| + content::WebContents* tab_; |
| + |
| + // The actual view of the color chooser. No ownership because this will be |
|
Peter Kasting
2012/06/21 18:46:16
Nit: Does the second sentence here mean "This owns
Jun Mukai
2012/06/22 09:39:35
views parent normally takes care of the lifetime o
|
| + // deleted when it's closed. |
| + views::ColorChooserView* view_; |
| + |
| + 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); |
| + views::Widget* 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; |
| +} |
| + |
| +void ColorChooserAura::End() { |
| + if (view_) { |
| + view_->OnOwningWindowClosed(); |
| + view_ = 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); |
| } |