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" | |
34 | 33 |
35 namespace { | 34 namespace { |
36 | 35 |
37 bool CallBuiltinGetOpenFileName(OPENFILENAME* ofn) { | 36 bool CallBuiltinGetOpenFileName(OPENFILENAME* ofn) { |
38 return ::GetOpenFileName(ofn) == TRUE; | 37 return ::GetOpenFileName(ofn) == TRUE; |
39 } | 38 } |
40 | 39 |
41 bool CallBuiltinGetSaveFileName(OPENFILENAME* ofn) { | 40 bool CallBuiltinGetSaveFileName(OPENFILENAME* ofn) { |
42 return ::GetSaveFileName(ofn) == TRUE; | 41 return ::GetSaveFileName(ofn) == TRUE; |
43 } | 42 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 Type type, | 320 Type type, |
322 const base::string16& title, | 321 const base::string16& title, |
323 const base::FilePath& default_path, | 322 const base::FilePath& default_path, |
324 const FileTypeInfo* file_types, | 323 const FileTypeInfo* file_types, |
325 int file_type_index, | 324 int file_type_index, |
326 const base::FilePath::StringType& default_extension, | 325 const base::FilePath::StringType& default_extension, |
327 gfx::NativeWindow owning_window, | 326 gfx::NativeWindow owning_window, |
328 void* params) { | 327 void* params) { |
329 has_multiple_file_type_choices_ = | 328 has_multiple_file_type_choices_ = |
330 file_types ? file_types->extensions.size() > 1 : true; | 329 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 } | |
384 HWND owner = owning_window && owning_window->GetRootWindow() | 330 HWND owner = owning_window && owning_window->GetRootWindow() |
385 ? owning_window->GetHost()->GetAcceleratedWidget() : NULL; | 331 ? owning_window->GetHost()->GetAcceleratedWidget() : NULL; |
386 | 332 |
387 ExecuteSelectParams execute_params(type, title, | 333 ExecuteSelectParams execute_params(type, title, |
388 default_path, file_types, file_type_index, | 334 default_path, file_types, file_type_index, |
389 default_extension, BeginRun(owner), | 335 default_extension, BeginRun(owner), |
390 owner, params); | 336 owner, params); |
391 execute_params.run_state.dialog_thread->message_loop()->PostTask( | 337 execute_params.run_state.dialog_thread->message_loop()->PostTask( |
392 FROM_HERE, | 338 FROM_HERE, |
393 base::Bind(&SelectFileDialogImpl::ExecuteSelectFile, this, | 339 base::Bind(&SelectFileDialogImpl::ExecuteSelectFile, this, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 SelectFileDialog* CreateDefaultWinSelectFileDialog( | 710 SelectFileDialog* CreateDefaultWinSelectFileDialog( |
765 SelectFileDialog::Listener* listener, | 711 SelectFileDialog::Listener* listener, |
766 SelectFilePolicy* policy) { | 712 SelectFilePolicy* policy) { |
767 return CreateWinSelectFileDialog(listener, | 713 return CreateWinSelectFileDialog(listener, |
768 policy, | 714 policy, |
769 base::Bind(&CallBuiltinGetOpenFileName), | 715 base::Bind(&CallBuiltinGetOpenFileName), |
770 base::Bind(&CallBuiltinGetSaveFileName)); | 716 base::Bind(&CallBuiltinGetSaveFileName)); |
771 } | 717 } |
772 | 718 |
773 } // namespace ui | 719 } // namespace ui |
OLD | NEW |