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

Side by Side Diff: extensions/common/features/json_feature_provider_source.cc

Issue 1308013005: Add scoped_ptr-safe base::Value to Dictionary/List conversion functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made conversions static members. Created 5 years, 3 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
« no previous file with comments | « extensions/common/extension_api.cc ('k') | extensions/common/file_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/features/json_feature_provider_source.h" 5 #include "extensions/common/features/json_feature_provider_source.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 10
(...skipping 12 matching lines...) Expand all
23 .as_string(); 23 .as_string();
24 int error_code = 0; 24 int error_code = 0;
25 std::string error_message; 25 std::string error_message;
26 scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( 26 scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError(
27 features_file, base::JSON_PARSE_RFC, &error_code, &error_message)); 27 features_file, base::JSON_PARSE_RFC, &error_code, &error_message));
28 DCHECK(value) << "Could not load features: " << name_ << " " << error_message; 28 DCHECK(value) << "Could not load features: " << name_ << " " << error_message;
29 29
30 scoped_ptr<base::DictionaryValue> value_as_dict; 30 scoped_ptr<base::DictionaryValue> value_as_dict;
31 if (value) { 31 if (value) {
32 CHECK(value->IsType(base::Value::TYPE_DICTIONARY)) << name_; 32 CHECK(value->IsType(base::Value::TYPE_DICTIONARY)) << name_;
33 value_as_dict.reset(static_cast<base::DictionaryValue*>(value.release())); 33 value_as_dict = base::DictionaryValue::From(value.Pass());
34 } else { 34 } else {
35 // There was some error loading the features file. 35 // There was some error loading the features file.
36 // http://crbug.com/176381 36 // http://crbug.com/176381
37 value_as_dict.reset(new base::DictionaryValue()); 37 value_as_dict.reset(new base::DictionaryValue());
38 } 38 }
39 39
40 // Ensure there are no key collisions. 40 // Ensure there are no key collisions.
41 for (base::DictionaryValue::Iterator iter(*value_as_dict); !iter.IsAtEnd(); 41 for (base::DictionaryValue::Iterator iter(*value_as_dict); !iter.IsAtEnd();
42 iter.Advance()) { 42 iter.Advance()) {
43 if (dictionary_.GetWithoutPathExpansion(iter.key(), NULL)) 43 if (dictionary_.GetWithoutPathExpansion(iter.key(), NULL))
44 LOG(FATAL) << "Key " << iter.key() << " is defined in " << name_ 44 LOG(FATAL) << "Key " << iter.key() << " is defined in " << name_
45 << " JSON feature files more than once."; 45 << " JSON feature files more than once.";
46 } 46 }
47 47
48 // Merge. 48 // Merge.
49 dictionary_.MergeDictionary(value_as_dict.get()); 49 dictionary_.MergeDictionary(value_as_dict.get());
50 } 50 }
51 51
52 } // namespace extensions 52 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/extension_api.cc ('k') | extensions/common/file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698