| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 UpdateManifest::~UpdateManifest() {} | 28 UpdateManifest::~UpdateManifest() {} |
| 29 | 29 |
| 30 void UpdateManifest::ParseError(const char* details, ...) { | 30 void UpdateManifest::ParseError(const char* details, ...) { |
| 31 va_list args; | 31 va_list args; |
| 32 va_start(args, details); | 32 va_start(args, details); |
| 33 | 33 |
| 34 if (errors_.length() > 0) { | 34 if (errors_.length() > 0) { |
| 35 // TODO(asargent) make a platform abstracted newline? | 35 // TODO(asargent) make a platform abstracted newline? |
| 36 errors_ += "\r\n"; | 36 errors_ += "\r\n"; |
| 37 } | 37 } |
| 38 StringAppendV(&errors_, details, args); | 38 base::StringAppendV(&errors_, details, args); |
| 39 va_end(args); | 39 va_end(args); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Checks whether a given node's name matches |expected_name| and | 42 // Checks whether a given node's name matches |expected_name| and |
| 43 // |expected_namespace|. | 43 // |expected_namespace|. |
| 44 static bool TagNameEquals(const xmlNode* node, const char* expected_name, | 44 static bool TagNameEquals(const xmlNode* node, const char* expected_name, |
| 45 const xmlNs* expected_namespace) { | 45 const xmlNs* expected_namespace) { |
| 46 if (node->ns != expected_namespace) { | 46 if (node->ns != expected_namespace) { |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 } | 74 } |
| 75 return std::string(); | 75 return std::string(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // This is used for the xml parser to report errors. This assumes the context | 78 // This is used for the xml parser to report errors. This assumes the context |
| 79 // is a pointer to a std::string where the error message should be appended. | 79 // is a pointer to a std::string where the error message should be appended. |
| 80 static void XmlErrorFunc(void *context, const char *message, ...) { | 80 static void XmlErrorFunc(void *context, const char *message, ...) { |
| 81 va_list args; | 81 va_list args; |
| 82 va_start(args, message); | 82 va_start(args, message); |
| 83 std::string* error = static_cast<std::string*>(context); | 83 std::string* error = static_cast<std::string*>(context); |
| 84 StringAppendV(error, message, args); | 84 base::StringAppendV(error, message, args); |
| 85 va_end(args); | 85 va_end(args); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Utility class for cleaning up the xml document when leaving a scope. | 88 // Utility class for cleaning up the xml document when leaving a scope. |
| 89 class ScopedXmlDocument { | 89 class ScopedXmlDocument { |
| 90 public: | 90 public: |
| 91 explicit ScopedXmlDocument(xmlDocPtr document) : document_(document) {} | 91 explicit ScopedXmlDocument(xmlDocPtr document) : document_(document) {} |
| 92 ~ScopedXmlDocument() { | 92 ~ScopedXmlDocument() { |
| 93 if (document_) | 93 if (document_) |
| 94 xmlFreeDoc(document_); | 94 xmlFreeDoc(document_); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 std::string error; | 253 std::string error; |
| 254 if (!ParseSingleAppTag(apps[i], gupdate_ns, ¤t, &error)) { | 254 if (!ParseSingleAppTag(apps[i], gupdate_ns, ¤t, &error)) { |
| 255 ParseError("%s", error.c_str()); | 255 ParseError("%s", error.c_str()); |
| 256 } else { | 256 } else { |
| 257 results_.list.push_back(current); | 257 results_.list.push_back(current); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| OLD | NEW |