| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/search_engines/ui_thread_search_terms_data.h" | 5 #include "ios/chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "components/google/core/browser/google_url_tracker.h" | 9 #include "components/google/core/browser/google_url_tracker.h" |
| 10 #include "components/google/core/browser/google_util.h" | 10 #include "components/google/core/browser/google_util.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 std::string UIThreadSearchTermsData::GetSuggestClient() const { | 84 std::string UIThreadSearchTermsData::GetSuggestClient() const { |
| 85 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
| 86 return search::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome"; | 86 return search::IsInstantExtendedAPIEnabled() ? "chrome-omni" : "chrome"; |
| 87 } | 87 } |
| 88 | 88 |
| 89 std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const { | 89 std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier() const { |
| 90 DCHECK(thread_checker_.CalledOnValidThread()); | 90 DCHECK(thread_checker_.CalledOnValidThread()); |
| 91 return "chrome-ext-ansg"; | 91 return "chrome-ext-ansg"; |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool UIThreadSearchTermsData::IsShowingSearchTermsOnSearchResultsPages() const { | |
| 95 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 96 return search::IsInstantExtendedAPIEnabled() && | |
| 97 search::IsQueryExtractionEnabled(); | |
| 98 } | |
| 99 | |
| 100 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam( | 94 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam( |
| 101 bool for_search) const { | 95 bool for_search) const { |
| 102 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
| 103 return search::InstantExtendedEnabledParam(for_search); | 97 return search::InstantExtendedEnabledParam(for_search); |
| 104 } | 98 } |
| 105 | 99 |
| 106 std::string UIThreadSearchTermsData::ForceInstantResultsParam( | 100 std::string UIThreadSearchTermsData::ForceInstantResultsParam( |
| 107 bool for_prerender) const { | 101 bool for_prerender) const { |
| 108 DCHECK(thread_checker_.CalledOnValidThread()); | 102 DCHECK(thread_checker_.CalledOnValidThread()); |
| 109 return search::ForceInstantResultsParam(for_prerender); | 103 return search::ForceInstantResultsParam(for_prerender); |
| 110 } | 104 } |
| 111 | 105 |
| 112 int UIThreadSearchTermsData::OmniboxStartMargin() const { | |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 114 // iOS has not InstantService. | |
| 115 return search::kDisableStartMargin; | |
| 116 } | |
| 117 | |
| 118 std::string UIThreadSearchTermsData::NTPIsThemedParam() const { | |
| 119 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 120 // iOS does not supports themed NTP. | |
| 121 return std::string(); | |
| 122 } | |
| 123 | |
| 124 std::string UIThreadSearchTermsData::IOSWebViewTypeParam() const { | 106 std::string UIThreadSearchTermsData::IOSWebViewTypeParam() const { |
| 125 DCHECK(thread_checker_.CalledOnValidThread()); | 107 DCHECK(thread_checker_.CalledOnValidThread()); |
| 126 std::string param = experimental_flags::GetWKWebViewSearchParams(); | 108 std::string param = experimental_flags::GetWKWebViewSearchParams(); |
| 127 if (param.empty()) { | 109 if (param.empty()) { |
| 128 return std::string(); | 110 return std::string(); |
| 129 } | 111 } |
| 130 | 112 |
| 131 return "&esrch=" + net::EscapeQueryParamValue(param, true); | 113 return "&esrch=" + net::EscapeQueryParamValue(param, true); |
| 132 } | 114 } |
| 133 | 115 |
| 134 std::string UIThreadSearchTermsData::GoogleImageSearchSource() const { | 116 std::string UIThreadSearchTermsData::GoogleImageSearchSource() const { |
| 135 DCHECK(thread_checker_.CalledOnValidThread()); | 117 DCHECK(thread_checker_.CalledOnValidThread()); |
| 136 std::string version(version_info::GetProductName() + " " + | 118 std::string version(version_info::GetProductName() + " " + |
| 137 version_info::GetVersionNumber()); | 119 version_info::GetVersionNumber()); |
| 138 if (version_info::IsOfficialBuild()) | 120 if (version_info::IsOfficialBuild()) |
| 139 version += " (Official)"; | 121 version += " (Official)"; |
| 140 version += " " + version_info::GetOSType(); | 122 version += " " + version_info::GetOSType(); |
| 141 std::string modifier(GetChannelString()); | 123 std::string modifier(GetChannelString()); |
| 142 if (!modifier.empty()) | 124 if (!modifier.empty()) |
| 143 version += " " + modifier; | 125 version += " " + modifier; |
| 144 return version; | 126 return version; |
| 145 } | 127 } |
| 146 | 128 |
| 147 } // namespace ios | 129 } // namespace ios |
| OLD | NEW |