Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/google/google_brand.h" | 5 #include "chrome/browser/google/google_brand.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 | 83 |
| 84 bool IsOrganic(const std::string& brand) { | 84 bool IsOrganic(const std::string& brand) { |
| 85 #if defined(OS_MACOSX) | 85 #if defined(OS_MACOSX) |
| 86 if (brand.empty()) { | 86 if (brand.empty()) { |
| 87 // An empty brand string on Mac is used for channels other than stable, | 87 // An empty brand string on Mac is used for channels other than stable, |
| 88 // which are always organic. | 88 // which are always organic. |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 const char* const kBrands[] = { | 93 const char* const kBrands[] = { |
|
Peter Kasting
2017/04/12 20:05:20
Nit: Maybe this should be kOrganicBrands?
Roger Tawa OOO till Jul 10th
2017/04/12 21:51:43
Done.
| |
| 94 "CHCA", "CHCB", "CHCG", "CHCH", "CHCI", "CHCJ", "CHCK", "CHCL", | 94 "CHCA", "CHCB", "CHCG", "CHCH", "CHCI", "CHCJ", "CHCK", "CHCL", |
| 95 "CHFO", "CHFT", "CHHS", "CHHM", "CHMA", "CHMB", "CHME", "CHMF", | 95 "CHFO", "CHFT", "CHHS", "CHHM", "CHMA", "CHMB", "CHME", "CHMF", |
| 96 "CHMG", "CHMH", "CHMI", "CHMQ", "CHMV", "CHNB", "CHNC", "CHNG", | 96 "CHMG", "CHMH", "CHMI", "CHMQ", "CHMV", "CHNB", "CHNC", "CHNG", |
| 97 "CHNH", "CHNI", "CHOA", "CHOB", "CHOC", "CHON", "CHOO", "CHOP", | 97 "CHNH", "CHNI", "CHOA", "CHOB", "CHOC", "CHON", "CHOO", "CHOP", |
| 98 "CHOQ", "CHOR", "CHOS", "CHOT", "CHOU", "CHOX", "CHOY", "CHOZ", | 98 "CHOQ", "CHOR", "CHOS", "CHOT", "CHOU", "CHOX", "CHOY", "CHOZ", |
| 99 "CHPD", "CHPE", "CHPF", "CHPG", "ECBA", "ECBB", "ECDA", "ECDB", | 99 "CHPD", "CHPE", "CHPF", "CHPG", "ECBA", "ECBB", "ECDA", "ECDB", |
| 100 "ECSA", "ECSB", "ECVA", "ECVB", "ECWA", "ECWB", "ECWC", "ECWD", | 100 "ECSA", "ECSB", "ECVA", "ECVB", "ECWA", "ECWB", "ECWC", "ECWD", |
| 101 "ECWE", "ECWF", "EUBB", "EUBC", "GGLA", "GGLS" | 101 "ECWE", "ECWF", "EUBB", "EUBC", "GGLA", "GGLS" |
| 102 }; | 102 }; |
| 103 const char* const* end = &kBrands[arraysize(kBrands)]; | 103 const char* const* end = &kBrands[arraysize(kBrands)]; |
| 104 const char* const* found = std::find(&kBrands[0], end, brand); | 104 const char* const* found = std::find(&kBrands[0], end, brand); |
|
Peter Kasting
2017/04/12 20:05:20
Nit: Could probably use binary_search() in place o
Roger Tawa OOO till Jul 10th
2017/04/12 21:51:43
Done.
| |
| 105 if (found != end) | 105 if (found != end) |
| 106 return true; | 106 return true; |
| 107 | 107 |
| 108 // The Chrome enterprise brand code is the only GGR* brand to be non-organic. | |
| 109 if (brand == "GGRV") | |
| 110 return false; | |
| 111 | |
| 108 return base::StartsWith(brand, "EUB", base::CompareCase::SENSITIVE) || | 112 return base::StartsWith(brand, "EUB", base::CompareCase::SENSITIVE) || |
| 109 base::StartsWith(brand, "EUC", base::CompareCase::SENSITIVE) || | 113 base::StartsWith(brand, "EUC", base::CompareCase::SENSITIVE) || |
| 110 base::StartsWith(brand, "GGR", base::CompareCase::SENSITIVE); | 114 base::StartsWith(brand, "GGR", base::CompareCase::SENSITIVE); |
| 111 } | 115 } |
| 112 | 116 |
| 113 bool IsOrganicFirstRun(const std::string& brand) { | 117 bool IsOrganicFirstRun(const std::string& brand) { |
| 114 #if defined(OS_MACOSX) | 118 #if defined(OS_MACOSX) |
| 115 if (brand.empty()) { | 119 if (brand.empty()) { |
| 116 // An empty brand string on Mac is used for channels other than stable, | 120 // An empty brand string on Mac is used for channels other than stable, |
| 117 // which are always organic. | 121 // which are always organic. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 139 DCHECK(g_brand_for_testing == NULL); | 143 DCHECK(g_brand_for_testing == NULL); |
| 140 g_brand_for_testing = brand_.c_str(); | 144 g_brand_for_testing = brand_.c_str(); |
| 141 } | 145 } |
| 142 | 146 |
| 143 BrandForTesting::~BrandForTesting() { | 147 BrandForTesting::~BrandForTesting() { |
| 144 g_brand_for_testing = NULL; | 148 g_brand_for_testing = NULL; |
| 145 } | 149 } |
| 146 | 150 |
| 147 | 151 |
| 148 } // namespace google_brand | 152 } // namespace google_brand |
| OLD | NEW |