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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/color_chooser_aura.h"
7 #include "chrome/browser/ui/browser_dialogs.h"
8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/browser_window.h"
10 #include "content/public/browser/web_contents.h"
11 #include "ui/views/color_chooser/color_chooser_view.h"
12 #include "ui/views/widget/widget.h"
14 ColorChooserAura::ColorChooserAura(content::WebContents* web_contents,
15 SkColor initial_color)
16 : web_contents_(web_contents) {
17 view_ = new views::ColorChooserView(this, initial_color);
18 widget_ = views::Widget::CreateWindowWithParent(
19 view_, web_contents->GetTopLevelNativeWindow());
23 void ColorChooserAura::OnColorChosen(SkColor color) {
25 web_contents_->DidChooseColorInColorChooser(color);
28 void ColorChooserAura::OnColorChooserDialogClosed() {
34 void ColorChooserAura::End() {
36 view_->set_listener(NULL);
40 // DidEndColorChooser will invoke Browser::DidEndColorChooser, which deletes
41 // this. Take care of the call order.
46 void ColorChooserAura::DidEndColorChooser() {
48 web_contents_->DidEndColorChooser();
51 void ColorChooserAura::SetSelectedColor(SkColor color) {
53 view_->OnColorChanged(color);
57 ColorChooserAura* ColorChooserAura::Open(
58 content::WebContents* web_contents, SkColor initial_color) {
59 return new ColorChooserAura(web_contents, initial_color);
65 content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
66 SkColor initial_color) {
67 return ColorChooserAura::Open(web_contents, initial_color);