| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/shell_dialogs.h" | 5 #include "chrome/browser/shell_dialogs.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <commdlg.h> | 8 #include <commdlg.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <set> | 12 #include <set> |
| 13 | 13 |
| 14 #include "app/l10n_util.h" | 14 #include "app/l10n_util.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/registry.h" | 17 #include "base/registry.h" |
| 18 #include "base/scoped_comptr_win.h" | 18 #include "base/scoped_comptr_win.h" |
| 19 #include "base/string_split.h" | 19 #include "base/string_split.h" |
| 20 #include "base/thread.h" | 20 #include "base/thread.h" |
| 21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "base/win_util.h" | 22 #include "base/win/windows_version.h" |
| 23 #include "chrome/browser/browser_thread.h" | 23 #include "chrome/browser/browser_thread.h" |
| 24 #include "gfx/font.h" | 24 #include "gfx/font.h" |
| 25 #include "grit/app_strings.h" | 25 #include "grit/app_strings.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 | 27 |
| 28 // This function takes the output of a SaveAs dialog: a filename, a filter and | 28 // This function takes the output of a SaveAs dialog: a filename, a filter and |
| 29 // the extension originally suggested to the user (shown in the dialog box) and | 29 // the extension originally suggested to the user (shown in the dialog box) and |
| 30 // returns back the filename with the appropriate extension tacked on. If the | 30 // returns back the filename with the appropriate extension tacked on. If the |
| 31 // user requests an unknown extension and is not using the 'All files' filter, | 31 // user requests an unknown extension and is not using the 'All files' filter, |
| 32 // the suggested extension will be appended, otherwise we will leave the | 32 // the suggested extension will be appended, otherwise we will leave the |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 270 |
| 271 // Set up the initial directory for the dialog. | 271 // Set up the initial directory for the dialog. |
| 272 std::wstring directory = file_util::GetDirectoryFromPath(suggested_name); | 272 std::wstring directory = file_util::GetDirectoryFromPath(suggested_name); |
| 273 save_as.lpstrInitialDir = directory.c_str(); | 273 save_as.lpstrInitialDir = directory.c_str(); |
| 274 save_as.lpstrTitle = NULL; | 274 save_as.lpstrTitle = NULL; |
| 275 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | | 275 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | |
| 276 OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; | 276 OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; |
| 277 save_as.lpstrDefExt = &def_ext[0]; | 277 save_as.lpstrDefExt = &def_ext[0]; |
| 278 save_as.lCustData = NULL; | 278 save_as.lCustData = NULL; |
| 279 | 279 |
| 280 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { | 280 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
| 281 // The save as on Windows XP remembers its last position, | 281 // The save as on Windows XP remembers its last position, |
| 282 // and if the screen resolution changed, it will be off screen. | 282 // and if the screen resolution changed, it will be off screen. |
| 283 save_as.Flags |= OFN_ENABLEHOOK; | 283 save_as.Flags |= OFN_ENABLEHOOK; |
| 284 save_as.lpfnHook = &SaveAsDialogHook; | 284 save_as.lpfnHook = &SaveAsDialogHook; |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Must be NULL or 0. | 287 // Must be NULL or 0. |
| 288 save_as.pvReserved = NULL; | 288 save_as.pvReserved = NULL; |
| 289 save_as.dwReserved = 0; | 289 save_as.dwReserved = 0; |
| 290 | 290 |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { | 1120 void SelectFontDialogImpl::FontNotSelected(void* params, RunState run_state) { |
| 1121 if (listener_) | 1121 if (listener_) |
| 1122 listener_->FontSelectionCanceled(params); | 1122 listener_->FontSelectionCanceled(params); |
| 1123 EndRun(run_state); | 1123 EndRun(run_state); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 // static | 1126 // static |
| 1127 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { | 1127 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { |
| 1128 return new SelectFontDialogImpl(listener); | 1128 return new SelectFontDialogImpl(listener); |
| 1129 } | 1129 } |
| OLD | NEW |