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/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 = NULL; | |
|
grt (UTC plus 2)
2017/05/17 08:45:43
the idiomatic way i've seen to do this sort of one
Boris Vidolov
2017/05/17 18:37:10
Sure. I've seen both and I just used the old-fashi
| |
| 80 if (!brand) { | |
| 81 brand = new std::string(); | |
| 82 google_brand::GetBrand(brand); | |
| 83 } | |
| 79 // For organic brandcodes do not use rlz at all. Empty brandcode usually | 84 // For organic brandcodes do not use rlz at all. Empty brandcode usually |
| 80 // means a chromium install. This is ok. | 85 // means a chromium install. This is ok. |
| 81 std::string brand; | 86 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 | 87 // 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 | 88 // 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. | 89 // search might not send the RLZ data but this is not really a problem. |
| 87 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); | 90 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); |
| 88 if (from_app_list) | 91 if (from_app_list) |
| 89 access_point = rlz::RLZTracker::ChromeAppList(); | 92 access_point = rlz::RLZTracker::ChromeAppList(); |
| 90 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string); | 93 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string); |
| 91 } | 94 } |
| 92 #endif | 95 #endif |
| 93 return rlz_string; | 96 return rlz_string; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 if (!modifier.empty()) | 149 if (!modifier.empty()) |
| 147 version += " " + modifier; | 150 version += " " + modifier; |
| 148 return version; | 151 return version; |
| 149 } | 152 } |
| 150 | 153 |
| 151 // static | 154 // static |
| 152 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 155 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
| 153 delete google_base_url_; | 156 delete google_base_url_; |
| 154 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 157 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
| 155 } | 158 } |
| OLD | NEW |