| 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/external_pref_loader.h" | 5 #include "chrome/browser/extensions/external_pref_loader.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 if (!file_util::PathExists(external_extension_search_path)) { | 33 if (!file_util::PathExists(external_extension_search_path)) { |
| 34 // Does not have to exist. | 34 // Does not have to exist. |
| 35 return external_extension_paths; | 35 return external_extension_paths; |
| 36 } | 36 } |
| 37 | 37 |
| 38 file_util::FileEnumerator json_files( | 38 file_util::FileEnumerator json_files( |
| 39 external_extension_search_path, | 39 external_extension_search_path, |
| 40 false, // Recursive. | 40 false, // Recursive. |
| 41 file_util::FileEnumerator::FILES); | 41 file_util::FileEnumerator::FILES); |
| 42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 43 base::FilePath::StringType extension = UTF8ToWide(std::string(".json")); | 43 base::FilePath::StringType extension = base::UTF8ToWide(std::string(".json")); |
| 44 #elif defined(OS_POSIX) | 44 #elif defined(OS_POSIX) |
| 45 base::FilePath::StringType extension(".json"); | 45 base::FilePath::StringType extension(".json"); |
| 46 #endif | 46 #endif |
| 47 do { | 47 do { |
| 48 base::FilePath file = json_files.Next(); | 48 base::FilePath file = json_files.Next(); |
| 49 if (file.BaseName().value() == kExternalExtensionJson) | 49 if (file.BaseName().value() == kExternalExtensionJson) |
| 50 continue; // Already taken care of elsewhere. | 50 continue; // Already taken care of elsewhere. |
| 51 if (file.empty()) | 51 if (file.empty()) |
| 52 break; | 52 break; |
| 53 if (file.MatchesExtension(extension)) { | 53 if (file.MatchesExtension(extension)) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 // For each file read the json description & build the proper | 204 // For each file read the json description & build the proper |
| 205 // associated prefs. | 205 // associated prefs. |
| 206 for (std::set<base::FilePath>::const_iterator it = candidates.begin(); | 206 for (std::set<base::FilePath>::const_iterator it = candidates.begin(); |
| 207 it != candidates.end(); | 207 it != candidates.end(); |
| 208 ++it) { | 208 ++it) { |
| 209 base::FilePath extension_candidate_path = base_path_.Append(*it); | 209 base::FilePath extension_candidate_path = base_path_.Append(*it); |
| 210 | 210 |
| 211 std::string id = | 211 std::string id = |
| 212 #if defined(OS_WIN) | 212 #if defined(OS_WIN) |
| 213 WideToASCII( | 213 base::WideToASCII( |
| 214 extension_candidate_path.RemoveExtension().BaseName().value()); | 214 extension_candidate_path.RemoveExtension().BaseName().value()); |
| 215 #elif defined(OS_POSIX) | 215 #elif defined(OS_POSIX) |
| 216 extension_candidate_path.RemoveExtension().BaseName().value().c_str(); | 216 extension_candidate_path.RemoveExtension().BaseName().value().c_str(); |
| 217 #endif | 217 #endif |
| 218 | 218 |
| 219 DVLOG(1) << "Reading json file: " | 219 DVLOG(1) << "Reading json file: " |
| 220 << extension_candidate_path.LossyDisplayName().c_str(); | 220 << extension_candidate_path.LossyDisplayName().c_str(); |
| 221 | 221 |
| 222 JSONFileValueSerializer serializer(extension_candidate_path); | 222 JSONFileValueSerializer serializer(extension_candidate_path); |
| 223 scoped_ptr<DictionaryValue> ext_prefs( | 223 scoped_ptr<DictionaryValue> ext_prefs( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 245 LoadFinished(); | 245 LoadFinished(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 ExternalTestingLoader::~ExternalTestingLoader() {} | 248 ExternalTestingLoader::~ExternalTestingLoader() {} |
| 249 | 249 |
| 250 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { | 250 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { |
| 251 return fake_base_path_; | 251 return fake_base_path_; |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // extensions | 254 } // extensions |
| OLD | NEW |