1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/metro_viewer/metro_viewer_process_host_win.h"
#include "base/logging.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/ash/ash_init.h"
#include "content/public/browser/browser_thread.h"
#include "ipc/ipc_channel_proxy.h"
#include "ui/aura/remote_root_window_host_win.h"
#include "ui/metro_viewer/metro_viewer_messages.h"
#include "ui/surface/accelerated_surface_win.h"
MetroViewerProcessHost::MetroViewerProcessHost(
const std::string& ipc_channel_name) {
channel_.reset(new IPC::ChannelProxy(
ipc_channel_name.c_str(),
IPC::Channel::MODE_NAMED_SERVER,
this,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO)));
}
MetroViewerProcessHost::~MetroViewerProcessHost() {
}
bool MetroViewerProcessHost::Send(IPC::Message* msg) {
return channel_->Send(msg);
}
bool MetroViewerProcessHost::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(MetroViewerProcessHost, message)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetTargetSurface, OnSetTargetSurface)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyUp, OnKeyUp)
IPC_MESSAGE_HANDLER(MetroViewerHostMsg_Character, OnChar)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void MetroViewerProcessHost::OnChannelError() {
// TODO(cpu): At some point we only close the browser. Right now this
// is very convenient for developing.
DLOG(INFO) << "viewer channel error : Quitting browser";
browser::CloseAllBrowsers();
}
void MetroViewerProcessHost::OnSetTargetSurface(
gfx::NativeViewId target_surface) {
DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface;
HWND hwnd = reinterpret_cast<HWND>(target_surface);
chrome::OpenAsh();
scoped_refptr<AcceleratedPresenter> any_window =
AcceleratedPresenter::GetForWindow(NULL);
any_window->SetNewTargetWindow(hwnd);
}
// TODO(cpu): Find a decent way to get to the root window host in the
// next four methods.
void MetroViewerProcessHost::OnMouseMoved(int32 x, int32 y, int32 modifiers) {
aura::RemoteRootWindowHostWin::Instance()->OnMouseMoved(x, y, modifiers);
}
void MetroViewerProcessHost::OnMouseButton(
int32 x, int32 y, int32 extra, ui::EventType type, ui::EventFlags flags) {
aura::RemoteRootWindowHostWin::Instance()->OnMouseButton(
x, y, extra, type, flags);
}
void MetroViewerProcessHost::OnKeyDown(uint32 vkey,
uint32 repeat_count,
uint32 scan_code,
uint32 flags) {
aura::RemoteRootWindowHostWin::Instance()->OnKeyDown(
vkey, repeat_count, scan_code, flags);
}
void MetroViewerProcessHost::OnKeyUp(uint32 vkey,
uint32 repeat_count,
uint32 scan_code,
uint32 flags) {
aura::RemoteRootWindowHostWin::Instance()->OnKeyUp(
vkey, repeat_count, scan_code, flags);
}
void MetroViewerProcessHost::OnChar(uint32 key_code,
uint32 repeat_count,
uint32 scan_code,
uint32 flags) {
aura::RemoteRootWindowHostWin::Instance()->OnChar(
key_code, repeat_count, scan_code, flags);
}
|