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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 const bool system_level = shell_mode == GCAPI_INVOKED_UAC_ELEVATION; | 36 const bool system_level = shell_mode == GCAPI_INVOKED_UAC_ELEVATION; |
37 | 37 |
38 base::string16 original_labels; | 38 base::string16 original_labels; |
39 if (!GoogleUpdateSettings::ReadExperimentLabels(system_level, | 39 if (!GoogleUpdateSettings::ReadExperimentLabels(system_level, |
40 &original_labels)) { | 40 &original_labels)) { |
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 = base::SplitString( |
46 base::SplitString(original_labels, google_update::kExperimentLabelSeparator, | 46 original_labels, |
47 &entries); | 47 base::string16(1, google_update::kExperimentLabelSeparator), |
| 48 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
48 | 49 |
49 // Keep all labels, but the one we want to add/replace. | 50 // Keep all labels, but the one we want to add/replace. |
50 base::string16 label_and_separator(label); | 51 base::string16 label_and_separator(label); |
51 label_and_separator.push_back('='); | 52 label_and_separator.push_back('='); |
52 base::string16 new_labels; | 53 base::string16 new_labels; |
53 for (const base::string16& entry : entries) { | 54 for (const base::string16& entry : entries) { |
54 if (!entry.empty() && | 55 if (!entry.empty() && |
55 !base::StartsWith(entry, label_and_separator, | 56 !base::StartsWith(entry, label_and_separator, |
56 base::CompareCase::SENSITIVE)) { | 57 base::CompareCase::SENSITIVE)) { |
57 new_labels += entry; | 58 new_labels += entry; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 bool SetReactivationExperimentLabels(const wchar_t* brand_code, | 101 bool SetReactivationExperimentLabels(const wchar_t* brand_code, |
101 int shell_mode) { | 102 int shell_mode) { |
102 return SetExperimentLabel(brand_code, gcapi_internals::kReactivationLabel, | 103 return SetExperimentLabel(brand_code, gcapi_internals::kReactivationLabel, |
103 shell_mode); | 104 shell_mode); |
104 } | 105 } |
105 | 106 |
106 bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) { | 107 bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) { |
107 return SetExperimentLabel(brand_code, gcapi_internals::kRelaunchLabel, | 108 return SetExperimentLabel(brand_code, gcapi_internals::kRelaunchLabel, |
108 shell_mode); | 109 shell_mode); |
109 } | 110 } |
OLD | NEW |