OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/metro_viewer/metro_viewer_process_host_win.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "ipc/ipc_channel_proxy.h" |
| 10 #include "ui/metro_viewer/metro_viewer_messages.h" |
| 11 #include "ui/surface/accelerated_surface_win.h" |
| 12 |
| 13 MetroViewerProcessHost::MetroViewerProcessHost() { |
| 14 channel_.reset(new IPC::ChannelProxy( |
| 15 // TODO(scottmg): Need to have a secure way to randomize and request |
| 16 // this name from the viewer-side. |
| 17 "viewer", |
| 18 IPC::Channel::MODE_NAMED_SERVER, |
| 19 this, |
| 20 content::BrowserThread::GetMessageLoopProxyForThread( |
| 21 content::BrowserThread::IO))); |
| 22 } |
| 23 |
| 24 MetroViewerProcessHost::~MetroViewerProcessHost() { |
| 25 } |
| 26 |
| 27 bool MetroViewerProcessHost::Send(IPC::Message* msg) { |
| 28 return channel_->Send(msg); |
| 29 } |
| 30 |
| 31 bool MetroViewerProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 32 DCHECK(CalledOnValidThread()); |
| 33 bool handled = true; |
| 34 IPC_BEGIN_MESSAGE_MAP(MetroViewerProcessHost, message) |
| 35 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface) |
| 36 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseEvent, OnMouseEvent) |
| 37 IPC_MESSAGE_UNHANDLED(handled = false) |
| 38 IPC_END_MESSAGE_MAP() |
| 39 return handled; |
| 40 } |
| 41 |
| 42 void MetroViewerProcessHost::OnSetTargetSurface( |
| 43 gfx::NativeViewId target_surface) { |
| 44 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; |
| 45 HWND hwnd = reinterpret_cast<HWND>(target_surface); |
| 46 |
| 47 scoped_refptr<AcceleratedPresenter> any_window = |
| 48 AcceleratedPresenter::GetForWindow(NULL); |
| 49 any_window->SetNewTargetWindow(hwnd); |
| 50 } |
| 51 |
| 52 void MetroViewerProcessHost::OnMouseEvent( |
| 53 int msg, WPARAM w_param, LPARAM l_param) { |
| 54 // TODO(scottmg): Pass to window. |
| 55 } |
OLD | NEW |