OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ash/test/test_metro_viewer_process_host.h" | 5 #include "ash/test/test_metro_viewer_process_host.h" |
6 | 6 |
7 #include <windef.h> | 7 #include <windef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/aura/remote_window_tree_host_win.h" | 10 #include "ui/aura/remote_window_tree_host_win.h" |
11 #include "ui/gfx/win/dpi.h" | 11 #include "ui/gfx/win/dpi.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 TestMetroViewerProcessHost::TestMetroViewerProcessHost( | 16 TestMetroViewerProcessHost::TestMetroViewerProcessHost( |
17 base::SingleThreadTaskRunner* ipc_task_runner) | 17 base::SingleThreadTaskRunner* ipc_task_runner) |
18 : MetroViewerProcessHost(ipc_task_runner), | 18 : MetroViewerProcessHost(ipc_task_runner), |
19 closed_unexpectedly_(false) { | 19 closed_unexpectedly_(false) { |
20 } | 20 } |
21 | 21 |
22 TestMetroViewerProcessHost::~TestMetroViewerProcessHost() { | 22 TestMetroViewerProcessHost::~TestMetroViewerProcessHost() { |
23 } | 23 } |
24 | 24 |
| 25 void TestMetroViewerProcessHost::TerminateViewer() { |
| 26 base::ProcessId viewer_process_id = GetViewerProcessId(); |
| 27 if (viewer_process_id != base::kNullProcessId) { |
| 28 base::ProcessHandle viewer_process = NULL; |
| 29 base::OpenProcessHandleWithAccess( |
| 30 viewer_process_id, |
| 31 PROCESS_QUERY_INFORMATION | SYNCHRONIZE | PROCESS_TERMINATE, |
| 32 &viewer_process); |
| 33 if (viewer_process) { |
| 34 ::TerminateProcess(viewer_process, 0); |
| 35 ::WaitForSingleObject(viewer_process, INFINITE); |
| 36 ::CloseHandle(viewer_process); |
| 37 } |
| 38 } |
| 39 } |
| 40 |
25 void TestMetroViewerProcessHost::OnChannelError() { | 41 void TestMetroViewerProcessHost::OnChannelError() { |
26 closed_unexpectedly_ = true; | 42 closed_unexpectedly_ = true; |
27 aura::RemoteWindowTreeHostWin::Instance()->Disconnected(); | 43 aura::RemoteWindowTreeHostWin::Instance()->Disconnected(); |
28 } | 44 } |
29 | 45 |
30 void TestMetroViewerProcessHost::OnSetTargetSurface( | 46 void TestMetroViewerProcessHost::OnSetTargetSurface( |
31 gfx::NativeViewId target_surface, | 47 gfx::NativeViewId target_surface, |
32 float device_scale) { | 48 float device_scale) { |
33 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; | 49 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; |
34 HWND hwnd = reinterpret_cast<HWND>(target_surface); | 50 HWND hwnd = reinterpret_cast<HWND>(target_surface); |
35 gfx::InitDeviceScaleFactor(device_scale); | 51 gfx::InitDeviceScaleFactor(device_scale); |
36 aura::RemoteWindowTreeHostWin::Instance()->SetRemoteWindowHandle(hwnd); | 52 aura::RemoteWindowTreeHostWin::Instance()->SetRemoteWindowHandle(hwnd); |
37 aura::RemoteWindowTreeHostWin::Instance()->Connected(this); | 53 aura::RemoteWindowTreeHostWin::Instance()->Connected(this); |
38 } | 54 } |
39 | 55 |
40 void TestMetroViewerProcessHost::OnOpenURL(const base::string16& url) { | 56 void TestMetroViewerProcessHost::OnOpenURL(const base::string16& url) { |
41 } | 57 } |
42 | 58 |
43 void TestMetroViewerProcessHost::OnHandleSearchRequest( | 59 void TestMetroViewerProcessHost::OnHandleSearchRequest( |
44 const base::string16& search_string) { | 60 const base::string16& search_string) { |
45 } | 61 } |
46 | 62 |
47 void TestMetroViewerProcessHost::OnWindowSizeChanged(uint32 width, | 63 void TestMetroViewerProcessHost::OnWindowSizeChanged(uint32 width, |
48 uint32 height) { | 64 uint32 height) { |
49 } | 65 } |
50 | 66 |
51 } // namespace test | 67 } // namespace test |
52 } // namespace ash | 68 } // namespace ash |
OLD | NEW |