| 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 "chrome/browser/lifetime/application_lifetime.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "ipc/ipc_channel_proxy.h" | 10 #include "ipc/ipc_channel_proxy.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 return channel_->Send(msg); | 30 return channel_->Send(msg); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool MetroViewerProcessHost::OnMessageReceived(const IPC::Message& message) { | 33 bool MetroViewerProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 34 DCHECK(CalledOnValidThread()); | 34 DCHECK(CalledOnValidThread()); |
| 35 bool handled = true; | 35 bool handled = true; |
| 36 IPC_BEGIN_MESSAGE_MAP(MetroViewerProcessHost, message) | 36 IPC_BEGIN_MESSAGE_MAP(MetroViewerProcessHost, message) |
| 37 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface) | 37 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface) |
| 38 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved) | 38 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved) |
| 39 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton) | 39 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton) |
| 40 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown) |
| 41 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyUp, OnKeyUp) |
| 40 IPC_MESSAGE_UNHANDLED(handled = false) | 42 IPC_MESSAGE_UNHANDLED(handled = false) |
| 41 IPC_END_MESSAGE_MAP() | 43 IPC_END_MESSAGE_MAP() |
| 42 return handled; | 44 return handled; |
| 43 } | 45 } |
| 44 | 46 |
| 45 void MetroViewerProcessHost::OnChannelError() { | 47 void MetroViewerProcessHost::OnChannelError() { |
| 46 // TODO(cpu): At some point we only close the browser. Right now this | 48 // TODO(cpu): At some point we only close the browser. Right now this |
| 47 // is very convenient for developing. | 49 // is very convenient for developing. |
| 48 DLOG(INFO) << "viewer channel error : Quitting browser"; | 50 DLOG(INFO) << "viewer channel error : Quitting browser"; |
| 49 browser::CloseAllBrowsers(); | 51 browser::CloseAllBrowsers(); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void MetroViewerProcessHost::OnSetTargetSurface( | 54 void MetroViewerProcessHost::OnSetTargetSurface( |
| 53 gfx::NativeViewId target_surface) { | 55 gfx::NativeViewId target_surface) { |
| 54 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; | 56 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; |
| 55 HWND hwnd = reinterpret_cast<HWND>(target_surface); | 57 HWND hwnd = reinterpret_cast<HWND>(target_surface); |
| 56 | 58 |
| 57 scoped_refptr<AcceleratedPresenter> any_window = | 59 scoped_refptr<AcceleratedPresenter> any_window = |
| 58 AcceleratedPresenter::GetForWindow(NULL); | 60 AcceleratedPresenter::GetForWindow(NULL); |
| 59 any_window->SetNewTargetWindow(hwnd); | 61 any_window->SetNewTargetWindow(hwnd); |
| 60 } | 62 } |
| 61 | 63 |
| 62 void MetroViewerProcessHost::OnMouseMoved(int x, int y, int modifiers) { | 64 // TODO(cpu): Find a decent way to get to the root window host in the |
| 63 // TODO(cpu): Find a decent way to get to the root window host. | 65 // next four methods. |
| 66 void MetroViewerProcessHost::OnMouseMoved(int32 x, int32 y, int32 modifiers) { |
| 64 aura::RemoteRootWindowHostWin::Instance()->OnMouseMoved(x, y, modifiers); | 67 aura::RemoteRootWindowHostWin::Instance()->OnMouseMoved(x, y, modifiers); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void MetroViewerProcessHost::OnMouseButton(int x, int y, int modifiers) { | 70 void MetroViewerProcessHost::OnMouseButton(int32 x, int32 y, int32 modifiers) { |
| 68 // TODO(cpu): Find a decent way to get to the root window host. | |
| 69 aura::RemoteRootWindowHostWin::Instance()->OnMouseClick(x, y, modifiers); | 71 aura::RemoteRootWindowHostWin::Instance()->OnMouseClick(x, y, modifiers); |
| 70 } | 72 } |
| 73 |
| 74 void MetroViewerProcessHost::OnKeyDown(uint32 vkey, |
| 75 uint32 repeat_count, |
| 76 uint32 scan_code) { |
| 77 aura::RemoteRootWindowHostWin::Instance()->OnKeyDown( |
| 78 vkey, repeat_count, scan_code); |
| 79 } |
| 80 |
| 81 void MetroViewerProcessHost::OnKeyUp(uint32 vkey, |
| 82 uint32 repeat_count, |
| 83 uint32 scan_code) { |
| 84 aura::RemoteRootWindowHostWin::Instance()->OnKeyUp( |
| 85 vkey, repeat_count, scan_code); |
| 86 } |
| OLD | NEW |