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

Side by Side Diff: extensions/common/manifest_handlers/requirements_info.cc

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/manifest_handlers/requirements_info.h" 5 #include "extensions/common/manifest_handlers/requirements_info.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "extensions/common/error_utils.h" 11 #include "extensions/common/error_utils.h"
12 #include "extensions/common/manifest_constants.h" 12 #include "extensions/common/manifest_constants.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 namespace keys = manifest_keys; 16 namespace keys = manifest_keys;
17 namespace errors = manifest_errors; 17 namespace errors = manifest_errors;
18 18
19 RequirementsInfo::RequirementsInfo(const Manifest* manifest) 19 RequirementsInfo::RequirementsInfo(const Manifest* manifest)
20 : webgl(false), 20 : webgl(false),
21 npapi(false), 21 npapi(false),
22 window_shape(false) { 22 window_shape(false) {
23 // Before parsing requirements from the manifest, automatically default the 23 // Before parsing requirements from the manifest, automatically default the
24 // NPAPI plugin requirement based on whether it includes NPAPI plugins. 24 // NPAPI plugin requirement based on whether it includes NPAPI plugins.
25 const base::ListValue* list_value = NULL; 25 const base::ListValue* list_value = nullptr;
26 npapi = manifest->GetList(keys::kPlugins, &list_value) && 26 npapi = manifest->GetList(keys::kPlugins, &list_value) &&
27 !list_value->empty(); 27 !list_value->empty();
28 } 28 }
29 29
30 RequirementsInfo::~RequirementsInfo() { 30 RequirementsInfo::~RequirementsInfo() {
31 } 31 }
32 32
33 // static 33 // static
34 const RequirementsInfo& RequirementsInfo::GetRequirements( 34 const RequirementsInfo& RequirementsInfo::GetRequirements(
35 const Extension* extension) { 35 const Extension* extension) {
(...skipping 26 matching lines...) Expand all
62 62
63 bool RequirementsHandler::Parse(Extension* extension, base::string16* error) { 63 bool RequirementsHandler::Parse(Extension* extension, base::string16* error) {
64 scoped_ptr<RequirementsInfo> requirements( 64 scoped_ptr<RequirementsInfo> requirements(
65 new RequirementsInfo(extension->manifest())); 65 new RequirementsInfo(extension->manifest()));
66 66
67 if (!extension->manifest()->HasKey(keys::kRequirements)) { 67 if (!extension->manifest()->HasKey(keys::kRequirements)) {
68 extension->SetManifestData(keys::kRequirements, requirements.release()); 68 extension->SetManifestData(keys::kRequirements, requirements.release());
69 return true; 69 return true;
70 } 70 }
71 71
72 const base::DictionaryValue* requirements_value = NULL; 72 const base::DictionaryValue* requirements_value = nullptr;
73 if (!extension->manifest()->GetDictionary(keys::kRequirements, 73 if (!extension->manifest()->GetDictionary(keys::kRequirements,
74 &requirements_value)) { 74 &requirements_value)) {
75 *error = base::ASCIIToUTF16(errors::kInvalidRequirements); 75 *error = base::ASCIIToUTF16(errors::kInvalidRequirements);
76 return false; 76 return false;
77 } 77 }
78 78
79 for (base::DictionaryValue::Iterator iter(*requirements_value); 79 for (base::DictionaryValue::Iterator iter(*requirements_value);
80 !iter.IsAtEnd(); 80 !iter.IsAtEnd();
81 iter.Advance()) { 81 iter.Advance()) {
82 const base::DictionaryValue* requirement_value; 82 const base::DictionaryValue* requirement_value;
(...skipping 14 matching lines...) Expand all
97 } 97 }
98 if (plugin_iter.key() == "npapi") { 98 if (plugin_iter.key() == "npapi") {
99 requirements->npapi = plugin_required; 99 requirements->npapi = plugin_required;
100 } else { 100 } else {
101 *error = ErrorUtils::FormatErrorMessageUTF16( 101 *error = ErrorUtils::FormatErrorMessageUTF16(
102 errors::kInvalidRequirement, iter.key()); 102 errors::kInvalidRequirement, iter.key());
103 return false; 103 return false;
104 } 104 }
105 } 105 }
106 } else if (iter.key() == "3D") { 106 } else if (iter.key() == "3D") {
107 const base::ListValue* features = NULL; 107 const base::ListValue* features = nullptr;
108 if (!requirement_value->GetListWithoutPathExpansion("features", 108 if (!requirement_value->GetListWithoutPathExpansion("features",
109 &features) || 109 &features) ||
110 !features) { 110 !features) {
111 *error = ErrorUtils::FormatErrorMessageUTF16( 111 *error = ErrorUtils::FormatErrorMessageUTF16(
112 errors::kInvalidRequirement, iter.key()); 112 errors::kInvalidRequirement, iter.key());
113 return false; 113 return false;
114 } 114 }
115 115
116 for (base::ListValue::const_iterator feature_iter = features->begin(); 116 for (base::ListValue::const_iterator feature_iter = features->begin();
117 feature_iter != features->end(); ++feature_iter) { 117 feature_iter != features->end(); ++feature_iter) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 *error = base::ASCIIToUTF16(errors::kInvalidRequirements); 150 *error = base::ASCIIToUTF16(errors::kInvalidRequirements);
151 return false; 151 return false;
152 } 152 }
153 } 153 }
154 154
155 extension->SetManifestData(keys::kRequirements, requirements.release()); 155 extension->SetManifestData(keys::kRequirements, requirements.release());
156 return true; 156 return true;
157 } 157 }
158 158
159 } // namespace extensions 159 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698