Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1308)

Unified Diff: chrome/browser/extensions/external_pref_extension_loader.cc

Issue 6293006: Allow relative paths to external extension files for some providers, error out for others. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Rebase for commit. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/external_pref_extension_loader.cc
diff --git a/chrome/browser/extensions/external_pref_extension_loader.cc b/chrome/browser/extensions/external_pref_extension_loader.cc
index 791005ca246f6aabcfe03a6d794681560bd21f0f..fc84b1ebf6df8b9023c67fba18696c0fd0069688 100644
--- a/chrome/browser/extensions/external_pref_extension_loader.cc
+++ b/chrome/browser/extensions/external_pref_extension_loader.cc
@@ -32,10 +32,22 @@ DictionaryValue* ExtractPrefs(ValueSerializer* serializer) {
} // namespace
-ExternalPrefExtensionLoader::ExternalPrefExtensionLoader() {
+ExternalPrefExtensionLoader::ExternalPrefExtensionLoader(int base_path_key)
+ : base_path_key_(base_path_key) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
+const FilePath ExternalPrefExtensionLoader::GetBaseCrxFilePath() {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // LoadOnFileThread() should set |external_file_path_| to a non-empty
+ // path. This function should not be called until after LoadOnFileThread()
+ // is complete.
+ CHECK(!base_path_.empty());
+
+ return base_path_;
+}
+
void ExternalPrefExtensionLoader::StartLoading() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
@@ -47,11 +59,13 @@ void ExternalPrefExtensionLoader::StartLoading() {
void ExternalPrefExtensionLoader::LoadOnFileThread() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+
+ CHECK(PathService::Get(base_path_key_, &base_path_));
+
FilePath json_file;
- PathService::Get(app::DIR_EXTERNAL_EXTENSIONS, &json_file);
- json_file = json_file.Append(FILE_PATH_LITERAL("external_extensions.json"));
- scoped_ptr<DictionaryValue> prefs;
+ json_file = base_path_.Append(FILE_PATH_LITERAL("external_extensions.json"));
+ scoped_ptr<DictionaryValue> prefs;
if (file_util::PathExists(json_file)) {
JSONFileValueSerializer serializer(json_file);
prefs.reset(ExtractPrefs(&serializer));
@@ -68,7 +82,9 @@ void ExternalPrefExtensionLoader::LoadOnFileThread() {
}
ExternalTestingExtensionLoader::ExternalTestingExtensionLoader(
- const std::string& json_data) {
+ const std::string& json_data,
+ const FilePath& fake_base_path)
+ : fake_base_path_(fake_base_path) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
JSONStringValueSerializer serializer(json_data);
testing_prefs_.reset(ExtractPrefs(&serializer));
@@ -79,3 +95,7 @@ void ExternalTestingExtensionLoader::StartLoading() {
prefs_.reset(testing_prefs_->DeepCopy());
LoadFinished();
}
+
+const FilePath ExternalTestingExtensionLoader::GetBaseCrxFilePath() {
+ return fake_base_path_;
+}

Powered by Google App Engine
This is Rietveld 408576698