diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/download/download_manager.cc | 8 | ||||
-rw-r--r-- | chrome/browser/download/save_package.cc | 20 | ||||
-rw-r--r-- | chrome/common/platform_util.h | 5 | ||||
-rw-r--r-- | chrome/common/platform_util_linux.cc | 6 | ||||
-rw-r--r-- | chrome/common/platform_util_mac.mm | 5 | ||||
-rw-r--r-- | chrome/common/platform_util_win.cc | 5 |
6 files changed, 37 insertions, 12 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index f58307c..f7f7864 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -28,6 +28,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/l10n_util.h" #include "chrome/common/notification_service.h" +#include "chrome/common/platform_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/stl_util-inl.h" @@ -636,14 +637,11 @@ void DownloadManager::OnPathExistenceAvailable(DownloadCreateInfo* info) { #if defined(OS_WIN) std::wstring filter = win_util::GetFileFilterFromPath(info->suggested_path.value()); - gfx::NativeWindow owning_window = - contents ? GetAncestor(contents->GetNativeView(), GA_ROOT) : NULL; #elif defined(OS_LINUX) std::wstring filter; - gfx::NativeWindow owning_window = contents ? - GTK_WINDOW(gtk_widget_get_toplevel(contents->GetNativeView())) : - NULL; #endif + gfx::NativeWindow owning_window = + contents ? platform_util::GetTopLevel(contents->GetNativeView()) : NULL; select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, std::wstring(), info->suggested_path.ToWStringHack(), diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index c5cdf1d..3f878a6 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -26,6 +26,7 @@ #include "chrome/browser/tab_contents/web_contents.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/platform_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/stl_util-inl.h" @@ -985,7 +986,6 @@ FilePath SavePackage::GetSuggestNameForSaveAs(PrefService* prefs, } void SavePackage::GetSaveInfo() { -#if defined(OS_WIN) // Use "Web Page, Complete" option as default choice of saving page. int filter_index = 2; std::wstring filter; @@ -1008,10 +1008,17 @@ void SavePackage::GetSaveInfo() { filter[filter.size() - 2] = L'\0'; default_extension = L"htm"; } else { +#if defined(OS_WIN) filter = win_util::GetFileFilterFromPath(suggested_name); +#else + // TODO(port): implement this. + NOTIMPLEMENTED(); +#endif filter_index = 1; } + +#if defined(OS_LINUX) || defined(OS_WIN) if (g_should_prompt_for_filename) { if (!select_file_dialog_.get()) select_file_dialog_ = SelectFileDialog::Create(this); @@ -1021,17 +1028,16 @@ void SavePackage::GetSaveInfo() { filter, filter_index, default_extension, - GetAncestor(web_contents_->GetNativeView(), - GA_ROOT), + platform_util::GetTopLevel( + web_contents_->GetNativeView()), save_params); - } else { + } else +#endif // defined(OS_LINUX) || defined(OS_WIN) + { // Just use 'suggested_name' instead of opening the dialog prompt. ContinueSave(save_params, suggested_name, filter_index); delete save_params; } -#else - NOTIMPLEMENTED(); -#endif // OS_WIN } // Called after the save file dialog box returns. diff --git a/chrome/common/platform_util.h b/chrome/common/platform_util.h index 27ef5c4..3886f17 100644 --- a/chrome/common/platform_util.h +++ b/chrome/common/platform_util.h @@ -5,6 +5,8 @@ #ifndef CHROME_COMMON_PLATFORM_UTIL_H_ #define CHROME_COMMON_PLATFORM_UTIL_H_ +#include "base/gfx/native_widget_types.h" + class FilePath; namespace platform_util { @@ -12,6 +14,9 @@ namespace platform_util { // Show the given file in a file manager. If possible, select the file. void ShowItemInFolder(const FilePath& full_path); +// Get the top level window for the native view. This can return NULL. +gfx::NativeWindow GetTopLevel(gfx::NativeView view); + } #endif // CHROME_COMMON_PLATFORM_UTIL_H_ diff --git a/chrome/common/platform_util_linux.cc b/chrome/common/platform_util_linux.cc index de06f04..3c0f5f6 100644 --- a/chrome/common/platform_util_linux.cc +++ b/chrome/common/platform_util_linux.cc @@ -4,6 +4,8 @@ #include "chrome/common/platform_util.h" +#include <gtk/gtk.h> + #include "base/file_path.h" #include "base/file_util.h" #include "base/process_util.h" @@ -25,4 +27,8 @@ void ShowItemInFolder(const FilePath& full_path) { base::LaunchApp(argv, no_files, false, NULL); } +gfx::NativeWindow GetTopLevel(gfx::NativeView view) { + return GTK_WINDOW(gtk_widget_get_toplevel(view)); +} + } // namespace platform_util diff --git a/chrome/common/platform_util_mac.mm b/chrome/common/platform_util_mac.mm index ea8474d..3ee3a2f 100644 --- a/chrome/common/platform_util_mac.mm +++ b/chrome/common/platform_util_mac.mm @@ -13,4 +13,9 @@ void ShowItemInFolder(const FilePath& full_path) { NOTIMPLEMENTED(); } +gfx::NativeWindow GetTopLevel(gfx::NativeView view) { + NOTIMPLEMENTED(); + return NULL; +} + } // namespace platform_util diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc index 217d832..16ea8c0 100644 --- a/chrome/common/platform_util_win.cc +++ b/chrome/common/platform_util_win.cc @@ -13,6 +13,7 @@ #include "base/file_path.h" #include "base/file_util.h" +#include "base/gfx/native_widget_types.h" #include "base/logging.h" #include "chrome/common/win_util.h" @@ -80,4 +81,8 @@ void ShowItemInFolder(const FilePath& full_path) { highlight, NULL); } +gfx::NativeWindow GetTopLevel(gfx::NativeView view) { + return GetAncestor(view, GA_ROOT); +} + } // namespace platform_util |