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 15 matching lines...) Expand all Loading... |
26 | 26 |
27 const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__"; | 27 const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__"; |
28 | 28 |
29 // The touch id to be used for touch events coming in from Windows Ash. | 29 // The touch id to be used for touch events coming in from Windows Ash. |
30 const int kRemoteWindowTouchId = 10; | 30 const int kRemoteWindowTouchId = 10; |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 void HandleOpenFile( | 34 void HandleOpenFile( |
35 const string16& title, | 35 const string16& title, |
36 const FilePath& default_path, | 36 const base::FilePath& default_path, |
37 const string16& filter, | 37 const string16& filter, |
38 const OpenFileCompletion& callback) { | 38 const OpenFileCompletion& callback) { |
39 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 39 DCHECK(aura::RemoteRootWindowHostWin::Instance()); |
40 aura::RemoteRootWindowHostWin::Instance()->HandleOpenFile(title, | 40 aura::RemoteRootWindowHostWin::Instance()->HandleOpenFile(title, |
41 default_path, | 41 default_path, |
42 filter, | 42 filter, |
43 callback); | 43 callback); |
44 } | 44 } |
45 | 45 |
46 void HandleOpenMultipleFiles( | 46 void HandleOpenMultipleFiles( |
47 const string16& title, | 47 const string16& title, |
48 const FilePath& default_path, | 48 const base::FilePath& default_path, |
49 const string16& filter, | 49 const string16& filter, |
50 const OpenMultipleFilesCompletion& callback) { | 50 const OpenMultipleFilesCompletion& callback) { |
51 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 51 DCHECK(aura::RemoteRootWindowHostWin::Instance()); |
52 aura::RemoteRootWindowHostWin::Instance()->HandleOpenMultipleFiles( | 52 aura::RemoteRootWindowHostWin::Instance()->HandleOpenMultipleFiles( |
53 title, | 53 title, |
54 default_path, | 54 default_path, |
55 filter, | 55 filter, |
56 callback); | 56 callback); |
57 } | 57 } |
58 | 58 |
59 void HandleSaveFile( | 59 void HandleSaveFile( |
60 const string16& title, | 60 const string16& title, |
61 const FilePath& default_path, | 61 const base::FilePath& default_path, |
62 const string16& filter, | 62 const string16& filter, |
63 int filter_index, | 63 int filter_index, |
64 const string16& default_extension, | 64 const string16& default_extension, |
65 const SaveFileCompletion& callback) { | 65 const SaveFileCompletion& callback) { |
66 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 66 DCHECK(aura::RemoteRootWindowHostWin::Instance()); |
67 aura::RemoteRootWindowHostWin::Instance()->HandleSaveFile(title, | 67 aura::RemoteRootWindowHostWin::Instance()->HandleSaveFile(title, |
68 default_path, | 68 default_path, |
69 filter, | 69 filter, |
70 filter_index, | 70 filter_index, |
71 default_extension, | 71 default_extension, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 OnFileOpenDone) | 124 OnFileOpenDone) |
125 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MultiFileOpenDone, | 125 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MultiFileOpenDone, |
126 OnMultiFileOpenDone) | 126 OnMultiFileOpenDone) |
127 IPC_MESSAGE_UNHANDLED(handled = false) | 127 IPC_MESSAGE_UNHANDLED(handled = false) |
128 IPC_END_MESSAGE_MAP() | 128 IPC_END_MESSAGE_MAP() |
129 return handled; | 129 return handled; |
130 } | 130 } |
131 | 131 |
132 void RemoteRootWindowHostWin::HandleOpenFile( | 132 void RemoteRootWindowHostWin::HandleOpenFile( |
133 const string16& title, | 133 const string16& title, |
134 const FilePath& default_path, | 134 const base::FilePath& default_path, |
135 const string16& filter, | 135 const string16& filter, |
136 const OpenFileCompletion& callback) { | 136 const OpenFileCompletion& callback) { |
137 if (!host_) | 137 if (!host_) |
138 return; | 138 return; |
139 | 139 |
140 // Can only one of these operations in flight. | 140 // Can only one of these operations in flight. |
141 DCHECK(file_open_completion_callback_.is_null()); | 141 DCHECK(file_open_completion_callback_.is_null()); |
142 file_open_completion_callback_ = callback; | 142 file_open_completion_callback_ = callback; |
143 | 143 |
144 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, | 144 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, |
145 filter, | 145 filter, |
146 default_path.value(), | 146 default_path.value(), |
147 false)); | 147 false)); |
148 } | 148 } |
149 | 149 |
150 void RemoteRootWindowHostWin::HandleOpenMultipleFiles( | 150 void RemoteRootWindowHostWin::HandleOpenMultipleFiles( |
151 const string16& title, | 151 const string16& title, |
152 const FilePath& default_path, | 152 const base::FilePath& default_path, |
153 const string16& filter, | 153 const string16& filter, |
154 const OpenMultipleFilesCompletion& callback) { | 154 const OpenMultipleFilesCompletion& callback) { |
155 if (!host_) | 155 if (!host_) |
156 return; | 156 return; |
157 | 157 |
158 // Can only one of these operations in flight. | 158 // Can only one of these operations in flight. |
159 DCHECK(multi_file_open_completion_callback_.is_null()); | 159 DCHECK(multi_file_open_completion_callback_.is_null()); |
160 multi_file_open_completion_callback_ = callback; | 160 multi_file_open_completion_callback_ = callback; |
161 | 161 |
162 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, | 162 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, |
163 filter, | 163 filter, |
164 default_path.value(), | 164 default_path.value(), |
165 true)); | 165 true)); |
166 } | 166 } |
167 | 167 |
168 void RemoteRootWindowHostWin::HandleSaveFile( | 168 void RemoteRootWindowHostWin::HandleSaveFile( |
169 const string16& title, | 169 const string16& title, |
170 const FilePath& default_path, | 170 const base::FilePath& default_path, |
171 const string16& filter, | 171 const string16& filter, |
172 int filter_index, | 172 int filter_index, |
173 const string16& default_extension, | 173 const string16& default_extension, |
174 const SaveFileCompletion& callback) { | 174 const SaveFileCompletion& callback) { |
175 if (!host_) | 175 if (!host_) |
176 return; | 176 return; |
177 | 177 |
178 MetroViewerHostMsg_SaveAsDialogParams params; | 178 MetroViewerHostMsg_SaveAsDialogParams params; |
179 params.title = title; | 179 params.title = title; |
180 params.default_extension = default_extension; | 180 params.default_extension = default_extension; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 kRemoteWindowTouchId, | 375 kRemoteWindowTouchId, |
376 base::TimeDelta::FromMicroseconds(timestamp)); | 376 base::TimeDelta::FromMicroseconds(timestamp)); |
377 delegate_->OnHostTouchEvent(&event); | 377 delegate_->OnHostTouchEvent(&event); |
378 } | 378 } |
379 | 379 |
380 void RemoteRootWindowHostWin::OnFileSaveAsDone(bool success, | 380 void RemoteRootWindowHostWin::OnFileSaveAsDone(bool success, |
381 string16 filename, | 381 string16 filename, |
382 int filter_index) { | 382 int filter_index) { |
383 if (success) { | 383 if (success) { |
384 file_saveas_completion_callback_.Run( | 384 file_saveas_completion_callback_.Run( |
385 FilePath(filename), filter_index, NULL); | 385 base::FilePath(filename), filter_index, NULL); |
386 } | 386 } |
387 file_saveas_completion_callback_.Reset(); | 387 file_saveas_completion_callback_.Reset(); |
388 } | 388 } |
389 | 389 |
390 | 390 |
391 void RemoteRootWindowHostWin::OnFileOpenDone(bool success, string16 filename) { | 391 void RemoteRootWindowHostWin::OnFileOpenDone(bool success, string16 filename) { |
392 if (success) { | 392 if (success) { |
393 file_open_completion_callback_.Run( | 393 file_open_completion_callback_.Run( |
394 FilePath(filename), 0, NULL); | 394 base::FilePath(filename), 0, NULL); |
395 } | 395 } |
396 file_open_completion_callback_.Reset(); | 396 file_open_completion_callback_.Reset(); |
397 } | 397 } |
398 | 398 |
399 void RemoteRootWindowHostWin::OnMultiFileOpenDone( | 399 void RemoteRootWindowHostWin::OnMultiFileOpenDone( |
400 bool success, | 400 bool success, |
401 const std::vector<FilePath>& files) { | 401 const std::vector<base::FilePath>& files) { |
402 if (success) { | 402 if (success) { |
403 multi_file_open_completion_callback_.Run(files, NULL); | 403 multi_file_open_completion_callback_.Run(files, NULL); |
404 } | 404 } |
405 multi_file_open_completion_callback_.Reset(); | 405 multi_file_open_completion_callback_.Reset(); |
406 } | 406 } |
407 | 407 |
408 } // namespace aura | 408 } // namespace aura |
OLD | NEW |