Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: chrome/browser/ui/views/color_chooser_aura.cc

Issue 10442020: Initial implementation of ColorChooser for Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/browser/color_chooser.h" 5 #include "content/public/browser/color_chooser.h"
6 #include "content/public/browser/web_contents.h"
7 #include "ui/views/color_chooser/color_chooser_listener.h"
8 #include "ui/views/color_chooser/color_chooser_view.h"
9 #include "ui/views/widget/widget.h"
6 10
7 #include "base/logging.h" 11
12 namespace {
13
14 class ColorChooserAura : public content::ColorChooser,
15 public views::ColorChooserListener {
16 public:
17 ColorChooserAura(int identifier,
18 content::WebContents* tab,
19 SkColor initial_color);
20
21 private:
22 // content::ColorChooser overrides:
23 virtual void End() OVERRIDE;
24 virtual void SetSelectedColor(SkColor color) OVERRIDE;
25
26 // views::ColorChooserListener overrides:
27 virtual void OnColorChosen(SkColor color) OVERRIDE;
28 virtual void OnColorChooserDialogClosed() OVERRIDE;
29
30 // 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
31 content::WebContents* tab_;
32
33 // 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
34 // deleted when it's closed.
35 views::ColorChooserView* view_;
36
37 DISALLOW_COPY_AND_ASSIGN(ColorChooserAura);
38 };
39
40 ColorChooserAura::ColorChooserAura(int identifier,
41 content::WebContents* tab,
42 SkColor initial_color)
43 : ColorChooser(identifier),
44 tab_(tab) {
45 view_ = new views::ColorChooserView(this, initial_color);
46 views::Widget* widget = views::Widget::CreateWindow(view_);
47 widget->SetAlwaysOnTop(true);
48 widget->Show();
49 }
50
51 void ColorChooserAura::OnColorChosen(SkColor color) {
52 if (tab_)
53 tab_->DidChooseColorInColorChooser(identifier(), color);
54 }
55
56 void ColorChooserAura::OnColorChooserDialogClosed() {
57 if (tab_)
58 tab_->DidEndColorChooser(identifier());
59 view_ = NULL;
60 }
61
62 void ColorChooserAura::End() {
63 if (view_) {
64 view_->OnOwningWindowClosed();
65 view_ = NULL;
66 }
67 }
68
69 void ColorChooserAura::SetSelectedColor(SkColor color) {
70 if (view_)
71 view_->OnColorChanged(color);
72 }
73
74 } // namespace
8 75
9 // static 76 // static
10 content::ColorChooser* content::ColorChooser::Create( 77 content::ColorChooser* content::ColorChooser::Create(
11 int identifier, content::WebContents* tab, SkColor initial_color) { 78 int identifier, content::WebContents* tab, SkColor initial_color) {
12 NOTIMPLEMENTED(); 79 return new ColorChooserAura(identifier, tab, initial_color);
13 return NULL;
14 } 80 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/color_chooser_dialog.h » ('j') | ui/views/color_chooser/color_chooser_view.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698