OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "apps/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 std::string display = GetDisplayBaseName(actual_path); | 121 std::string display = GetDisplayBaseName(actual_path); |
122 display_path = display_path.Append(display); | 122 display_path = display_path.Append(display); |
123 } | 123 } |
124 DCHECK_EQ(actual_path.value(), source_path.value()); | 124 DCHECK_EQ(actual_path.value(), source_path.value()); |
125 return display_path; | 125 return display_path; |
126 } | 126 } |
127 #else // defined(OS_MACOSX) | 127 #else // defined(OS_MACOSX) |
128 // Prettifies |source_path|, by replacing the user's home directory with "~" | 128 // Prettifies |source_path|, by replacing the user's home directory with "~" |
129 // (if applicable). | 129 // (if applicable). |
130 base::FilePath PrettifyPath(const base::FilePath& source_path) { | 130 base::FilePath PrettifyPath(const base::FilePath& source_path) { |
131 #if defined(OS_WIN) || defined(OS_POSIX) | |
132 #if defined(OS_WIN) | |
133 int home_key = base::DIR_PROFILE; | |
134 #elif defined(OS_POSIX) | |
135 int home_key = base::DIR_HOME; | |
136 #endif | |
137 base::FilePath home_path; | 131 base::FilePath home_path; |
138 base::FilePath display_path = base::FilePath::FromUTF8Unsafe("~"); | 132 base::FilePath display_path = base::FilePath::FromUTF8Unsafe("~"); |
139 if (PathService::Get(home_key, &home_path) | 133 if (PathService::Get(base::DIR_HOME, &home_path) |
140 && home_path.AppendRelativePath(source_path, &display_path)) | 134 && home_path.AppendRelativePath(source_path, &display_path)) |
141 return display_path; | 135 return display_path; |
142 #endif | |
143 return source_path; | 136 return source_path; |
144 } | 137 } |
145 #endif // defined(OS_MACOSX) | 138 #endif // defined(OS_MACOSX) |
146 | 139 |
147 bool g_skip_picker_for_test = false; | 140 bool g_skip_picker_for_test = false; |
148 bool g_use_suggested_path_for_test = false; | 141 bool g_use_suggested_path_for_test = false; |
149 base::FilePath* g_path_to_be_picked_for_test; | 142 base::FilePath* g_path_to_be_picked_for_test; |
150 std::vector<base::FilePath>* g_paths_to_be_picked_for_test; | 143 std::vector<base::FilePath>* g_paths_to_be_picked_for_test; |
151 bool g_skip_directory_confirmation_for_test = false; | 144 bool g_skip_directory_confirmation_for_test = false; |
152 bool g_allow_directory_access_for_test = false; | 145 bool g_allow_directory_access_for_test = false; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 *description = l10n_util::GetStringUTF16(description_id); | 205 *description = l10n_util::GetStringUTF16(description_id); |
213 | 206 |
214 return true; | 207 return true; |
215 } | 208 } |
216 | 209 |
217 // Key for the path of the directory of the file last chosen by the user in | 210 // Key for the path of the directory of the file last chosen by the user in |
218 // response to a chrome.fileSystem.chooseEntry() call. | 211 // response to a chrome.fileSystem.chooseEntry() call. |
219 const char kLastChooseEntryDirectory[] = "last_choose_file_directory"; | 212 const char kLastChooseEntryDirectory[] = "last_choose_file_directory"; |
220 | 213 |
221 const int kGraylistedPaths[] = { | 214 const int kGraylistedPaths[] = { |
| 215 base::DIR_HOME, |
222 #if defined(OS_WIN) | 216 #if defined(OS_WIN) |
223 base::DIR_PROFILE, | |
224 base::DIR_PROGRAM_FILES, | 217 base::DIR_PROGRAM_FILES, |
225 base::DIR_PROGRAM_FILESX86, | 218 base::DIR_PROGRAM_FILESX86, |
226 base::DIR_WINDOWS, | 219 base::DIR_WINDOWS, |
227 #elif defined(OS_POSIX) | |
228 base::DIR_HOME, | |
229 #endif | 220 #endif |
230 }; | 221 }; |
231 | 222 |
232 } // namespace | 223 } // namespace |
233 | 224 |
234 namespace extensions { | 225 namespace extensions { |
235 | 226 |
236 namespace file_system_api { | 227 namespace file_system_api { |
237 | 228 |
238 base::FilePath GetLastChooseEntryDirectory(const ExtensionPrefs* prefs, | 229 base::FilePath GetLastChooseEntryDirectory(const ExtensionPrefs* prefs, |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 if (needs_new_entry) { | 967 if (needs_new_entry) { |
977 is_directory_ = file_entry->is_directory; | 968 is_directory_ = file_entry->is_directory; |
978 CreateResponse(); | 969 CreateResponse(); |
979 AddEntryToResponse(file_entry->path, file_entry->id); | 970 AddEntryToResponse(file_entry->path, file_entry->id); |
980 } | 971 } |
981 SendResponse(true); | 972 SendResponse(true); |
982 return true; | 973 return true; |
983 } | 974 } |
984 | 975 |
985 } // namespace extensions | 976 } // namespace extensions |
OLD | NEW |