OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_extension_loader.h" | 5 #include "chrome/browser/extensions/external_pref_extension_loader.h" |
6 | 6 |
7 #include "app/app_paths.h" | 7 #include "app/app_paths.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 if (!prefs.get()) | 81 if (!prefs.get()) |
82 prefs.reset(new DictionaryValue()); | 82 prefs.reset(new DictionaryValue()); |
83 | 83 |
84 prefs_.reset(prefs.release()); | 84 prefs_.reset(prefs.release()); |
85 | 85 |
86 // If we have any records to process, then we must have | 86 // If we have any records to process, then we must have |
87 // read the .json file. If we read the .json file, then | 87 // read the .json file. If we read the .json file, then |
88 // we were able to set |base_path_|. | 88 // we were able to set |base_path_|. So, prefs_ is empty, |
89 CHECK(!prefs_->empty() || !base_path_.empty()); | 89 // or base_path_ is not empty. |
| 90 CHECK(prefs_->empty() || !base_path_.empty()); |
90 | 91 |
91 BrowserThread::PostTask( | 92 BrowserThread::PostTask( |
92 BrowserThread::UI, FROM_HERE, | 93 BrowserThread::UI, FROM_HERE, |
93 NewRunnableMethod( | 94 NewRunnableMethod( |
94 this, | 95 this, |
95 &ExternalPrefExtensionLoader::LoadFinished)); | 96 &ExternalPrefExtensionLoader::LoadFinished)); |
96 } | 97 } |
97 | 98 |
98 ExternalTestingExtensionLoader::ExternalTestingExtensionLoader( | 99 ExternalTestingExtensionLoader::ExternalTestingExtensionLoader( |
99 const std::string& json_data, | 100 const std::string& json_data, |
100 const FilePath& fake_base_path) | 101 const FilePath& fake_base_path) |
101 : fake_base_path_(fake_base_path) { | 102 : fake_base_path_(fake_base_path) { |
102 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 103 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
103 JSONStringValueSerializer serializer(json_data); | 104 JSONStringValueSerializer serializer(json_data); |
104 FilePath fake_json_path = fake_base_path.AppendASCII("fake.json"); | 105 FilePath fake_json_path = fake_base_path.AppendASCII("fake.json"); |
105 testing_prefs_.reset(ExtractPrefs(fake_json_path, &serializer)); | 106 testing_prefs_.reset(ExtractPrefs(fake_json_path, &serializer)); |
106 } | 107 } |
107 | 108 |
108 void ExternalTestingExtensionLoader::StartLoading() { | 109 void ExternalTestingExtensionLoader::StartLoading() { |
109 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 110 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
110 prefs_.reset(testing_prefs_->DeepCopy()); | 111 prefs_.reset(testing_prefs_->DeepCopy()); |
111 LoadFinished(); | 112 LoadFinished(); |
112 } | 113 } |
113 | 114 |
114 const FilePath ExternalTestingExtensionLoader::GetBaseCrxFilePath() { | 115 const FilePath ExternalTestingExtensionLoader::GetBaseCrxFilePath() { |
115 return fake_base_path_; | 116 return fake_base_path_; |
116 } | 117 } |
OLD | NEW |