OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/metro_viewer/metro_viewer_process_host_win.h" | 5 #include "chrome/browser/metro_viewer/metro_viewer_process_host_win.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/lifetime/application_lifetime.h" |
8 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
9 #include "ipc/ipc_channel_proxy.h" | 10 #include "ipc/ipc_channel_proxy.h" |
| 11 #include "ui/aura/remote_root_window_host_win.h" |
10 #include "ui/metro_viewer/metro_viewer_messages.h" | 12 #include "ui/metro_viewer/metro_viewer_messages.h" |
11 #include "ui/surface/accelerated_surface_win.h" | 13 #include "ui/surface/accelerated_surface_win.h" |
12 | 14 |
13 MetroViewerProcessHost::MetroViewerProcessHost() { | 15 MetroViewerProcessHost::MetroViewerProcessHost() { |
14 channel_.reset(new IPC::ChannelProxy( | 16 channel_.reset(new IPC::ChannelProxy( |
15 // TODO(scottmg): Need to have a secure way to randomize and request | 17 // TODO(scottmg): Need to have a secure way to randomize and request |
16 // this name from the viewer-side. | 18 // this name from the viewer-side. |
17 "viewer", | 19 "viewer", |
18 IPC::Channel::MODE_NAMED_SERVER, | 20 IPC::Channel::MODE_NAMED_SERVER, |
19 this, | 21 this, |
20 content::BrowserThread::GetMessageLoopProxyForThread( | 22 content::BrowserThread::GetMessageLoopProxyForThread( |
21 content::BrowserThread::IO))); | 23 content::BrowserThread::IO))); |
22 } | 24 } |
23 | 25 |
24 MetroViewerProcessHost::~MetroViewerProcessHost() { | 26 MetroViewerProcessHost::~MetroViewerProcessHost() { |
25 } | 27 } |
26 | 28 |
27 bool MetroViewerProcessHost::Send(IPC::Message* msg) { | 29 bool MetroViewerProcessHost::Send(IPC::Message* msg) { |
28 return channel_->Send(msg); | 30 return channel_->Send(msg); |
29 } | 31 } |
30 | 32 |
31 bool MetroViewerProcessHost::OnMessageReceived(const IPC::Message& message) { | 33 bool MetroViewerProcessHost::OnMessageReceived(const IPC::Message& message) { |
32 DCHECK(CalledOnValidThread()); | 34 DCHECK(CalledOnValidThread()); |
33 bool handled = true; | 35 bool handled = true; |
34 IPC_BEGIN_MESSAGE_MAP(MetroViewerProcessHost, message) | 36 IPC_BEGIN_MESSAGE_MAP(MetroViewerProcessHost, message) |
35 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface) | 37 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface) |
36 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseEvent, OnMouseEvent) | 38 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved) |
| 39 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton) |
37 IPC_MESSAGE_UNHANDLED(handled = false) | 40 IPC_MESSAGE_UNHANDLED(handled = false) |
38 IPC_END_MESSAGE_MAP() | 41 IPC_END_MESSAGE_MAP() |
39 return handled; | 42 return handled; |
40 } | 43 } |
41 | 44 |
| 45 void MetroViewerProcessHost::OnChannelError() { |
| 46 // TODO(cpu): At some point we only close the browser. Right now this |
| 47 // is very convenient for developing. |
| 48 DLOG(INFO) << "viewer channel error : Quitting browser"; |
| 49 browser::CloseAllBrowsers(); |
| 50 } |
| 51 |
42 void MetroViewerProcessHost::OnSetTargetSurface( | 52 void MetroViewerProcessHost::OnSetTargetSurface( |
43 gfx::NativeViewId target_surface) { | 53 gfx::NativeViewId target_surface) { |
44 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; | 54 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; |
45 HWND hwnd = reinterpret_cast<HWND>(target_surface); | 55 HWND hwnd = reinterpret_cast<HWND>(target_surface); |
46 | 56 |
47 scoped_refptr<AcceleratedPresenter> any_window = | 57 scoped_refptr<AcceleratedPresenter> any_window = |
48 AcceleratedPresenter::GetForWindow(NULL); | 58 AcceleratedPresenter::GetForWindow(NULL); |
49 any_window->SetNewTargetWindow(hwnd); | 59 any_window->SetNewTargetWindow(hwnd); |
50 } | 60 } |
51 | 61 |
52 void MetroViewerProcessHost::OnMouseEvent( | 62 void MetroViewerProcessHost::OnMouseMoved(int x, int y, int modifiers) { |
53 int msg, WPARAM w_param, LPARAM l_param) { | 63 // TODO(cpu): Find a decent way to get to the root window host. |
54 // TODO(scottmg): Pass to window. | 64 aura::RemoteRootWindowHostWin::Instance()->OnMouseMoved(x, y, modifiers); |
55 } | 65 } |
| 66 |
| 67 void MetroViewerProcessHost::OnMouseButton(int x, int y, int modifiers) { |
| 68 // TODO(cpu): Find a decent way to get to the root window host. |
| 69 aura::RemoteRootWindowHostWin::Instance()->OnMouseClick(x, y, modifiers); |
| 70 } |
OLD | NEW |