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 "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
22 #include "components/google/core/browser/google_url_tracker.h" | 22 #include "components/google/core/browser/google_url_tracker.h" |
23 #include "components/google/core/browser/google_util.h" | 23 #include "components/google/core/browser/google_util.h" |
24 #include "components/omnibox/browser/omnibox_field_trial.h" | 24 #include "components/omnibox/browser/omnibox_field_trial.h" |
25 #include "components/search/search.h" | 25 #include "components/search/search.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "ui/base/device_form_factor.h" | 27 #include "ui/base/device_form_factor.h" |
28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
29 | 29 |
30 #if defined(ENABLE_RLZ) | 30 #if defined(ENABLE_RLZ) |
31 #include "chrome/browser/rlz/rlz.h" | 31 #include "components/rlz/rlz_tracker.h" |
32 #endif | 32 #endif |
33 | 33 |
34 using content::BrowserThread; | 34 using content::BrowserThread; |
35 | 35 |
36 // static | 36 // static |
37 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 37 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
38 | 38 |
39 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) | 39 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) |
40 : profile_(profile) { | 40 : profile_(profile) { |
41 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 41 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 base::string16 rlz_string; | 75 base::string16 rlz_string; |
76 #if defined(ENABLE_RLZ) | 76 #if defined(ENABLE_RLZ) |
77 // For organic brandcodes do not use rlz at all. Empty brandcode usually | 77 // For organic brandcodes do not use rlz at all. Empty brandcode usually |
78 // means a chromium install. This is ok. | 78 // means a chromium install. This is ok. |
79 std::string brand; | 79 std::string brand; |
80 if (google_brand::GetBrand(&brand) && !brand.empty() && | 80 if (google_brand::GetBrand(&brand) && !brand.empty() && |
81 !google_brand::IsOrganic(brand)) { | 81 !google_brand::IsOrganic(brand)) { |
82 // This call will return false the first time(s) it is called until the | 82 // This call will return false the first time(s) it is called until the |
83 // value has been cached. This normally would mean that at most one omnibox | 83 // value has been cached. This normally would mean that at most one omnibox |
84 // search might not send the RLZ data but this is not really a problem. | 84 // search might not send the RLZ data but this is not really a problem. |
85 rlz_lib::AccessPoint access_point = RLZTracker::ChromeOmnibox(); | 85 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); |
86 #if !defined(OS_IOS) | 86 #if !defined(OS_IOS) |
87 if (from_app_list) | 87 if (from_app_list) |
88 access_point = RLZTracker::ChromeAppList(); | 88 access_point = rlz::RLZTracker::ChromeAppList(); |
89 #endif | 89 #endif |
90 RLZTracker::GetAccessPointRlz(access_point, &rlz_string); | 90 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string); |
91 } | 91 } |
92 #endif | 92 #endif |
93 return rlz_string; | 93 return rlz_string; |
94 } | 94 } |
95 | 95 |
96 // We can enable this on non-Android if other platforms ever want a non-empty | 96 // We can enable this on non-Android if other platforms ever want a non-empty |
97 // search client string. There is already a unit test in place for Android | 97 // search client string. There is already a unit test in place for Android |
98 // called TemplateURLTest::SearchClient. | 98 // called TemplateURLTest::SearchClient. |
99 std::string UIThreadSearchTermsData::GetSearchClient() const { | 99 std::string UIThreadSearchTermsData::GetSearchClient() const { |
100 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 100 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (!modifier.empty()) | 179 if (!modifier.empty()) |
180 version += " " + modifier; | 180 version += " " + modifier; |
181 return version; | 181 return version; |
182 } | 182 } |
183 | 183 |
184 // static | 184 // static |
185 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 185 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
186 delete google_base_url_; | 186 delete google_base_url_; |
187 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 187 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
188 } | 188 } |
OLD | NEW |