Chromium Code Reviews| Index: components/update_client/update_response.cc |
| diff --git a/components/update_client/update_response.cc b/components/update_client/update_response.cc |
| index e89a774ae7a77627b0800cf8b6218642c96de385..b6c8c44b8c27683fac680fc91fac9ec202842b49 100644 |
| --- a/components/update_client/update_response.cc |
| +++ b/components/update_client/update_response.cc |
| @@ -80,6 +80,18 @@ static std::vector<xmlNode*> GetChildren(xmlNode* root, const char* name) { |
| return result; |
| } |
| +// Returns whether the attribute is present. |
| +static bool HasAttribute(xmlNode* node, const char* attribute_name) { |
| + const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name); |
| + for (xmlAttr* attr = node->properties; attr != NULL; attr = attr->next) { |
| + if (!xmlStrcmp(attr->name, name) && attr->children && |
| + attr->children->content) { |
| + return true; |
| + } |
| + } |
| + return false; |
| +} |
| + |
| // Returns the value of a named attribute, or the empty string. |
| static std::string GetAttribute(xmlNode* node, const char* attribute_name) { |
| const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name); |
| @@ -268,6 +280,14 @@ bool ParseUpdateCheckTag(xmlNode* updatecheck, |
| bool ParseAppTag(xmlNode* app, |
| UpdateResponse::Result* result, |
| std::string* error) { |
| + // Read cohort information. |
| + result->set_cohort = HasAttribute(app, "cohort"); |
| + result->cohort = GetAttribute(app, "cohort"); |
|
Sorin Jianu
2016/08/18 21:15:15
Would it make sense to dynamically allocate the co
waffles
2016/08/18 22:29:23
According to the spec, if the server serializes an
|
| + result->set_cohort_hint = HasAttribute(app, "cohorthint"); |
| + result->cohort_hint = GetAttribute(app, "cohorthint"); |
| + result->set_cohort_name = HasAttribute(app, "cohortname"); |
| + result->cohort_name = GetAttribute(app, "cohortname"); |
| + |
| // Read the crx id. |
| result->extension_id = GetAttribute(app, "appid"); |
| if (result->extension_id.empty()) { |