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