From 1a695bc286bb24e8c7ba213cae5923c8558b2f1b Mon Sep 17 00:00:00 2001 From: "siggi@chromium.org" Date: Fri, 25 May 2012 20:11:12 +0000 Subject: [PATCH] Delegate Metro save file operations to metro_driver. R=sky@chromium.org,robertshield@chromium.org BUG=125674 TEST=None Review URL: https://chromiumcodereview.appspot.com/10440052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139105 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/ui/views/select_file_dialog_win.cc | 30 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/chrome/browser/ui/views/select_file_dialog_win.cc b/chrome/browser/ui/views/select_file_dialog_win.cc index 7b51bb98eded..822e3050f1c2 100644 --- a/chrome/browser/ui/views/select_file_dialog_win.cc +++ b/chrome/browser/ui/views/select_file_dialog_win.cc @@ -39,6 +39,7 @@ std::wstring GetExtensionWithoutLeadingDot(const std::wstring& extension) { return extension.empty() ? extension : extension.substr(1); } +// Diverts to a metro-specific implementation as appropriate. bool CallGetOpenFileName(OPENFILENAME* ofn) { HMODULE metro_module = base::win::GetMetroModule(); if (metro_module != NULL) { @@ -46,10 +47,33 @@ bool CallGetOpenFileName(OPENFILENAME* ofn) { MetroGetOpenFileName metro_get_open_file_name = reinterpret_cast( ::GetProcAddress(metro_module, "MetroGetOpenFileName")); + if (metro_get_open_file_name == NULL) { + NOTREACHED(); + return false; + } + + return metro_get_open_file_name(ofn) == TRUE; + } else { + return GetOpenFileName(ofn) == TRUE; + } +} + +// Diverts to a metro-specific implementation as appropriate. +bool CallGetSaveFileName(OPENFILENAME* ofn) { + HMODULE metro_module = base::win::GetMetroModule(); + if (metro_module != NULL) { + typedef BOOL (*MetroGetSaveFileName)(OPENFILENAME*); + MetroGetSaveFileName metro_get_save_file_name = + reinterpret_cast( + ::GetProcAddress(metro_module, "MetroGetSaveFileName")); + if (metro_get_save_file_name == NULL) { + NOTREACHED(); + return false; + } - return !!metro_get_open_file_name(ofn); + return metro_get_save_file_name(ofn) == TRUE; } else { - return !!GetOpenFileName(ofn); + return GetSaveFileName(ofn) == TRUE; } } @@ -329,7 +353,7 @@ bool SaveFileAsWithFilter(HWND owner, save_as.pvReserved = NULL; save_as.dwReserved = 0; - if (!GetSaveFileName(&save_as)) { + if (!CallGetSaveFileName(&save_as)) { // Zero means the dialog was closed, otherwise we had an error. DWORD error_code = CommDlgExtendedError(); if (error_code != 0) { -- 2.11.4.GIT