| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/utility/shell_handler_win.h" | 5 #include "chrome/utility/shell_handler_win.h" |
| 6 | 6 |
| 7 #include <commdlg.h> | 7 #include <commdlg.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/common/chrome_utility_messages.h" | 11 #include "chrome/common/chrome_utility_messages.h" |
| 12 #include "content/public/utility/utility_thread.h" | 12 #include "content/public/utility/utility_thread.h" |
| 13 #include "ui/base/win/open_file_name_win.h" | 13 #include "ui/base/win/open_file_name_win.h" |
| 14 #include "ui/base/win/shell.h" | 14 #include "ui/base/win/shell.h" |
| 15 | 15 |
| 16 ShellHandler::ShellHandler() {} | 16 ShellHandler::ShellHandler() {} |
| 17 ShellHandler::~ShellHandler() {} | 17 ShellHandler::~ShellHandler() {} |
| 18 | 18 |
| 19 bool ShellHandler::OnMessageReceived(const IPC::Message& message) { | 19 bool ShellHandler::OnMessageReceived(const IPC::Message& message) { |
| 20 bool handled = true; | 20 bool handled = true; |
| 21 IPC_BEGIN_MESSAGE_MAP(ShellHandler, message) | 21 IPC_BEGIN_MESSAGE_MAP(ShellHandler, message) |
| 22 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_OpenItemViaShell, | 22 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_OpenFileViaShell, |
| 23 OnOpenItemViaShell) | 23 OnOpenFileViaShell) |
| 24 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_OpenFolderViaShell, |
| 25 OnOpenFolderViaShell) |
| 24 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetOpenFileName, | 26 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetOpenFileName, |
| 25 OnGetOpenFileName) | 27 OnGetOpenFileName) |
| 26 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetSaveFileName, | 28 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetSaveFileName, |
| 27 OnGetSaveFileName) | 29 OnGetSaveFileName) |
| 28 IPC_MESSAGE_UNHANDLED(handled = false) | 30 IPC_MESSAGE_UNHANDLED(handled = false) |
| 29 IPC_END_MESSAGE_MAP() | 31 IPC_END_MESSAGE_MAP() |
| 30 return handled; | 32 return handled; |
| 31 } | 33 } |
| 32 | 34 |
| 33 void ShellHandler::OnOpenItemViaShell(const base::FilePath& full_path) { | 35 void ShellHandler::OnOpenFileViaShell(const base::FilePath& full_path) { |
| 34 ui::win::OpenItemViaShell(full_path); | 36 ui::win::OpenFileViaShell(full_path); |
| 37 } |
| 38 |
| 39 void ShellHandler::OnOpenFolderViaShell(const base::FilePath& full_path) { |
| 40 ui::win::OpenFolderViaShell(full_path); |
| 35 } | 41 } |
| 36 | 42 |
| 37 void ShellHandler::OnGetOpenFileName( | 43 void ShellHandler::OnGetOpenFileName( |
| 38 HWND owner, | 44 HWND owner, |
| 39 DWORD flags, | 45 DWORD flags, |
| 40 const GetOpenFileNameFilter& filter, | 46 const GetOpenFileNameFilter& filter, |
| 41 const base::FilePath& initial_directory, | 47 const base::FilePath& initial_directory, |
| 42 const base::FilePath& filename) { | 48 const base::FilePath& filename) { |
| 43 ui::win::OpenFileName open_file_name(owner, flags); | 49 ui::win::OpenFileName open_file_name(owner, flags); |
| 44 open_file_name.SetInitialSelection(initial_directory, filename); | 50 open_file_name.SetInitialSelection(initial_directory, filename); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 87 } |
| 82 | 88 |
| 83 // Zero means the dialog was closed, otherwise we had an error. | 89 // Zero means the dialog was closed, otherwise we had an error. |
| 84 DWORD error_code = ::CommDlgExtendedError(); | 90 DWORD error_code = ::CommDlgExtendedError(); |
| 85 if (error_code != 0) | 91 if (error_code != 0) |
| 86 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; | 92 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; |
| 87 | 93 |
| 88 content::UtilityThread::Get()->Send( | 94 content::UtilityThread::Get()->Send( |
| 89 new ChromeUtilityHostMsg_GetSaveFileName_Failed()); | 95 new ChromeUtilityHostMsg_GetSaveFileName_Failed()); |
| 90 } | 96 } |
| OLD | NEW |