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" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/google/google_brand.h" | 12 #include "chrome/browser/google/google_brand.h" |
13 #include "chrome/browser/google/google_url_tracker_factory.h" | 13 #include "chrome/browser/google/google_url_tracker_factory.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/search/instant_service.h" | 15 #include "chrome/browser/search/instant_service.h" |
16 #include "chrome/browser/search/instant_service_factory.h" | 16 #include "chrome/browser/search/instant_service_factory.h" |
17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
18 #include "chrome/common/channel_info.h" | 18 #include "chrome/common/channel_info.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "components/google/core/browser/google_url_tracker.h" | 21 #include "components/google/core/browser/google_url_tracker.h" |
22 #include "components/google/core/browser/google_util.h" | 22 #include "components/google/core/browser/google_util.h" |
23 #include "components/omnibox/browser/omnibox_field_trial.h" | 23 #include "components/omnibox/browser/omnibox_field_trial.h" |
24 #include "components/prefs/pref_service.h" | 24 #include "components/prefs/pref_service.h" |
25 #include "components/search/search.h" | 25 #include "components/search/search.h" |
26 #include "components/version_info/version_info.h" | 26 #include "components/version_info/version_info.h" |
27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "rlz/features/features.h" |
28 #include "ui/base/device_form_factor.h" | 29 #include "ui/base/device_form_factor.h" |
29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
30 | 31 |
31 #if defined(ENABLE_RLZ) | 32 #if BUILDFLAG(ENABLE_RLZ) |
32 #include "components/rlz/rlz_tracker.h" | 33 #include "components/rlz/rlz_tracker.h" |
33 #endif | 34 #endif |
34 | 35 |
35 using content::BrowserThread; | 36 using content::BrowserThread; |
36 | 37 |
37 // static | 38 // static |
38 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; | 39 std::string* UIThreadSearchTermsData::google_base_url_ = NULL; |
39 | 40 |
40 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) | 41 UIThreadSearchTermsData::UIThreadSearchTermsData(Profile* profile) |
41 : profile_(profile) { | 42 : profile_(profile) { |
(...skipping 25 matching lines...) Expand all Loading... |
67 return g_browser_process->GetApplicationLocale(); | 68 return g_browser_process->GetApplicationLocale(); |
68 } | 69 } |
69 | 70 |
70 // Android implementations are in ui_thread_search_terms_data_android.cc. | 71 // Android implementations are in ui_thread_search_terms_data_android.cc. |
71 #if !defined(OS_ANDROID) | 72 #if !defined(OS_ANDROID) |
72 base::string16 UIThreadSearchTermsData::GetRlzParameterValue( | 73 base::string16 UIThreadSearchTermsData::GetRlzParameterValue( |
73 bool from_app_list) const { | 74 bool from_app_list) const { |
74 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || | 75 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
75 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 76 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
76 base::string16 rlz_string; | 77 base::string16 rlz_string; |
77 #if defined(ENABLE_RLZ) | 78 #if BUILDFLAG(ENABLE_RLZ) |
78 // For organic brandcodes do not use rlz at all. Empty brandcode usually | 79 // For organic brandcodes do not use rlz at all. Empty brandcode usually |
79 // means a chromium install. This is ok. | 80 // means a chromium install. This is ok. |
80 std::string brand; | 81 std::string brand; |
81 if (google_brand::GetBrand(&brand) && !brand.empty() && | 82 if (google_brand::GetBrand(&brand) && !brand.empty() && |
82 !google_brand::IsOrganic(brand)) { | 83 !google_brand::IsOrganic(brand)) { |
83 // This call will return false the first time(s) it is called until the | 84 // This call will return false the first time(s) it is called until the |
84 // value has been cached. This normally would mean that at most one omnibox | 85 // value has been cached. This normally would mean that at most one omnibox |
85 // search might not send the RLZ data but this is not really a problem. | 86 // search might not send the RLZ data but this is not really a problem. |
86 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); | 87 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); |
87 if (from_app_list) | 88 if (from_app_list) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (!modifier.empty()) | 146 if (!modifier.empty()) |
146 version += " " + modifier; | 147 version += " " + modifier; |
147 return version; | 148 return version; |
148 } | 149 } |
149 | 150 |
150 // static | 151 // static |
151 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 152 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
152 delete google_base_url_; | 153 delete google_base_url_; |
153 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 154 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
154 } | 155 } |
OLD | NEW |