OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/aura/remote_root_window_host_win.h" | 5 #include "ui/aura/remote_root_window_host_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 SetKeyState(keyboard_state, !!(flags & ui::EF_SHIFT_DOWN), VK_SHIFT); | 46 SetKeyState(keyboard_state, !!(flags & ui::EF_SHIFT_DOWN), VK_SHIFT); |
47 SetKeyState(keyboard_state, !!(flags & ui::EF_CONTROL_DOWN), VK_CONTROL); | 47 SetKeyState(keyboard_state, !!(flags & ui::EF_CONTROL_DOWN), VK_CONTROL); |
48 SetKeyState(keyboard_state, !!(flags & ui::EF_ALT_DOWN), VK_MENU); | 48 SetKeyState(keyboard_state, !!(flags & ui::EF_ALT_DOWN), VK_MENU); |
49 SetKeyState(keyboard_state, !!(flags & ui::EF_CAPS_LOCK_DOWN), VK_CAPITAL); | 49 SetKeyState(keyboard_state, !!(flags & ui::EF_CAPS_LOCK_DOWN), VK_CAPITAL); |
50 | 50 |
51 ::SetKeyboardState(keyboard_state); | 51 ::SetKeyboardState(keyboard_state); |
52 } | 52 } |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 void HandleOpenFile( | 56 void HandleOpenFile(const base::string16& title, |
57 const string16& title, | 57 const base::FilePath& default_path, |
58 const base::FilePath& default_path, | 58 const base::string16& filter, |
59 const string16& filter, | 59 const OpenFileCompletion& callback) { |
60 const OpenFileCompletion& callback) { | |
61 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 60 DCHECK(aura::RemoteRootWindowHostWin::Instance()); |
62 aura::RemoteRootWindowHostWin::Instance()->HandleOpenFile(title, | 61 aura::RemoteRootWindowHostWin::Instance()->HandleOpenFile(title, |
63 default_path, | 62 default_path, |
64 filter, | 63 filter, |
65 callback); | 64 callback); |
66 } | 65 } |
67 | 66 |
68 void HandleOpenMultipleFiles( | 67 void HandleOpenMultipleFiles(const base::string16& title, |
69 const string16& title, | 68 const base::FilePath& default_path, |
70 const base::FilePath& default_path, | 69 const base::string16& filter, |
71 const string16& filter, | 70 const OpenMultipleFilesCompletion& callback) { |
72 const OpenMultipleFilesCompletion& callback) { | |
73 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 71 DCHECK(aura::RemoteRootWindowHostWin::Instance()); |
74 aura::RemoteRootWindowHostWin::Instance()->HandleOpenMultipleFiles( | 72 aura::RemoteRootWindowHostWin::Instance()->HandleOpenMultipleFiles( |
75 title, | 73 title, |
76 default_path, | 74 default_path, |
77 filter, | 75 filter, |
78 callback); | 76 callback); |
79 } | 77 } |
80 | 78 |
81 void HandleSaveFile( | 79 void HandleSaveFile(const base::string16& title, |
82 const string16& title, | 80 const base::FilePath& default_path, |
83 const base::FilePath& default_path, | 81 const base::string16& filter, |
84 const string16& filter, | 82 int filter_index, |
85 int filter_index, | 83 const base::string16& default_extension, |
86 const string16& default_extension, | 84 const SaveFileCompletion& callback) { |
87 const SaveFileCompletion& callback) { | |
88 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 85 DCHECK(aura::RemoteRootWindowHostWin::Instance()); |
89 aura::RemoteRootWindowHostWin::Instance()->HandleSaveFile(title, | 86 aura::RemoteRootWindowHostWin::Instance()->HandleSaveFile(title, |
90 default_path, | 87 default_path, |
91 filter, | 88 filter, |
92 filter_index, | 89 filter_index, |
93 default_extension, | 90 default_extension, |
94 callback); | 91 callback); |
95 } | 92 } |
96 | 93 |
97 void HandleSelectFolder(const string16& title, | 94 void HandleSelectFolder(const base::string16& title, |
98 const SelectFolderCompletion& callback) { | 95 const SelectFolderCompletion& callback) { |
99 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 96 DCHECK(aura::RemoteRootWindowHostWin::Instance()); |
100 aura::RemoteRootWindowHostWin::Instance()->HandleSelectFolder(title, | 97 aura::RemoteRootWindowHostWin::Instance()->HandleSelectFolder(title, |
101 callback); | 98 callback); |
102 } | 99 } |
103 | 100 |
104 RemoteRootWindowHostWin* g_instance = NULL; | 101 RemoteRootWindowHostWin* g_instance = NULL; |
105 | 102 |
106 RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() { | 103 RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() { |
107 return g_instance; | 104 return g_instance; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowActivated, | 157 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowActivated, |
161 OnWindowActivated) | 158 OnWindowActivated) |
162 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPosAck, | 159 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPosAck, |
163 OnSetCursorPosAck) | 160 OnSetCursorPosAck) |
164 IPC_MESSAGE_UNHANDLED(handled = false) | 161 IPC_MESSAGE_UNHANDLED(handled = false) |
165 IPC_END_MESSAGE_MAP() | 162 IPC_END_MESSAGE_MAP() |
166 return handled; | 163 return handled; |
167 } | 164 } |
168 | 165 |
169 void RemoteRootWindowHostWin::HandleOpenFile( | 166 void RemoteRootWindowHostWin::HandleOpenFile( |
170 const string16& title, | 167 const base::string16& title, |
171 const base::FilePath& default_path, | 168 const base::FilePath& default_path, |
172 const string16& filter, | 169 const base::string16& filter, |
173 const OpenFileCompletion& callback) { | 170 const OpenFileCompletion& callback) { |
174 if (!host_) | 171 if (!host_) |
175 return; | 172 return; |
176 | 173 |
177 // Can only have one of these operations in flight. | 174 // Can only have one of these operations in flight. |
178 DCHECK(file_open_completion_callback_.is_null()); | 175 DCHECK(file_open_completion_callback_.is_null()); |
179 file_open_completion_callback_ = callback; | 176 file_open_completion_callback_ = callback; |
180 | 177 |
181 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, | 178 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, |
182 filter, | 179 filter, |
183 default_path, | 180 default_path, |
184 false)); | 181 false)); |
185 } | 182 } |
186 | 183 |
187 void RemoteRootWindowHostWin::HandleOpenMultipleFiles( | 184 void RemoteRootWindowHostWin::HandleOpenMultipleFiles( |
188 const string16& title, | 185 const base::string16& title, |
189 const base::FilePath& default_path, | 186 const base::FilePath& default_path, |
190 const string16& filter, | 187 const base::string16& filter, |
191 const OpenMultipleFilesCompletion& callback) { | 188 const OpenMultipleFilesCompletion& callback) { |
192 if (!host_) | 189 if (!host_) |
193 return; | 190 return; |
194 | 191 |
195 // Can only have one of these operations in flight. | 192 // Can only have one of these operations in flight. |
196 DCHECK(multi_file_open_completion_callback_.is_null()); | 193 DCHECK(multi_file_open_completion_callback_.is_null()); |
197 multi_file_open_completion_callback_ = callback; | 194 multi_file_open_completion_callback_ = callback; |
198 | 195 |
199 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, | 196 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, |
200 filter, | 197 filter, |
201 default_path, | 198 default_path, |
202 true)); | 199 true)); |
203 } | 200 } |
204 | 201 |
205 void RemoteRootWindowHostWin::HandleSaveFile( | 202 void RemoteRootWindowHostWin::HandleSaveFile( |
206 const string16& title, | 203 const base::string16& title, |
207 const base::FilePath& default_path, | 204 const base::FilePath& default_path, |
208 const string16& filter, | 205 const base::string16& filter, |
209 int filter_index, | 206 int filter_index, |
210 const string16& default_extension, | 207 const base::string16& default_extension, |
211 const SaveFileCompletion& callback) { | 208 const SaveFileCompletion& callback) { |
212 if (!host_) | 209 if (!host_) |
213 return; | 210 return; |
214 | 211 |
215 MetroViewerHostMsg_SaveAsDialogParams params; | 212 MetroViewerHostMsg_SaveAsDialogParams params; |
216 params.title = title; | 213 params.title = title; |
217 params.default_extension = default_extension; | 214 params.default_extension = default_extension; |
218 params.filter = filter; | 215 params.filter = filter; |
219 params.filter_index = filter_index; | 216 params.filter_index = filter_index; |
220 | 217 |
221 // Can only have one of these operations in flight. | 218 // Can only have one of these operations in flight. |
222 DCHECK(file_saveas_completion_callback_.is_null()); | 219 DCHECK(file_saveas_completion_callback_.is_null()); |
223 file_saveas_completion_callback_ = callback; | 220 file_saveas_completion_callback_ = callback; |
224 | 221 |
225 host_->Send(new MetroViewerHostMsg_DisplayFileSaveAs(params)); | 222 host_->Send(new MetroViewerHostMsg_DisplayFileSaveAs(params)); |
226 } | 223 } |
227 | 224 |
228 void RemoteRootWindowHostWin::HandleSelectFolder( | 225 void RemoteRootWindowHostWin::HandleSelectFolder( |
229 const string16& title, | 226 const base::string16& title, |
230 const SelectFolderCompletion& callback) { | 227 const SelectFolderCompletion& callback) { |
231 if (!host_) | 228 if (!host_) |
232 return; | 229 return; |
233 | 230 |
234 // Can only have one of these operations in flight. | 231 // Can only have one of these operations in flight. |
235 DCHECK(select_folder_completion_callback_.is_null()); | 232 DCHECK(select_folder_completion_callback_.is_null()); |
236 select_folder_completion_callback_ = callback; | 233 select_folder_completion_callback_ = callback; |
237 | 234 |
238 host_->Send(new MetroViewerHostMsg_DisplaySelectFolder(title)); | 235 host_->Send(new MetroViewerHostMsg_DisplaySelectFolder(title)); |
239 } | 236 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 } else { | 517 } else { |
521 ui::KeyEvent event(type, | 518 ui::KeyEvent event(type, |
522 ui::KeyboardCodeForWindowsKeyCode(vkey), | 519 ui::KeyboardCodeForWindowsKeyCode(vkey), |
523 flags, | 520 flags, |
524 is_character); | 521 is_character); |
525 delegate_->OnHostKeyEvent(&event); | 522 delegate_->OnHostKeyEvent(&event); |
526 } | 523 } |
527 } | 524 } |
528 | 525 |
529 } // namespace aura | 526 } // namespace aura |
OLD | NEW |