OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/installer/gcapi/gcapi_omaha_experiment.h" | 5 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 // Split the original labels by the label separator. | 44 // Split the original labels by the label separator. |
45 std::vector<base::string16> entries; | 45 std::vector<base::string16> entries; |
46 base::SplitString(original_labels, google_update::kExperimentLabelSeparator, | 46 base::SplitString(original_labels, google_update::kExperimentLabelSeparator, |
47 &entries); | 47 &entries); |
48 | 48 |
49 // Keep all labels, but the one we want to add/replace. | 49 // Keep all labels, but the one we want to add/replace. |
50 base::string16 new_labels; | 50 base::string16 new_labels; |
51 for (std::vector<base::string16>::const_iterator it = entries.begin(); | 51 for (const base::string16& entry : entries) { |
52 it != entries.end(); ++it) { | 52 if (!entry.empty() && |
53 if (!it->empty() && !base::StartsWith(*it, label + L"=", true)) { | 53 !base::StartsWith(entry, label + L"=", base::CompareCase::SENSITIVE)) { |
54 new_labels += *it; | 54 new_labels += entry; |
55 new_labels += google_update::kExperimentLabelSeparator; | 55 new_labels += google_update::kExperimentLabelSeparator; |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 new_labels.append( | 59 new_labels.append( |
60 gcapi_internals::GetGCAPIExperimentLabel(brand_code, label)); | 60 gcapi_internals::GetGCAPIExperimentLabel(brand_code, label)); |
61 | 61 |
62 return GoogleUpdateSettings::SetExperimentLabels(system_level, | 62 return GoogleUpdateSettings::SetExperimentLabels(system_level, |
63 new_labels); | 63 new_labels); |
64 } | 64 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 bool SetReactivationExperimentLabels(const wchar_t* brand_code, | 97 bool SetReactivationExperimentLabels(const wchar_t* brand_code, |
98 int shell_mode) { | 98 int shell_mode) { |
99 return SetExperimentLabel(brand_code, gcapi_internals::kReactivationLabel, | 99 return SetExperimentLabel(brand_code, gcapi_internals::kReactivationLabel, |
100 shell_mode); | 100 shell_mode); |
101 } | 101 } |
102 | 102 |
103 bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) { | 103 bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) { |
104 return SetExperimentLabel(brand_code, gcapi_internals::kRelaunchLabel, | 104 return SetExperimentLabel(brand_code, gcapi_internals::kRelaunchLabel, |
105 shell_mode); | 105 shell_mode); |
106 } | 106 } |
OLD | NEW |