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/shell_dialogs/select_file_dialog_win.h" | 5 #include "ui/shell_dialogs/select_file_dialog_win.h" |
6 | 6 |
7 #include <shlobj.h> | 7 #include <shlobj.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/win/shortcut.h" | 23 #include "base/win/shortcut.h" |
24 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
25 #include "ui/aura/window_event_dispatcher.h" | 25 #include "ui/aura/window_event_dispatcher.h" |
26 #include "ui/aura/window_tree_host.h" | 26 #include "ui/aura/window_tree_host.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/base/win/open_file_name_win.h" | 28 #include "ui/base/win/open_file_name_win.h" |
29 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
30 #include "ui/shell_dialogs/base_shell_dialog_win.h" | 30 #include "ui/shell_dialogs/base_shell_dialog_win.h" |
31 #include "ui/shell_dialogs/shell_dialogs_delegate.h" | 31 #include "ui/shell_dialogs/shell_dialogs_delegate.h" |
32 #include "ui/strings/grit/ui_strings.h" | 32 #include "ui/strings/grit/ui_strings.h" |
| 33 #include "win8/viewer/metro_viewer_process_host.h" |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 bool CallBuiltinGetOpenFileName(OPENFILENAME* ofn) { | 37 bool CallBuiltinGetOpenFileName(OPENFILENAME* ofn) { |
37 return ::GetOpenFileName(ofn) == TRUE; | 38 return ::GetOpenFileName(ofn) == TRUE; |
38 } | 39 } |
39 | 40 |
40 bool CallBuiltinGetSaveFileName(OPENFILENAME* ofn) { | 41 bool CallBuiltinGetSaveFileName(OPENFILENAME* ofn) { |
41 return ::GetSaveFileName(ofn) == TRUE; | 42 return ::GetSaveFileName(ofn) == TRUE; |
42 } | 43 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 Type type, | 321 Type type, |
321 const base::string16& title, | 322 const base::string16& title, |
322 const base::FilePath& default_path, | 323 const base::FilePath& default_path, |
323 const FileTypeInfo* file_types, | 324 const FileTypeInfo* file_types, |
324 int file_type_index, | 325 int file_type_index, |
325 const base::FilePath::StringType& default_extension, | 326 const base::FilePath::StringType& default_extension, |
326 gfx::NativeWindow owning_window, | 327 gfx::NativeWindow owning_window, |
327 void* params) { | 328 void* params) { |
328 has_multiple_file_type_choices_ = | 329 has_multiple_file_type_choices_ = |
329 file_types ? file_types->extensions.size() > 1 : true; | 330 file_types ? file_types->extensions.size() > 1 : true; |
| 331 // If the owning_window passed in is in metro then we need to forward the |
| 332 // file open/save operations to metro. |
| 333 if (GetShellDialogsDelegate() && |
| 334 GetShellDialogsDelegate()->IsWindowInMetro(owning_window)) { |
| 335 if (type == SELECT_SAVEAS_FILE) { |
| 336 win8::MetroViewerProcessHost::HandleSaveFile( |
| 337 title, |
| 338 default_path, |
| 339 GetFilterForFileTypes(file_types), |
| 340 file_type_index, |
| 341 default_extension, |
| 342 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
| 343 base::Unretained(listener_)), |
| 344 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
| 345 base::Unretained(listener_))); |
| 346 return; |
| 347 } else if (type == SELECT_OPEN_FILE) { |
| 348 win8::MetroViewerProcessHost::HandleOpenFile( |
| 349 title, |
| 350 default_path, |
| 351 GetFilterForFileTypes(file_types), |
| 352 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
| 353 base::Unretained(listener_)), |
| 354 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
| 355 base::Unretained(listener_))); |
| 356 return; |
| 357 } else if (type == SELECT_OPEN_MULTI_FILE) { |
| 358 win8::MetroViewerProcessHost::HandleOpenMultipleFiles( |
| 359 title, |
| 360 default_path, |
| 361 GetFilterForFileTypes(file_types), |
| 362 base::Bind(&ui::SelectFileDialog::Listener::MultiFilesSelected, |
| 363 base::Unretained(listener_)), |
| 364 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
| 365 base::Unretained(listener_))); |
| 366 return; |
| 367 } else if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { |
| 368 base::string16 title_string = title; |
| 369 if (type == SELECT_UPLOAD_FOLDER && title_string.empty()) { |
| 370 // If it's for uploading don't use default dialog title to |
| 371 // make sure we clearly tell it's for uploading. |
| 372 title_string = l10n_util::GetStringUTF16( |
| 373 IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE); |
| 374 } |
| 375 win8::MetroViewerProcessHost::HandleSelectFolder( |
| 376 title_string, |
| 377 base::Bind(&ui::SelectFileDialog::Listener::FileSelected, |
| 378 base::Unretained(listener_)), |
| 379 base::Bind(&ui::SelectFileDialog::Listener::FileSelectionCanceled, |
| 380 base::Unretained(listener_))); |
| 381 return; |
| 382 } |
| 383 } |
330 HWND owner = owning_window && owning_window->GetRootWindow() | 384 HWND owner = owning_window && owning_window->GetRootWindow() |
331 ? owning_window->GetHost()->GetAcceleratedWidget() : NULL; | 385 ? owning_window->GetHost()->GetAcceleratedWidget() : NULL; |
332 | 386 |
333 ExecuteSelectParams execute_params(type, title, | 387 ExecuteSelectParams execute_params(type, title, |
334 default_path, file_types, file_type_index, | 388 default_path, file_types, file_type_index, |
335 default_extension, BeginRun(owner), | 389 default_extension, BeginRun(owner), |
336 owner, params); | 390 owner, params); |
337 execute_params.run_state.dialog_thread->message_loop()->PostTask( | 391 execute_params.run_state.dialog_thread->message_loop()->PostTask( |
338 FROM_HERE, | 392 FROM_HERE, |
339 base::Bind(&SelectFileDialogImpl::ExecuteSelectFile, this, | 393 base::Bind(&SelectFileDialogImpl::ExecuteSelectFile, this, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 SelectFileDialog* CreateDefaultWinSelectFileDialog( | 764 SelectFileDialog* CreateDefaultWinSelectFileDialog( |
711 SelectFileDialog::Listener* listener, | 765 SelectFileDialog::Listener* listener, |
712 SelectFilePolicy* policy) { | 766 SelectFilePolicy* policy) { |
713 return CreateWinSelectFileDialog(listener, | 767 return CreateWinSelectFileDialog(listener, |
714 policy, | 768 policy, |
715 base::Bind(&CallBuiltinGetOpenFileName), | 769 base::Bind(&CallBuiltinGetOpenFileName), |
716 base::Bind(&CallBuiltinGetSaveFileName)); | 770 base::Bind(&CallBuiltinGetSaveFileName)); |
717 } | 771 } |
718 | 772 |
719 } // namespace ui | 773 } // namespace ui |
OLD | NEW |