OLD | NEW |
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 "chrome/browser/ui/views/color_chooser_dialog.h" | 5 #include "chrome/browser/ui/views/color_chooser_dialog.h" |
6 | 6 |
7 #include <commdlg.h> | 7 #include <commdlg.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "skia/ext/skia_utils_win.h" | 13 #include "skia/ext/skia_utils_win.h" |
| 14 #include "ui/views/color_chooser/color_chooser_listener.h" |
14 | 15 |
15 using content::BrowserThread; | 16 using content::BrowserThread; |
16 | 17 |
17 // static | 18 // static |
18 COLORREF ColorChooserDialog::g_custom_colors[16]; | 19 COLORREF ColorChooserDialog::g_custom_colors[16]; |
19 | 20 |
20 ColorChooserDialog::ExecuteOpenParams::ExecuteOpenParams(SkColor color, | 21 ColorChooserDialog::ExecuteOpenParams::ExecuteOpenParams(SkColor color, |
21 RunState run_state, | 22 RunState run_state, |
22 HWND owner) | 23 HWND owner) |
23 : color(color), | 24 : color(color), |
24 run_state(run_state), | 25 run_state(run_state), |
25 owner(owner) { | 26 owner(owner) { |
26 } | 27 } |
27 | 28 |
28 ColorChooserDialog::ColorChooserDialog(Listener* listener, | 29 ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener, |
29 SkColor initial_color, | 30 SkColor initial_color, |
30 gfx::NativeWindow owning_window) | 31 gfx::NativeWindow owning_window) |
31 : listener_(listener) { | 32 : listener_(listener) { |
32 DCHECK(listener_); | 33 DCHECK(listener_); |
33 CopyCustomColors(g_custom_colors, custom_colors_); | 34 CopyCustomColors(g_custom_colors, custom_colors_); |
34 ExecuteOpenParams execute_params(initial_color, BeginRun(owning_window), | 35 ExecuteOpenParams execute_params(initial_color, BeginRun(owning_window), |
35 owning_window); | 36 owning_window); |
36 execute_params.run_state.dialog_thread->message_loop()->PostTask(FROM_HERE, | 37 execute_params.run_state.dialog_thread->message_loop()->PostTask(FROM_HERE, |
37 base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params)); | 38 base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params)); |
38 } | 39 } |
(...skipping 26 matching lines...) Expand all Loading... |
65 } | 66 } |
66 | 67 |
67 void ColorChooserDialog::DidCloseDialog(bool chose_color, | 68 void ColorChooserDialog::DidCloseDialog(bool chose_color, |
68 SkColor color, | 69 SkColor color, |
69 RunState run_state) { | 70 RunState run_state) { |
70 if (!listener_) | 71 if (!listener_) |
71 return; | 72 return; |
72 EndRun(run_state); | 73 EndRun(run_state); |
73 CopyCustomColors(custom_colors_, g_custom_colors); | 74 CopyCustomColors(custom_colors_, g_custom_colors); |
74 if (chose_color) | 75 if (chose_color) |
75 listener_->DidChooseColor(color); | 76 listener_->OnColorChosen(color); |
76 listener_->DidEnd(); | 77 listener_->OnColorChooserDialogClosed(); |
77 } | 78 } |
78 | 79 |
79 void ColorChooserDialog::CopyCustomColors(COLORREF* src, COLORREF* dst) { | 80 void ColorChooserDialog::CopyCustomColors(COLORREF* src, COLORREF* dst) { |
80 memcpy(dst, src, sizeof(COLORREF) * arraysize(g_custom_colors)); | 81 memcpy(dst, src, sizeof(COLORREF) * arraysize(g_custom_colors)); |
81 } | 82 } |
OLD | NEW |