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