| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 bool SelectFileDialogImpl::RunOpenFileDialog(const std::wstring& title, | 333 bool SelectFileDialogImpl::RunOpenFileDialog(const std::wstring& title, |
| 334 HWND owner, | 334 HWND owner, |
| 335 std::wstring* path) { | 335 std::wstring* path) { |
| 336 OPENFILENAME ofn; | 336 OPENFILENAME ofn; |
| 337 // We must do this otherwise the ofn's FlagsEx may be initialized to random | 337 // We must do this otherwise the ofn's FlagsEx may be initialized to random |
| 338 // junk in release builds which can cause the Places Bar not to show up! | 338 // junk in release builds which can cause the Places Bar not to show up! |
| 339 ZeroMemory(&ofn, sizeof(ofn)); | 339 ZeroMemory(&ofn, sizeof(ofn)); |
| 340 ofn.lStructSize = sizeof(ofn); | 340 ofn.lStructSize = sizeof(ofn); |
| 341 ofn.hwndOwner = owner; | 341 ofn.hwndOwner = owner; |
| 342 | 342 |
| 343 // This will clamp the number of characters copied from the supplied path |
| 344 // to the value of MAX_PATH. |
| 345 size_t name_size = std::min(path->length() + 1, |
| 346 static_cast<size_t>(MAX_PATH)); |
| 343 wchar_t filename[MAX_PATH]; | 347 wchar_t filename[MAX_PATH]; |
| 344 memcpy(filename, path->c_str(), (path->length()+1) * sizeof(wchar_t)); | 348 memcpy(filename, path->c_str(), name_size * sizeof(wchar_t)); |
| 349 filename[MAX_PATH - 1] = '\0'; |
| 345 | 350 |
| 346 ofn.lpstrFile = filename; | 351 ofn.lpstrFile = filename; |
| 347 ofn.nMaxFile = MAX_PATH; | 352 ofn.nMaxFile = MAX_PATH; |
| 348 ofn.Flags = OFN_FILEMUSTEXIST; | 353 ofn.Flags = OFN_FILEMUSTEXIST; |
| 349 | 354 |
| 350 // TODO(beng): (http://b/issue?id=1126563) edit the filter options in the | 355 // TODO(beng): (http://b/issue?id=1126563) edit the filter options in the |
| 351 // dropdown list. | 356 // dropdown list. |
| 352 bool success = !!GetOpenFileName(&ofn); | 357 bool success = !!GetOpenFileName(&ofn); |
| 353 DisableOwner(owner); | 358 DisableOwner(owner); |
| 354 if (success) | 359 if (success) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 if (listener_) | 523 if (listener_) |
| 519 listener_->FontSelectionCanceled(params); | 524 listener_->FontSelectionCanceled(params); |
| 520 EndRun(run_state); | 525 EndRun(run_state); |
| 521 } | 526 } |
| 522 | 527 |
| 523 // static | 528 // static |
| 524 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { | 529 SelectFontDialog* SelectFontDialog::Create(Listener* listener) { |
| 525 return new SelectFontDialogImpl(listener); | 530 return new SelectFontDialogImpl(listener); |
| 526 } | 531 } |
| 527 | 532 |
| OLD | NEW |