OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <atlbase.h> | 5 #include <atlbase.h> |
6 #include <atlapp.h> // NOLINT | 6 #include <atlapp.h> // NOLINT |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/message_loop/message_pump_dispatcher.h" |
| 15 #include "base/run_loop.h" |
14 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
15 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
16 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
17 #include "cloud_print/common/win/cloud_print_utils.h" | 19 #include "cloud_print/common/win/cloud_print_utils.h" |
18 #include "cloud_print/resources.h" | 20 #include "cloud_print/resources.h" |
19 #include "cloud_print/service/service_state.h" | 21 #include "cloud_print/service/service_state.h" |
20 #include "cloud_print/service/win/chrome_launcher.h" | 22 #include "cloud_print/service/win/chrome_launcher.h" |
21 #include "cloud_print/service/win/service_controller.h" | 23 #include "cloud_print/service/win/service_controller.h" |
22 #include "cloud_print/service/win/service_utils.h" | 24 #include "cloud_print/service/win/service_utils.h" |
23 #include "cloud_print/service/win/setup_listener.h" | 25 #include "cloud_print/service/win/setup_listener.h" |
24 | 26 |
25 using cloud_print::LoadLocalString; | 27 using cloud_print::LoadLocalString; |
26 using cloud_print::GetErrorMessage; | 28 using cloud_print::GetErrorMessage; |
27 | 29 |
28 class SetupDialog : public base::RefCounted<SetupDialog>, | 30 class SetupDialog : public base::RefCounted<SetupDialog>, |
29 public ATL::CDialogImpl<SetupDialog> { | 31 public ATL::CDialogImpl<SetupDialog> { |
30 public: | 32 public: |
31 // Enables accelerators. | 33 // Enables accelerators. |
32 class MessageFilter : public base::MessageLoopForUI::MessageFilter { | 34 class Dispatcher : public base::MessagePumpDispatcher { |
33 public: | 35 public: |
34 explicit MessageFilter(SetupDialog* dialog) : dialog_(dialog){} | 36 explicit Dispatcher(SetupDialog* dialog) : dialog_(dialog) {} |
35 virtual ~MessageFilter() {}; | 37 virtual ~Dispatcher() {}; |
36 | 38 |
37 // MessageLoopForUI::MessageFilter | 39 // MessagePumpDispatcher: |
38 virtual bool ProcessMessage(const MSG& msg) OVERRIDE { | 40 virtual bool Dispatch(const MSG& msg) OVERRIDE { |
39 MSG msg2 = msg; | 41 MSG msg2 = msg; |
40 return dialog_->IsDialogMessage(&msg2) != FALSE; | 42 if (!dialog_->IsDialogMessage(&msg2)) { |
| 43 ::TranslateMessage(&msg); |
| 44 ::DispatchMessage(&msg); |
| 45 } |
| 46 return true; |
41 } | 47 } |
42 | 48 |
43 private: | 49 private: |
44 scoped_refptr<SetupDialog> dialog_; | 50 scoped_refptr<SetupDialog> dialog_; |
45 }; | 51 }; |
46 | 52 |
47 typedef ATL::CDialogImpl<SetupDialog> Base; | 53 typedef ATL::CDialogImpl<SetupDialog> Base; |
48 enum { IDD = IDD_SETUP_DIALOG }; | 54 enum { IDD = IDD_SETUP_DIALOG }; |
49 | 55 |
50 BEGIN_MSG_MAP(SetupDialog) | 56 BEGIN_MSG_MAP(SetupDialog) |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 __in HINSTANCE hPrevInstance, | 443 __in HINSTANCE hPrevInstance, |
438 __in LPSTR lpCmdLine, | 444 __in LPSTR lpCmdLine, |
439 __in int nCmdShow) { | 445 __in int nCmdShow) { |
440 base::AtExitManager at_exit; | 446 base::AtExitManager at_exit; |
441 CommandLine::Init(0, NULL); | 447 CommandLine::Init(0, NULL); |
442 | 448 |
443 base::MessageLoopForUI loop; | 449 base::MessageLoopForUI loop; |
444 scoped_refptr<SetupDialog> dialog(new SetupDialog()); | 450 scoped_refptr<SetupDialog> dialog(new SetupDialog()); |
445 dialog->Create(NULL); | 451 dialog->Create(NULL); |
446 dialog->ShowWindow(SW_SHOW); | 452 dialog->ShowWindow(SW_SHOW); |
447 scoped_ptr<SetupDialog::MessageFilter> filter( | 453 SetupDialog::Dispatcher dispatcher(dialog); |
448 new SetupDialog::MessageFilter(dialog)); | 454 base::RunLoop run_loop; |
449 loop.SetMessageFilter(filter.Pass()); | 455 run_loop.set_dispatcher(&dispatcher); |
450 | 456 run_loop.Run(); |
451 loop.Run(); | |
452 return 0; | 457 return 0; |
453 } | 458 } |
OLD | NEW |