| 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_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 base::FilePath::CharType kExternalExtensionJson[] = | 25 base::FilePath::CharType kExternalExtensionJson[] = |
| 26 FILE_PATH_LITERAL("external_extensions.json"); | 26 FILE_PATH_LITERAL("external_extensions.json"); |
| 27 | 27 |
| 28 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( | 28 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( |
| 29 const base::FilePath& external_extension_search_path) { | 29 const base::FilePath& external_extension_search_path) { |
| 30 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 30 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 31 | 31 |
| 32 std::set<base::FilePath> external_extension_paths; | 32 std::set<base::FilePath> external_extension_paths; |
| 33 | 33 |
| 34 if (!file_util::PathExists(external_extension_search_path)) { | 34 if (!base::PathExists(external_extension_search_path)) { |
| 35 // Does not have to exist. | 35 // Does not have to exist. |
| 36 return external_extension_paths; | 36 return external_extension_paths; |
| 37 } | 37 } |
| 38 | 38 |
| 39 base::FileEnumerator json_files( | 39 base::FileEnumerator json_files( |
| 40 external_extension_search_path, | 40 external_extension_search_path, |
| 41 false, // Recursive. | 41 false, // Recursive. |
| 42 base::FileEnumerator::FILES); | 42 base::FileEnumerator::FILES); |
| 43 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
| 44 base::FilePath::StringType extension = UTF8ToWide(std::string(".json")); | 44 base::FilePath::StringType extension = UTF8ToWide(std::string(".json")); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 BrowserThread::UI, FROM_HERE, | 149 BrowserThread::UI, FROM_HERE, |
| 150 base::Bind(&ExternalPrefLoader::LoadFinished, this)); | 150 base::Bind(&ExternalPrefLoader::LoadFinished, this)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void ExternalPrefLoader::ReadExternalExtensionPrefFile(DictionaryValue* prefs) { | 153 void ExternalPrefLoader::ReadExternalExtensionPrefFile(DictionaryValue* prefs) { |
| 154 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 154 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 155 CHECK(NULL != prefs); | 155 CHECK(NULL != prefs); |
| 156 | 156 |
| 157 base::FilePath json_file = base_path_.Append(kExternalExtensionJson); | 157 base::FilePath json_file = base_path_.Append(kExternalExtensionJson); |
| 158 | 158 |
| 159 if (!file_util::PathExists(json_file)) { | 159 if (!base::PathExists(json_file)) { |
| 160 // This is not an error. The file does not exist by default. | 160 // This is not an error. The file does not exist by default. |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 | 163 |
| 164 if (IsOptionSet(ENSURE_PATH_CONTROLLED_BY_ADMIN)) { | 164 if (IsOptionSet(ENSURE_PATH_CONTROLLED_BY_ADMIN)) { |
| 165 #if defined(OS_MACOSX) | 165 #if defined(OS_MACOSX) |
| 166 if (!file_util::VerifyPathControlledByAdmin(json_file)) { | 166 if (!file_util::VerifyPathControlledByAdmin(json_file)) { |
| 167 LOG(ERROR) << "Can not read external extensions source. The file " | 167 LOG(ERROR) << "Can not read external extensions source. The file " |
| 168 << json_file.value() << " and every directory in its path, " | 168 << json_file.value() << " and every directory in its path, " |
| 169 << "must be owned by root, have group \"admin\", and not be " | 169 << "must be owned by root, have group \"admin\", and not be " |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 LoadFinished(); | 244 LoadFinished(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 ExternalTestingLoader::~ExternalTestingLoader() {} | 247 ExternalTestingLoader::~ExternalTestingLoader() {} |
| 248 | 248 |
| 249 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { | 249 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { |
| 250 return fake_base_path_; | 250 return fake_base_path_; |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // extensions | 253 } // extensions |
| OLD | NEW |