| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/common/extensions/update_manifest.h" | 5 #include "chrome/common/extensions/update_manifest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 void UpdateManifest::ParseError(const char* details, ...) { | 24 void UpdateManifest::ParseError(const char* details, ...) { |
| 25 va_list args; | 25 va_list args; |
| 26 va_start(args, details); | 26 va_start(args, details); |
| 27 | 27 |
| 28 if (errors_.length() > 0) { | 28 if (errors_.length() > 0) { |
| 29 // TODO(asargent) make a platform abstracted newline? | 29 // TODO(asargent) make a platform abstracted newline? |
| 30 errors_ += "\r\n"; | 30 errors_ += "\r\n"; |
| 31 } | 31 } |
| 32 StringAppendV(&errors_, details, args); | 32 StringAppendV(&errors_, details, args); |
| 33 va_end(args); |
| 33 } | 34 } |
| 34 | 35 |
| 35 // Checks whether a given node's name matches |expected_name| and | 36 // Checks whether a given node's name matches |expected_name| and |
| 36 // |expected_namespace|. | 37 // |expected_namespace|. |
| 37 static bool TagNameEquals(const xmlNode* node, const char* expected_name, | 38 static bool TagNameEquals(const xmlNode* node, const char* expected_name, |
| 38 const xmlNs* expected_namespace) { | 39 const xmlNs* expected_namespace) { |
| 39 if (node->ns != expected_namespace) { | 40 if (node->ns != expected_namespace) { |
| 40 return false; | 41 return false; |
| 41 } | 42 } |
| 42 return 0 == strcmp(expected_name, reinterpret_cast<const char*>(node->name)); | 43 return 0 == strcmp(expected_name, reinterpret_cast<const char*>(node->name)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 68 return std::string(); | 69 return std::string(); |
| 69 } | 70 } |
| 70 | 71 |
| 71 // This is used for the xml parser to report errors. This assumes the context | 72 // This is used for the xml parser to report errors. This assumes the context |
| 72 // is a pointer to a std::string where the error message should be appended. | 73 // is a pointer to a std::string where the error message should be appended. |
| 73 static void XmlErrorFunc(void *context, const char *message, ...) { | 74 static void XmlErrorFunc(void *context, const char *message, ...) { |
| 74 va_list args; | 75 va_list args; |
| 75 va_start(args, message); | 76 va_start(args, message); |
| 76 std::string* error = static_cast<std::string*>(context); | 77 std::string* error = static_cast<std::string*>(context); |
| 77 StringAppendV(error, message, args); | 78 StringAppendV(error, message, args); |
| 79 va_end(args); |
| 78 } | 80 } |
| 79 | 81 |
| 80 // Utility class for cleaning up the xml document when leaving a scope. | 82 // Utility class for cleaning up the xml document when leaving a scope. |
| 81 class ScopedXmlDocument { | 83 class ScopedXmlDocument { |
| 82 public: | 84 public: |
| 83 explicit ScopedXmlDocument(xmlDocPtr document) : document_(document) {} | 85 explicit ScopedXmlDocument(xmlDocPtr document) : document_(document) {} |
| 84 ~ScopedXmlDocument() { | 86 ~ScopedXmlDocument() { |
| 85 if (document_) | 87 if (document_) |
| 86 xmlFreeDoc(document_); | 88 xmlFreeDoc(document_); |
| 87 } | 89 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 std::string error; | 229 std::string error; |
| 228 if (!ParseSingleAppTag(apps[i], gupdate_ns, ¤t, &error)) { | 230 if (!ParseSingleAppTag(apps[i], gupdate_ns, ¤t, &error)) { |
| 229 ParseError(error.c_str()); | 231 ParseError(error.c_str()); |
| 230 return false; | 232 return false; |
| 231 } | 233 } |
| 232 results_.push_back(current); | 234 results_.push_back(current); |
| 233 } | 235 } |
| 234 | 236 |
| 235 return true; | 237 return true; |
| 236 } | 238 } |
| OLD | NEW |