| 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" | |
| 10 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 11 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| 12 #include "base/json/json_string_value_serializer.h" | 11 #include "base/json/json_string_value_serializer.h" |
| 13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 15 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 16 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 17 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 18 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 | 19 |
| 21 using content::BrowserThread; | 20 using content::BrowserThread; |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 base::FilePath::CharType kExternalExtensionJson[] = | 24 base::FilePath::CharType kExternalExtensionJson[] = |
| 26 FILE_PATH_LITERAL("external_extensions.json"); | 25 FILE_PATH_LITERAL("external_extensions.json"); |
| 27 | 26 |
| 28 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( | 27 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( |
| 29 const base::FilePath& external_extension_search_path) { | 28 const base::FilePath& external_extension_search_path) { |
| 30 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 29 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 31 | 30 |
| 32 std::set<base::FilePath> external_extension_paths; | 31 std::set<base::FilePath> external_extension_paths; |
| 33 | 32 |
| 34 if (!file_util::PathExists(external_extension_search_path)) { | 33 if (!file_util::PathExists(external_extension_search_path)) { |
| 35 // Does not have to exist. | 34 // Does not have to exist. |
| 36 return external_extension_paths; | 35 return external_extension_paths; |
| 37 } | 36 } |
| 38 | 37 |
| 39 base::FileEnumerator json_files( | 38 file_util::FileEnumerator json_files( |
| 40 external_extension_search_path, | 39 external_extension_search_path, |
| 41 false, // Recursive. | 40 false, // Recursive. |
| 42 base::FileEnumerator::FILES); | 41 file_util::FileEnumerator::FILES); |
| 43 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 44 base::FilePath::StringType extension = UTF8ToWide(std::string(".json")); | 43 base::FilePath::StringType extension = UTF8ToWide(std::string(".json")); |
| 45 #elif defined(OS_POSIX) | 44 #elif defined(OS_POSIX) |
| 46 base::FilePath::StringType extension(".json"); | 45 base::FilePath::StringType extension(".json"); |
| 47 #endif | 46 #endif |
| 48 do { | 47 do { |
| 49 base::FilePath file = json_files.Next(); | 48 base::FilePath file = json_files.Next(); |
| 50 if (file.BaseName().value() == kExternalExtensionJson) | 49 if (file.BaseName().value() == kExternalExtensionJson) |
| 51 continue; // Already taken care of elsewhere. | 50 continue; // Already taken care of elsewhere. |
| 52 if (file.empty()) | 51 if (file.empty()) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 LoadFinished(); | 245 LoadFinished(); |
| 247 } | 246 } |
| 248 | 247 |
| 249 ExternalTestingLoader::~ExternalTestingLoader() {} | 248 ExternalTestingLoader::~ExternalTestingLoader() {} |
| 250 | 249 |
| 251 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { | 250 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { |
| 252 return fake_base_path_; | 251 return fake_base_path_; |
| 253 } | 252 } |
| 254 | 253 |
| 255 } // extensions | 254 } // extensions |
| OLD | NEW |