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/developer_private/developer_private_api.
h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
6 | 6 |
7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
8 #include "apps/app_restore_service.h" | 8 #include "apps/app_restore_service.h" |
9 #include "apps/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
10 #include "apps/shell_window.h" | 10 #include "apps/shell_window.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // extensions::ImageLoader. Also a resize should be performed to avoid | 118 // extensions::ImageLoader. Also a resize should be performed to avoid |
119 // potential huge URLs: crbug/297298. | 119 // potential huge URLs: crbug/297298. |
120 GURL ToDataURL(const base::FilePath& path, developer_private::ItemType type) { | 120 GURL ToDataURL(const base::FilePath& path, developer_private::ItemType type) { |
121 std::string contents; | 121 std::string contents; |
122 if (path.empty() || !base::ReadFileToString(path, &contents)) | 122 if (path.empty() || !base::ReadFileToString(path, &contents)) |
123 return GetDefaultImageURL(type); | 123 return GetDefaultImageURL(type); |
124 | 124 |
125 return GetImageURLFromData(contents); | 125 return GetImageURLFromData(contents); |
126 } | 126 } |
127 | 127 |
128 std::vector<base::FilePath> ListFolder(const base::FilePath path) { | |
129 base::FileEnumerator files(path, false, | |
130 base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); | |
131 std::vector<base::FilePath> paths; | |
132 | |
133 for (base::FilePath current_path = files.Next(); !current_path.empty(); | |
134 current_path = files.Next()) { | |
135 paths.push_back(current_path); | |
136 } | |
137 return paths; | |
138 } | |
139 | |
140 bool ValidateFolderName(const base::FilePath::StringType& name) { | 128 bool ValidateFolderName(const base::FilePath::StringType& name) { |
141 base::FilePath::StringType name_sanitized(name); | 129 base::FilePath::StringType name_sanitized(name); |
142 file_util::ReplaceIllegalCharactersInPath(&name_sanitized, '_'); | 130 file_util::ReplaceIllegalCharactersInPath(&name_sanitized, '_'); |
143 return name == name_sanitized; | 131 return name == name_sanitized; |
144 } | 132 } |
145 | 133 |
146 const Extension* GetExtensionByPath(const ExtensionSet* extensions, | 134 const Extension* GetExtensionByPath(const ExtensionSet* extensions, |
147 const base::FilePath& path) { | 135 const base::FilePath& path) { |
148 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); | 136 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); |
149 for (ExtensionSet::const_iterator iter = extensions->begin(); | 137 for (ExtensionSet::const_iterator iter = extensions->begin(); |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 return true; | 1341 return true; |
1354 } | 1342 } |
1355 | 1343 |
1356 DeveloperPrivateIsProfileManagedFunction:: | 1344 DeveloperPrivateIsProfileManagedFunction:: |
1357 ~DeveloperPrivateIsProfileManagedFunction() { | 1345 ~DeveloperPrivateIsProfileManagedFunction() { |
1358 } | 1346 } |
1359 | 1347 |
1360 } // namespace api | 1348 } // namespace api |
1361 | 1349 |
1362 } // namespace extensions | 1350 } // namespace extensions |
OLD | NEW |