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/search_engines/ui_thread_search_terms_data.h" | 5 #include "chrome/browser/search_engines/ui_thread_search_terms_data.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 "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 } | 69 } |
70 | 70 |
71 // Android implementations are in ui_thread_search_terms_data_android.cc. | 71 // Android implementations are in ui_thread_search_terms_data_android.cc. |
72 #if !defined(OS_ANDROID) | 72 #if !defined(OS_ANDROID) |
73 base::string16 UIThreadSearchTermsData::GetRlzParameterValue( | 73 base::string16 UIThreadSearchTermsData::GetRlzParameterValue( |
74 bool from_app_list) const { | 74 bool from_app_list) const { |
75 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 75 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
76 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 76 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
77 base::string16 rlz_string; | 77 base::string16 rlz_string; |
78 #if BUILDFLAG(ENABLE_RLZ) | 78 #if BUILDFLAG(ENABLE_RLZ) |
79 static std::string* brand = []() { | |
80 auto* extracted = new std::string(); | |
81 if (!google_brand::GetBrand(extracted)) { | |
Peter Kasting
2017/05/19 01:48:45
Why {} here? It's allowed by the style guide, but
| |
82 extracted->clear(); | |
83 } | |
84 return extracted; | |
85 }(); | |
79 // For organic brandcodes do not use rlz at all. Empty brandcode usually | 86 // For organic brandcodes do not use rlz at all. Empty brandcode usually |
80 // means a chromium install. This is ok. | 87 // means a chromium install. This is ok. |
81 std::string brand; | 88 if (!brand->empty() && !google_brand::IsOrganic(*brand)) { |
82 if (google_brand::GetBrand(&brand) && !brand.empty() && | |
83 !google_brand::IsOrganic(brand)) { | |
84 // This call will return false the first time(s) it is called until the | 89 // This call will return false the first time(s) it is called until the |
85 // value has been cached. This normally would mean that at most one omnibox | 90 // value has been cached. This normally would mean that at most one omnibox |
86 // search might not send the RLZ data but this is not really a problem. | 91 // search might not send the RLZ data but this is not really a problem. |
87 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); | 92 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); |
88 if (from_app_list) | 93 if (from_app_list) |
89 access_point = rlz::RLZTracker::ChromeAppList(); | 94 access_point = rlz::RLZTracker::ChromeAppList(); |
90 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string); | 95 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string); |
91 } | 96 } |
92 #endif | 97 #endif |
93 return rlz_string; | 98 return rlz_string; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 if (!modifier.empty()) | 151 if (!modifier.empty()) |
147 version += " " + modifier; | 152 version += " " + modifier; |
148 return version; | 153 return version; |
149 } | 154 } |
150 | 155 |
151 // static | 156 // static |
152 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 157 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
153 delete google_base_url_; | 158 delete google_base_url_; |
154 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 159 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
155 } | 160 } |
OLD | NEW |