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

Side by Side Diff: chrome/browser/extensions/external_pref_loader.cc

Issue 13949011: Cleanup: Remove unnecessary ".get()" from scoped_ptrs<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_path.h" 9 #include "base/files/file_path.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ReadExternalExtensionPrefFile(prefs.get()); 125 ReadExternalExtensionPrefFile(prefs.get());
126 if (!prefs->empty()) 126 if (!prefs->empty())
127 LOG(WARNING) << "You are using an old-style extension deployment method " 127 LOG(WARNING) << "You are using an old-style extension deployment method "
128 "(external_extensions.json), which will soon be " 128 "(external_extensions.json), which will soon be "
129 "deprecated. (see http://code.google.com/chrome/" 129 "deprecated. (see http://code.google.com/chrome/"
130 "extensions/external_extensions.html )"; 130 "extensions/external_extensions.html )";
131 131
132 ReadStandaloneExtensionPrefFiles(prefs.get()); 132 ReadStandaloneExtensionPrefFiles(prefs.get());
133 133
134 prefs_.swap(prefs); 134 prefs_.swap(prefs);
135 if (!prefs_.get()) 135 if (!prefs_)
136 prefs_.reset(new DictionaryValue()); 136 prefs_.reset(new DictionaryValue());
137 137
138 if (base_path_id_ == chrome::DIR_EXTERNAL_EXTENSIONS) { 138 if (base_path_id_ == chrome::DIR_EXTERNAL_EXTENSIONS) {
139 UMA_HISTOGRAM_COUNTS_100("Extensions.ExternalJsonCount", 139 UMA_HISTOGRAM_COUNTS_100("Extensions.ExternalJsonCount",
140 prefs_->size()); 140 prefs_->size());
141 } 141 }
142 142
143 // If we have any records to process, then we must have 143 // If we have any records to process, then we must have
144 // read at least one .json file. If so, then we should have 144 // read at least one .json file. If so, then we should have
145 // set |base_path_|. 145 // set |base_path_|.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // The only platform that uses this check is Mac OS. If you add one, 177 // The only platform that uses this check is Mac OS. If you add one,
178 // you need to implement file_util::VerifyPathControlledByAdmin() for 178 // you need to implement file_util::VerifyPathControlledByAdmin() for
179 // that platform. 179 // that platform.
180 NOTREACHED(); 180 NOTREACHED();
181 #endif // defined(OS_MACOSX) 181 #endif // defined(OS_MACOSX)
182 } 182 }
183 183
184 JSONFileValueSerializer serializer(json_file); 184 JSONFileValueSerializer serializer(json_file);
185 scoped_ptr<DictionaryValue> ext_prefs( 185 scoped_ptr<DictionaryValue> ext_prefs(
186 ExtractExtensionPrefs(&serializer, json_file)); 186 ExtractExtensionPrefs(&serializer, json_file));
187 if (ext_prefs.get()) 187 if (ext_prefs)
188 prefs->MergeDictionary(ext_prefs.get()); 188 prefs->MergeDictionary(ext_prefs.get());
189 } 189 }
190 190
191 void ExternalPrefLoader::ReadStandaloneExtensionPrefFiles( 191 void ExternalPrefLoader::ReadStandaloneExtensionPrefFiles(
192 DictionaryValue* prefs) { 192 DictionaryValue* prefs) {
193 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 193 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
194 CHECK(NULL != prefs); 194 CHECK(NULL != prefs);
195 195
196 // First list the potential .json candidates. 196 // First list the potential .json candidates.
197 std::set<base::FilePath> 197 std::set<base::FilePath>
(...skipping 17 matching lines...) Expand all
215 #elif defined(OS_POSIX) 215 #elif defined(OS_POSIX)
216 extension_candidate_path.RemoveExtension().BaseName().value().c_str(); 216 extension_candidate_path.RemoveExtension().BaseName().value().c_str();
217 #endif 217 #endif
218 218
219 DVLOG(1) << "Reading json file: " 219 DVLOG(1) << "Reading json file: "
220 << extension_candidate_path.LossyDisplayName().c_str(); 220 << extension_candidate_path.LossyDisplayName().c_str();
221 221
222 JSONFileValueSerializer serializer(extension_candidate_path); 222 JSONFileValueSerializer serializer(extension_candidate_path);
223 scoped_ptr<DictionaryValue> ext_prefs( 223 scoped_ptr<DictionaryValue> ext_prefs(
224 ExtractExtensionPrefs(&serializer, extension_candidate_path)); 224 ExtractExtensionPrefs(&serializer, extension_candidate_path));
225 if (ext_prefs.get()) { 225 if (ext_prefs) {
226 DVLOG(1) << "Adding extension with id: " << id; 226 DVLOG(1) << "Adding extension with id: " << id;
227 prefs->Set(id, ext_prefs.release()); 227 prefs->Set(id, ext_prefs.release());
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 ExternalTestingLoader::ExternalTestingLoader( 232 ExternalTestingLoader::ExternalTestingLoader(
233 const std::string& json_data, 233 const std::string& json_data,
234 const base::FilePath& fake_base_path) 234 const base::FilePath& fake_base_path)
235 : fake_base_path_(fake_base_path) { 235 : fake_base_path_(fake_base_path) {
236 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 236 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
237 JSONStringValueSerializer serializer(json_data); 237 JSONStringValueSerializer serializer(json_data);
238 base::FilePath fake_json_path = fake_base_path.AppendASCII("fake.json"); 238 base::FilePath fake_json_path = fake_base_path.AppendASCII("fake.json");
239 testing_prefs_.reset(ExtractExtensionPrefs(&serializer, fake_json_path)); 239 testing_prefs_.reset(ExtractExtensionPrefs(&serializer, fake_json_path));
240 } 240 }
241 241
242 void ExternalTestingLoader::StartLoading() { 242 void ExternalTestingLoader::StartLoading() {
243 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 243 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
244 prefs_.reset(testing_prefs_->DeepCopy()); 244 prefs_.reset(testing_prefs_->DeepCopy());
245 LoadFinished(); 245 LoadFinished();
246 } 246 }
247 247
248 ExternalTestingLoader::~ExternalTestingLoader() {} 248 ExternalTestingLoader::~ExternalTestingLoader() {}
249 249
250 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { 250 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() {
251 return fake_base_path_; 251 return fake_base_path_;
252 } 252 }
253 253
254 } // extensions 254 } // extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system.cc ('k') | chrome/browser/extensions/image_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698