Chromium Code Reviews| 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/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 12 #include "base/json/json_string_value_serializer.h" | 12 #include "base/json/json_string_value_serializer.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 | 20 |
| 21 using content::BrowserThread; | 21 using content::BrowserThread; |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 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 // Keep this delay greater or close to priority settings sync timeout (10 sec) | |
|
Nikita (slow)
2014/10/23 14:22:47
For the reference: kSyncTimeoutSeconds.
asargent_no_longer_on_chrome
2014/10/23 22:34:35
optional: Is it worth putting this constant name i
Dmitry Polukhin
2014/10/24 11:40:42
Removed this constant.
| |
| 29 // on Chrome OS login. | |
| 30 const int kMsDelayPrefLoad = 15 * 1000; | |
| 31 | |
| 28 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( | 32 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( |
| 29 const base::FilePath& external_extension_search_path) { | 33 const base::FilePath& external_extension_search_path) { |
| 30 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 34 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 31 | 35 |
| 32 std::set<base::FilePath> external_extension_paths; | 36 std::set<base::FilePath> external_extension_paths; |
| 33 | 37 |
| 34 if (!base::PathExists(external_extension_search_path)) { | 38 if (!base::PathExists(external_extension_search_path)) { |
| 35 // Does not have to exist. | 39 // Does not have to exist. |
| 36 return external_extension_paths; | 40 return external_extension_paths; |
| 37 } | 41 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 101 |
| 98 const base::FilePath ExternalPrefLoader::GetBaseCrxFilePath() { | 102 const base::FilePath ExternalPrefLoader::GetBaseCrxFilePath() { |
| 99 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 103 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 100 | 104 |
| 101 // |base_path_| was set in LoadOnFileThread(). | 105 // |base_path_| was set in LoadOnFileThread(). |
| 102 return base_path_; | 106 return base_path_; |
| 103 } | 107 } |
| 104 | 108 |
| 105 void ExternalPrefLoader::StartLoading() { | 109 void ExternalPrefLoader::StartLoading() { |
| 106 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 110 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 107 BrowserThread::PostTask( | 111 if (options_ & DELAY_LOAD) { |
| 108 BrowserThread::FILE, FROM_HERE, | 112 BrowserThread::PostDelayedTask( |
| 109 base::Bind(&ExternalPrefLoader::LoadOnFileThread, this)); | 113 BrowserThread::FILE, FROM_HERE, |
| 114 base::Bind(&ExternalPrefLoader::LoadOnFileThread, this), | |
| 115 base::TimeDelta::FromMillisecondsD(kMsDelayPrefLoad)); | |
| 116 } else { | |
| 117 BrowserThread::PostTask( | |
| 118 BrowserThread::FILE, FROM_HERE, | |
| 119 base::Bind(&ExternalPrefLoader::LoadOnFileThread, this)); | |
| 120 } | |
| 110 } | 121 } |
| 111 | 122 |
| 112 void ExternalPrefLoader::LoadOnFileThread() { | 123 void ExternalPrefLoader::LoadOnFileThread() { |
| 113 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 124 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 114 | 125 |
| 115 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); | 126 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); |
| 116 | 127 |
| 117 // TODO(skerner): Some values of base_path_id_ will cause | 128 // TODO(skerner): Some values of base_path_id_ will cause |
| 118 // PathService::Get() to return false, because the path does | 129 // PathService::Get() to return false, because the path does |
| 119 // not exist. Find and fix the build/install scripts so that | 130 // not exist. Find and fix the build/install scripts so that |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 LoadFinished(); | 256 LoadFinished(); |
| 246 } | 257 } |
| 247 | 258 |
| 248 ExternalTestingLoader::~ExternalTestingLoader() {} | 259 ExternalTestingLoader::~ExternalTestingLoader() {} |
| 249 | 260 |
| 250 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { | 261 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { |
| 251 return fake_base_path_; | 262 return fake_base_path_; |
| 252 } | 263 } |
| 253 | 264 |
| 254 } // namespace extensions | 265 } // namespace extensions |
| OLD | NEW |