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

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

Issue 2211473003: Remove calls to deprecated MessageLoop methods on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
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 "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/macros.h" 10 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/single_thread_task_runner.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "skia/ext/skia_utils_win.h" 15 #include "skia/ext/skia_utils_win.h"
15 #include "ui/views/color_chooser/color_chooser_listener.h" 16 #include "ui/views/color_chooser/color_chooser_listener.h"
16 #include "ui/views/win/hwnd_util.h" 17 #include "ui/views/win/hwnd_util.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 20
20 // static 21 // static
21 COLORREF ColorChooserDialog::g_custom_colors[16]; 22 COLORREF ColorChooserDialog::g_custom_colors[16];
22 23
23 ColorChooserDialog::ExecuteOpenParams::ExecuteOpenParams(SkColor color, 24 ColorChooserDialog::ExecuteOpenParams::ExecuteOpenParams(SkColor color,
24 RunState run_state, 25 RunState run_state,
25 HWND owner) 26 HWND owner)
26 : color(color), 27 : color(color),
27 run_state(run_state), 28 run_state(run_state),
28 owner(owner) { 29 owner(owner) {
29 } 30 }
30 31
31 ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener, 32 ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener,
32 SkColor initial_color, 33 SkColor initial_color,
33 gfx::NativeWindow owning_window) 34 gfx::NativeWindow owning_window)
34 : listener_(listener) { 35 : listener_(listener) {
35 DCHECK(listener_); 36 DCHECK(listener_);
36 CopyCustomColors(g_custom_colors, custom_colors_); 37 CopyCustomColors(g_custom_colors, custom_colors_);
37 HWND owning_hwnd = views::HWNDForNativeWindow(owning_window); 38 HWND owning_hwnd = views::HWNDForNativeWindow(owning_window);
38 ExecuteOpenParams execute_params(initial_color, BeginRun(owning_hwnd), 39 ExecuteOpenParams execute_params(initial_color, BeginRun(owning_hwnd),
39 owning_hwnd); 40 owning_hwnd);
40 execute_params.run_state.dialog_thread->message_loop()->PostTask(FROM_HERE, 41 execute_params.run_state.dialog_thread->task_runner()->PostTask(
42 FROM_HERE,
41 base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params)); 43 base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params));
42 } 44 }
43 45
44 bool ColorChooserDialog::IsRunning(gfx::NativeWindow owning_window) const { 46 bool ColorChooserDialog::IsRunning(gfx::NativeWindow owning_window) const {
45 return listener_ && IsRunningDialogForOwner( 47 return listener_ && IsRunningDialogForOwner(
46 views::HWNDForNativeWindow(owning_window)); 48 views::HWNDForNativeWindow(owning_window));
47 } 49 }
48 50
49 void ColorChooserDialog::ListenerDestroyed() { 51 void ColorChooserDialog::ListenerDestroyed() {
50 // Our associated listener has gone away, so we shouldn't call back to it if 52 // Our associated listener has gone away, so we shouldn't call back to it if
(...skipping 26 matching lines...) Expand all
77 if (listener_) { 79 if (listener_) {
78 if (chose_color) 80 if (chose_color)
79 listener_->OnColorChosen(color); 81 listener_->OnColorChosen(color);
80 listener_->OnColorChooserDialogClosed(); 82 listener_->OnColorChooserDialogClosed();
81 } 83 }
82 } 84 }
83 85
84 void ColorChooserDialog::CopyCustomColors(COLORREF* src, COLORREF* dst) { 86 void ColorChooserDialog::CopyCustomColors(COLORREF* src, COLORREF* dst) {
85 memcpy(dst, src, sizeof(COLORREF) * arraysize(g_custom_colors)); 87 memcpy(dst, src, sizeof(COLORREF) * arraysize(g_custom_colors));
86 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698