diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/platform_util.h | 3 | ||||
-rw-r--r-- | chrome/common/platform_util_linux.cc | 22 | ||||
-rw-r--r-- | chrome/common/platform_util_mac.mm | 4 | ||||
-rw-r--r-- | chrome/common/platform_util_win.cc | 4 | ||||
-rw-r--r-- | chrome/common/win_safe_util.cc | 7 | ||||
-rw-r--r-- | chrome/common/win_safe_util.h | 4 |
6 files changed, 33 insertions, 11 deletions
diff --git a/chrome/common/platform_util.h b/chrome/common/platform_util.h index c4a46b7..54e7487 100644 --- a/chrome/common/platform_util.h +++ b/chrome/common/platform_util.h @@ -15,6 +15,9 @@ namespace platform_util { // Show the given file in a file manager. If possible, select the file. void ShowItemInFolder(const FilePath& full_path); +// Open the given file in the desktop's default manner. +void OpenItem(const FilePath& full_path); + // Get the top level window for the native view. This can return NULL. gfx::NativeWindow GetTopLevel(gfx::NativeView view); diff --git a/chrome/common/platform_util_linux.cc b/chrome/common/platform_util_linux.cc index 8d3a5a1..988de92 100644 --- a/chrome/common/platform_util_linux.cc +++ b/chrome/common/platform_util_linux.cc @@ -11,6 +11,18 @@ #include "base/process_util.h" #include "base/string_util.h" +namespace { + +void XDGOpen(const FilePath& path) { + std::vector<std::string> argv; + argv.push_back("xdg-open"); + argv.push_back(path.value()); + base::file_handle_mapping_vector no_files; + base::LaunchApp(argv, no_files, false, NULL); +} + +} // namespace + namespace platform_util { // TODO(estade): It would be nice to be able to select the file in the file @@ -21,11 +33,11 @@ void ShowItemInFolder(const FilePath& full_path) { if (!file_util::DirectoryExists(dir)) return; - std::vector<std::string> argv; - argv.push_back("xdg-open"); - argv.push_back(dir.value()); - base::file_handle_mapping_vector no_files; - base::LaunchApp(argv, no_files, false, NULL); + XDGOpen(dir); +} + +void OpenItem(const FilePath& full_path) { + XDGOpen(full_path); } gfx::NativeWindow GetTopLevel(gfx::NativeView view) { diff --git a/chrome/common/platform_util_mac.mm b/chrome/common/platform_util_mac.mm index 2586d1f..c3a4ab7 100644 --- a/chrome/common/platform_util_mac.mm +++ b/chrome/common/platform_util_mac.mm @@ -21,6 +21,10 @@ void ShowItemInFolder(const FilePath& full_path) { inFileViewerRootedAtPath:nil]; } +void OpenItem(const FilePath& full_path) { + NOTIMPLEMENTED(); +} + gfx::NativeWindow GetTopLevel(gfx::NativeView view) { return [view window]; } diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc index f1af709..e3cd5db 100644 --- a/chrome/common/platform_util_win.cc +++ b/chrome/common/platform_util_win.cc @@ -82,6 +82,10 @@ void ShowItemInFolder(const FilePath& full_path) { highlight, NULL); } +void OpenItem(const FilePath& full_path) { + win_util::OpenItemViaShell(full_path); +} + gfx::NativeWindow GetTopLevel(gfx::NativeView view) { return GetAncestor(view, GA_ROOT); } diff --git a/chrome/common/win_safe_util.cc b/chrome/common/win_safe_util.cc index 2187d30..8afe8c5 100644 --- a/chrome/common/win_safe_util.cc +++ b/chrome/common/win_safe_util.cc @@ -23,8 +23,7 @@ namespace win_util { // http://msdn2.microsoft.com/en-us/library/ms647048.aspx bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, const FilePath& full_path, - const std::wstring& source_url, - bool ask_for_app) { + const std::wstring& source_url) { ATL::CComPtr<IAttachmentExecute> attachment_services; HRESULT hr = attachment_services.CoCreateInstance(CLSID_AttachmentServices); if (FAILED(hr)) { @@ -34,7 +33,7 @@ bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, NOTREACHED(); return false; } - return OpenItemViaShell(full_path, ask_for_app); + return OpenItemViaShell(full_path); } // This GUID is associated with any 'don't ask me again' settings that the @@ -92,7 +91,7 @@ bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, return false; } } - return OpenItemViaShellNoZoneCheck(full_path, ask_for_app); + return OpenItemViaShellNoZoneCheck(full_path); } bool SetInternetZoneIdentifier(const FilePath& full_path) { diff --git a/chrome/common/win_safe_util.h b/chrome/common/win_safe_util.h index 9b8ac1b..8705d8a 100644 --- a/chrome/common/win_safe_util.h +++ b/chrome/common/win_safe_util.h @@ -34,11 +34,11 @@ namespace win_util { // // In the event that there is no default application registered for the file // specified by 'full_path' it ask the user, via the Windows "Open With" -// dialog, for an application to use if 'ask_for_app' is true. +// dialog. // Returns 'true' on successful open, 'false' otherwise. bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, const FilePath& full_path, - const std::wstring& source_url, bool ask_for_app); + const std::wstring& source_url); // Sets the Zone Identifier on the file to "Internet" (3). Returns true if the // function succeeds, false otherwise. A failure is expected on system where |