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

Side by Side Diff: components/update_client/update_checker.cc

Issue 1823273002: Send the value of google_brand::GetBrand in component update checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor unit test improvement. Created 4 years, 9 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 "components/update_client/update_checker.h" 5 #include "components/update_client/update_checker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 #include "components/update_client/configurator.h" 21 #include "components/update_client/configurator.h"
22 #include "components/update_client/crx_update_item.h" 22 #include "components/update_client/crx_update_item.h"
23 #include "components/update_client/request_sender.h" 23 #include "components/update_client/request_sender.h"
24 #include "components/update_client/utils.h" 24 #include "components/update_client/utils.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 namespace update_client { 27 namespace update_client {
28 28
29 namespace { 29 namespace {
30 30
31 // Returns a sanitized version of the brand or an empty string otherwise.
32 std::string SanitizeBrand(const std::string& brand) {
33 return IsValidBrand(brand) ? brand : std::string("");
34 }
35
31 // Builds an update check request for |components|. |additional_attributes| is 36 // Builds an update check request for |components|. |additional_attributes| is
32 // serialized as part of the <request> element of the request to customize it 37 // serialized as part of the <request> element of the request to customize it
33 // with data that is not platform or component specific. For each |item|, a 38 // with data that is not platform or component specific. For each |item|, a
34 // corresponding <app> element is created and inserted as a child node of 39 // corresponding <app> element is created and inserted as a child node of
35 // the <request>. 40 // the <request>.
36 // 41 //
37 // An app element looks like this: 42 // An app element looks like this:
38 // <app appid="hnimpnehoodheedghdeeijklkeaacbdc" 43 // <app appid="hnimpnehoodheedghdeeijklkeaacbdc"
39 // version="0.1.2.3" installsource="ondemand"> 44 // version="0.1.2.3" installsource="ondemand">
40 // <updatecheck /> 45 // <updatecheck />
41 // <packages> 46 // <packages>
42 // <package fp="abcd" /> 47 // <package fp="abcd" />
43 // </packages> 48 // </packages>
44 // </app> 49 // </app>
45 std::string BuildUpdateCheckRequest(const Configurator& config, 50 std::string BuildUpdateCheckRequest(const Configurator& config,
46 const std::vector<CrxUpdateItem*>& items, 51 const std::vector<CrxUpdateItem*>& items,
47 const std::string& additional_attributes) { 52 const std::string& additional_attributes) {
53 const std::string brand(SanitizeBrand(config.GetBrand()));
48 std::string app_elements; 54 std::string app_elements;
49 for (size_t i = 0; i != items.size(); ++i) { 55 for (size_t i = 0; i != items.size(); ++i) {
50 const CrxUpdateItem* item = items[i]; 56 const CrxUpdateItem* item = items[i];
51 std::string app("<app "); 57 std::string app("<app ");
52 base::StringAppendF(&app, "appid=\"%s\" version=\"%s\"", item->id.c_str(), 58 base::StringAppendF(&app, "appid=\"%s\" version=\"%s\"", item->id.c_str(),
53 item->component.version.GetString().c_str()); 59 item->component.version.GetString().c_str());
60 if (!brand.empty())
61 base::StringAppendF(&app, " brand=\"%s\"", brand.c_str());
54 if (item->on_demand) 62 if (item->on_demand)
55 base::StringAppendF(&app, " installsource=\"ondemand\""); 63 base::StringAppendF(&app, " installsource=\"ondemand\"");
56 base::StringAppendF(&app, ">"); 64 base::StringAppendF(&app, ">");
57 base::StringAppendF(&app, "<updatecheck />"); 65 base::StringAppendF(&app, "<updatecheck />");
58 if (!item->component.fingerprint.empty()) { 66 if (!item->component.fingerprint.empty()) {
59 base::StringAppendF(&app, 67 base::StringAppendF(&app,
60 "<packages>" 68 "<packages>"
61 "<package fp=\"%s\"/>" 69 "<package fp=\"%s\"/>"
62 "</packages>", 70 "</packages>",
63 item->component.fingerprint.c_str()); 71 item->component.fingerprint.c_str());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 156 }
149 157
150 } // namespace 158 } // namespace
151 159
152 scoped_ptr<UpdateChecker> UpdateChecker::Create( 160 scoped_ptr<UpdateChecker> UpdateChecker::Create(
153 const scoped_refptr<Configurator>& config) { 161 const scoped_refptr<Configurator>& config) {
154 return scoped_ptr<UpdateChecker>(new UpdateCheckerImpl(config)); 162 return scoped_ptr<UpdateChecker>(new UpdateCheckerImpl(config));
155 } 163 }
156 164
157 } // namespace update_client 165 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/test_configurator.cc ('k') | components/update_client/update_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698