| 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, OnOpenFileViaShell) |
| 23 OnOpenItemViaShell) | 23 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_OpenFolderViaShell, OnOpenFolderViaShell) |
| 24 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetOpenFileName, | 24 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetOpenFileName, |
| 25 OnGetOpenFileName) | 25 OnGetOpenFileName) |
| 26 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetSaveFileName, | 26 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetSaveFileName, |
| 27 OnGetSaveFileName) | 27 OnGetSaveFileName) |
| 28 IPC_MESSAGE_UNHANDLED(handled = false) | 28 IPC_MESSAGE_UNHANDLED(handled = false) |
| 29 IPC_END_MESSAGE_MAP() | 29 IPC_END_MESSAGE_MAP() |
| 30 return handled; | 30 return handled; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void ShellHandler::OnOpenItemViaShell(const base::FilePath& full_path) { | 33 void ShellHandler::OnOpenFileViaShell(const base::FilePath& full_path) { |
| 34 ui::win::OpenItemViaShell(full_path); | 34 ui::win::OpenFileViaShell(full_path); |
| 35 } |
| 36 |
| 37 void ShellHandler::OnOpenFolderViaShell(const base::FilePath& full_path) { |
| 38 ui::win::OpenFolderViaShell(full_path); |
| 35 } | 39 } |
| 36 | 40 |
| 37 void ShellHandler::OnGetOpenFileName( | 41 void ShellHandler::OnGetOpenFileName( |
| 38 HWND owner, | 42 HWND owner, |
| 39 DWORD flags, | 43 DWORD flags, |
| 40 const GetOpenFileNameFilter& filter, | 44 const GetOpenFileNameFilter& filter, |
| 41 const base::FilePath& initial_directory, | 45 const base::FilePath& initial_directory, |
| 42 const base::FilePath& filename) { | 46 const base::FilePath& filename) { |
| 43 ui::win::OpenFileName open_file_name(owner, flags); | 47 ui::win::OpenFileName open_file_name(owner, flags); |
| 44 open_file_name.SetInitialSelection(initial_directory, filename); | 48 open_file_name.SetInitialSelection(initial_directory, filename); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 85 } |
| 82 | 86 |
| 83 // Zero means the dialog was closed, otherwise we had an error. | 87 // Zero means the dialog was closed, otherwise we had an error. |
| 84 DWORD error_code = ::CommDlgExtendedError(); | 88 DWORD error_code = ::CommDlgExtendedError(); |
| 85 if (error_code != 0) | 89 if (error_code != 0) |
| 86 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; | 90 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; |
| 87 | 91 |
| 88 content::UtilityThread::Get()->Send( | 92 content::UtilityThread::Get()->Send( |
| 89 new ChromeUtilityHostMsg_GetSaveFileName_Failed()); | 93 new ChromeUtilityHostMsg_GetSaveFileName_Failed()); |
| 90 } | 94 } |
| OLD | NEW |