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

Side by Side Diff: extensions/common/update_manifest.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, 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
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/update_manifest.h" 5 #include "extensions/common/update_manifest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (node->ns != expected_namespace) { 53 if (node->ns != expected_namespace) {
54 return false; 54 return false;
55 } 55 }
56 return 0 == strcmp(expected_name, reinterpret_cast<const char*>(node->name)); 56 return 0 == strcmp(expected_name, reinterpret_cast<const char*>(node->name));
57 } 57 }
58 58
59 // Returns child nodes of |root| with name |name| in namespace |xml_namespace|. 59 // Returns child nodes of |root| with name |name| in namespace |xml_namespace|.
60 static std::vector<xmlNode*> GetChildren(xmlNode* root, xmlNs* xml_namespace, 60 static std::vector<xmlNode*> GetChildren(xmlNode* root, xmlNs* xml_namespace,
61 const char* name) { 61 const char* name) {
62 std::vector<xmlNode*> result; 62 std::vector<xmlNode*> result;
63 for (xmlNode* child = root->children; child != NULL; child = child->next) { 63 for (xmlNode* child = root->children; child != nullptr; child = child->next) {
64 if (!TagNameEquals(child, name, xml_namespace)) { 64 if (!TagNameEquals(child, name, xml_namespace)) {
65 continue; 65 continue;
66 } 66 }
67 result.push_back(child); 67 result.push_back(child);
68 } 68 }
69 return result; 69 return result;
70 } 70 }
71 71
72 // Returns the value of a named attribute, or the empty string. 72 // Returns the value of a named attribute, or the empty string.
73 static std::string GetAttribute(xmlNode* node, const char* attribute_name) { 73 static std::string GetAttribute(xmlNode* node, const char* attribute_name) {
74 const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name); 74 const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name);
75 for (xmlAttr* attr = node->properties; attr != NULL; attr = attr->next) { 75 for (xmlAttr* attr = node->properties; attr != nullptr; attr = attr->next) {
76 if (!xmlStrcmp(attr->name, name) && attr->children && 76 if (!xmlStrcmp(attr->name, name) && attr->children &&
77 attr->children->content) { 77 attr->children->content) {
78 return std::string(reinterpret_cast<const char*>( 78 return std::string(reinterpret_cast<const char*>(
79 attr->children->content)); 79 attr->children->content));
80 } 80 }
81 } 81 }
82 return std::string(); 82 return std::string();
83 } 83 }
84 84
85 // This is used for the xml parser to report errors. This assumes the context 85 // This is used for the xml parser to report errors. This assumes the context
(...skipping 20 matching lines...) Expand all
106 } 106 }
107 107
108 private: 108 private:
109 xmlDocPtr document_; 109 xmlDocPtr document_;
110 }; 110 };
111 111
112 // Returns a pointer to the xmlNs on |node| with the |expected_href|, or 112 // Returns a pointer to the xmlNs on |node| with the |expected_href|, or
113 // NULL if there isn't one with that href. 113 // NULL if there isn't one with that href.
114 static xmlNs* GetNamespace(xmlNode* node, const char* expected_href) { 114 static xmlNs* GetNamespace(xmlNode* node, const char* expected_href) {
115 const xmlChar* href = reinterpret_cast<const xmlChar*>(expected_href); 115 const xmlChar* href = reinterpret_cast<const xmlChar*>(expected_href);
116 for (xmlNs* ns = node->ns; ns != NULL; ns = ns->next) { 116 for (xmlNs* ns = node->ns; ns != nullptr; ns = ns->next) {
117 if (ns->href && !xmlStrcmp(ns->href, href)) { 117 if (ns->href && !xmlStrcmp(ns->href, href)) {
118 return ns; 118 return ns;
119 } 119 }
120 } 120 }
121 return NULL; 121 return nullptr;
122 } 122 }
123 123
124 124
125 // Helper function that reads in values for a single <app> tag. It returns a 125 // Helper function that reads in values for a single <app> tag. It returns a
126 // boolean indicating success or failure. On failure, it writes a error message 126 // boolean indicating success or failure. On failure, it writes a error message
127 // into |error_detail|. 127 // into |error_detail|.
128 static bool ParseSingleAppTag(xmlNode* app_node, xmlNs* xml_namespace, 128 static bool ParseSingleAppTag(xmlNode* app_node, xmlNs* xml_namespace,
129 UpdateManifest::Result* result, 129 UpdateManifest::Result* result,
130 std::string *error_detail) { 130 std::string *error_detail) {
131 // Read the extension id. 131 // Read the extension id.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 std::string error; 276 std::string error;
277 if (!ParseSingleAppTag(apps[i], gupdate_ns, &current, &error)) { 277 if (!ParseSingleAppTag(apps[i], gupdate_ns, &current, &error)) {
278 ParseError("%s", error.c_str()); 278 ParseError("%s", error.c_str());
279 } else { 279 } else {
280 results_.list.push_back(current); 280 results_.list.push_back(current);
281 } 281 }
282 } 282 }
283 283
284 return true; 284 return true;
285 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698