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 "webkit/fileapi/isolated_context.h" | 5 #include "webkit/fileapi/isolated_context.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 PathMap toplevels; | 29 PathMap toplevels; |
30 for (std::set<FilePath>::const_iterator iter = files.begin(); | 30 for (std::set<FilePath>::const_iterator iter = files.begin(); |
31 iter != files.end(); ++iter) { | 31 iter != files.end(); ++iter) { |
32 // If the given path contains any '..' or is not an absolute path, | 32 // If the given path contains any '..' or is not an absolute path, |
33 // return an empty (invalid) id. | 33 // return an empty (invalid) id. |
34 if (iter->ReferencesParent() || !iter->IsAbsolute()) | 34 if (iter->ReferencesParent() || !iter->IsAbsolute()) |
35 return std::string(); | 35 return std::string(); |
36 | 36 |
37 // Register the basename -> fullpath map. (We only expose the basename | 37 // Register the basename -> fullpath map. (We only expose the basename |
38 // part to the user scripts) | 38 // part to the user scripts) |
39 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 39 FilePath fullpath = iter->NormalizePathSeparators(); |
40 FilePath fullpath = iter->NormalizeWindowsPathSeparators(); | |
41 #else | |
42 FilePath fullpath = *iter; | |
43 #endif | |
44 FilePath basename = iter->BaseName(); | 40 FilePath basename = iter->BaseName(); |
45 // TODO(kinuko): Append a suffix or something if we have multiple pathnames | 41 // TODO(kinuko): Append a suffix or something if we have multiple pathnames |
46 // with the same basename. For now we only register the first one. | 42 // with the same basename. For now we only register the first one. |
47 toplevels.insert(std::make_pair(basename, fullpath)); | 43 toplevels.insert(std::make_pair(basename, fullpath)); |
48 } | 44 } |
49 toplevel_map_[filesystem_id] = toplevels; | 45 toplevel_map_[filesystem_id] = toplevels; |
50 return filesystem_id; | 46 return filesystem_id; |
51 } | 47 } |
52 | 48 |
53 // Revoke any registered drag context for the child_id. | 49 // Revoke any registered drag context for the child_id. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 uint32 random_data[4]; | 130 uint32 random_data[4]; |
135 std::string id; | 131 std::string id; |
136 do { | 132 do { |
137 base::RandBytes(random_data, sizeof(random_data)); | 133 base::RandBytes(random_data, sizeof(random_data)); |
138 id = base::HexEncode(random_data, sizeof(random_data)); | 134 id = base::HexEncode(random_data, sizeof(random_data)); |
139 } while (toplevel_map_.find(id) != toplevel_map_.end()); | 135 } while (toplevel_map_.find(id) != toplevel_map_.end()); |
140 return id; | 136 return id; |
141 } | 137 } |
142 | 138 |
143 } // namespace fileapi | 139 } // namespace fileapi |
OLD | NEW |