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

Side by Side Diff: chrome/installer/gcapi/gcapi_omaha_experiment.cc

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt's review comments, Mac fix Created 5 years, 5 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 (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 29 matching lines...) Expand all
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;
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 label_and_separator(label);
51 label_and_separator.push_back('=');
50 base::string16 new_labels; 52 base::string16 new_labels;
51 for (std::vector<base::string16>::const_iterator it = entries.begin(); 53 for (const base::string16& entry : entries) {
52 it != entries.end(); ++it) { 54 if (!entry.empty() &&
53 if (!it->empty() && !base::StartsWith(*it, label + L"=", true)) { 55 !base::StartsWith(entry, label_and_separator,
54 new_labels += *it; 56 base::CompareCase::SENSITIVE)) {
57 new_labels += entry;
55 new_labels += google_update::kExperimentLabelSeparator; 58 new_labels += google_update::kExperimentLabelSeparator;
56 } 59 }
57 } 60 }
58 61
59 new_labels.append( 62 new_labels.append(
60 gcapi_internals::GetGCAPIExperimentLabel(brand_code, label)); 63 gcapi_internals::GetGCAPIExperimentLabel(brand_code, label));
61 64
62 return GoogleUpdateSettings::SetExperimentLabels(system_level, 65 return GoogleUpdateSettings::SetExperimentLabels(system_level,
63 new_labels); 66 new_labels);
64 } 67 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool SetReactivationExperimentLabels(const wchar_t* brand_code, 100 bool SetReactivationExperimentLabels(const wchar_t* brand_code,
98 int shell_mode) { 101 int shell_mode) {
99 return SetExperimentLabel(brand_code, gcapi_internals::kReactivationLabel, 102 return SetExperimentLabel(brand_code, gcapi_internals::kReactivationLabel,
100 shell_mode); 103 shell_mode);
101 } 104 }
102 105
103 bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) { 106 bool SetRelaunchExperimentLabels(const wchar_t* brand_code, int shell_mode) {
104 return SetExperimentLabel(brand_code, gcapi_internals::kRelaunchLabel, 107 return SetExperimentLabel(brand_code, gcapi_internals::kRelaunchLabel,
105 shell_mode); 108 shell_mode);
106 } 109 }
OLDNEW
« no previous file with comments | « chrome/common/variations/experiment_labels.cc ('k') | chrome/installer/util/delete_after_reboot_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698