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/download/save_package.h" | 5 #include "chrome/browser/download/save_package.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 // Create filter string. | 954 // Create filter string. |
955 std::wstring filter = l10n_util::GetString(IDS_SAVE_PAGE_FILTER); | 955 std::wstring filter = l10n_util::GetString(IDS_SAVE_PAGE_FILTER); |
956 filter.resize(filter.size() + 2); | 956 filter.resize(filter.size() + 2); |
957 filter[filter.size() - 1] = L'\0'; | 957 filter[filter.size() - 1] = L'\0'; |
958 filter[filter.size() - 2] = L'\0'; | 958 filter[filter.size() - 2] = L'\0'; |
959 | 959 |
960 if (g_should_prompt_for_filename) { | 960 if (g_should_prompt_for_filename) { |
961 // Since we take the suggested name from the web page's title, we want to | 961 // Since we take the suggested name from the web page's title, we want to |
962 // ignore the file extension generated by SaveFileAsWithFilter, since it | 962 // ignore the file extension generated by SaveFileAsWithFilter, since it |
963 // will always be ".htm". | 963 // will always be ".htm". |
964 // TODO(estade): is this saved_main_file_path assignment behavior desired? | |
965 // It was copied from previous code but seems strange. | |
966 std::wstring main_file_path; | 964 std::wstring main_file_path; |
967 if (!win_util::SaveFileAsWithFilter(container_hwnd, | 965 bool success = win_util::SaveFileAsWithFilter(container_hwnd, |
968 suggest_name.value(), | 966 suggest_name.value(), filter, L"htm", true, &index, &main_file_path); |
969 filter, | 967 param->saved_main_file_path = FilePath(main_file_path); |
970 L"htm", | 968 if (!success) |
971 true, | |
972 &index, | |
973 &main_file_path)) { | |
974 param->saved_main_file_path = FilePath(main_file_path); | |
975 return false; | 969 return false; |
976 } | |
977 } else { | 970 } else { |
978 param->saved_main_file_path = suggest_name; | 971 param->saved_main_file_path = suggest_name; |
979 } | 972 } |
980 } else { | 973 } else { |
981 if (g_should_prompt_for_filename) { | 974 if (g_should_prompt_for_filename) { |
982 // TODO(estade): see above comment. | 975 // TODO(estade): see above comment. |
983 std::wstring main_file_path; | 976 std::wstring main_file_path; |
984 if (!win_util::SaveFileAs(container_hwnd, suggest_name.value(), | 977 if (!win_util::SaveFileAs(container_hwnd, suggest_name.value(), |
985 &main_file_path)) | 978 &main_file_path)) |
986 param->saved_main_file_path = FilePath(main_file_path); | 979 param->saved_main_file_path = FilePath(main_file_path); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 *pure_file_name = | 1059 *pure_file_name = |
1067 pure_file_name->substr(0, available_length); | 1060 pure_file_name->substr(0, available_length); |
1068 return true; | 1061 return true; |
1069 } | 1062 } |
1070 | 1063 |
1071 // Not enough room to even use a shortened |pure_file_name|. | 1064 // Not enough room to even use a shortened |pure_file_name|. |
1072 pure_file_name->clear(); | 1065 pure_file_name->clear(); |
1073 return false; | 1066 return false; |
1074 } | 1067 } |
1075 | 1068 |
OLD | NEW |