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

Side by Side Diff: components/translate/core/browser/translate_experiment.cc

Issue 1877623002: [Translate] Add Thailand to experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/translate/core/browser/translate_experiment.h" 5 #include "components/translate/core/browser/translate_experiment.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 24 matching lines...) Expand all
35 *ui_lang = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 35 *ui_lang = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
36 kForceTranslateLanguage); 36 kForceTranslateLanguage);
37 return; 37 return;
38 } 38 }
39 39
40 // Otherwise, base the target language on the current country. 40 // Otherwise, base the target language on the current country.
41 if (country == "my") 41 if (country == "my")
42 *ui_lang = "ms"; 42 *ui_lang = "ms";
43 else if (country == "id") 43 else if (country == "id")
44 *ui_lang = "id"; 44 *ui_lang = "id";
45 else if (country == "th")
46 *ui_lang = "th";
45 } 47 }
46 48
47 // static 49 // static
48 bool TranslateExperiment::ShouldOverrideBlocking(const std::string& ui_language, 50 bool TranslateExperiment::ShouldOverrideBlocking(const std::string& ui_language,
49 const std::string& language) { 51 const std::string& language) {
50 return InExperiment() && (language == ui_language); 52 return InExperiment() && (language == ui_language);
51 } 53 }
52 54
53 // static 55 // static
54 bool TranslateExperiment::InExperiment() { 56 bool TranslateExperiment::InExperiment() {
55 // Note: It's important to query the field trial state first, to ensure that 57 // Note: It's important to query the field trial state first, to ensure that
56 // UMA reports the correct group. 58 // UMA reports the correct group.
57 const std::string group_name = 59 const std::string group_name =
58 base::FieldTrialList::FindFullName(kTranslateExperimentTrial); 60 base::FieldTrialList::FindFullName(kTranslateExperimentTrial);
59 if (CommandLine::ForCurrentProcess()->HasSwitch(kDisableTranslateExperiment)) 61 if (CommandLine::ForCurrentProcess()->HasSwitch(kDisableTranslateExperiment))
60 return false; 62 return false;
61 // TODO(groby): Figure out if we can get rid of the enable branch completely. 63 // TODO(groby): Figure out if we can get rid of the enable branch completely.
62 // Or, if we allow enable, we have to gate this on country. I'd rather not, 64 // Or, if we allow enable, we have to gate this on country. I'd rather not,
63 // since this complicates the experiment. 65 // since this complicates the experiment.
64 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableTranslateExperiment)) 66 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableTranslateExperiment))
65 return true; 67 return true;
66 if (CommandLine::ForCurrentProcess()->HasSwitch(kForceTranslateLanguage)) 68 if (CommandLine::ForCurrentProcess()->HasSwitch(kForceTranslateLanguage))
67 return true; 69 return true;
68 // Use StartsWith() for more flexibility (e.g. multiple Enabled groups). 70 // Use StartsWith() for more flexibility (e.g. multiple Enabled groups).
69 return base::StartsWith(group_name, "Enabled", 71 return base::StartsWith(group_name, "Enabled",
70 base::CompareCase::INSENSITIVE_ASCII); 72 base::CompareCase::INSENSITIVE_ASCII);
71 } 73 }
72 74
73 } // namespace translate 75 } // namespace translate
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698