OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/search_terms_data.h" | 5 #include "chrome/browser/search_engines/search_terms_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/google/google_url_tracker.h" | 11 #include "chrome/browser/google/google_url_tracker.h" |
12 #include "chrome/browser/google/google_util.h" | 12 #include "chrome/browser/google/google_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser_instant_controller.h" | |
15 #include "chrome/browser/ui/search/search.h" | 14 #include "chrome/browser/ui/search/search.h" |
16 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
17 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
18 | 17 |
19 #if defined(ENABLE_RLZ) | 18 #if defined(ENABLE_RLZ) |
20 #include "chrome/browser/rlz/rlz.h" | 19 #include "chrome/browser/rlz/rlz.h" |
21 #endif | 20 #endif |
22 | 21 |
23 using content::BrowserThread; | 22 using content::BrowserThread; |
24 | 23 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 std::string UIThreadSearchTermsData::GetSearchClient() const { | 122 std::string UIThreadSearchTermsData::GetSearchClient() const { |
124 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 123 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
125 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 124 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
126 return std::string(); | 125 return std::string(); |
127 } | 126 } |
128 #endif | 127 #endif |
129 | 128 |
130 std::string UIThreadSearchTermsData::InstantEnabledParam() const { | 129 std::string UIThreadSearchTermsData::InstantEnabledParam() const { |
131 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 130 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
132 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 131 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
133 if (profile_) { | 132 if (chrome::search::IsInstantPrefEnabled(profile_) && |
134 uint32 instant_extended_api_version = | 133 !chrome::search::IsInstantExtendedAPIEnabled(profile_)) |
135 chrome::search::EmbeddedSearchPageVersion(profile_); | 134 return "ion=1&"; |
136 if (instant_extended_api_version == 0 && | |
137 chrome::BrowserInstantController::IsInstantEnabled(profile_)) | |
138 return "ion=1&"; | |
139 } | |
140 return std::string(); | 135 return std::string(); |
141 } | 136 } |
142 | 137 |
143 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam() const { | 138 std::string UIThreadSearchTermsData::InstantExtendedEnabledParam() const { |
144 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 139 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
145 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 140 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
146 if (profile_) { | 141 uint64 instant_extended_api_version = |
147 uint32 instant_extended_api_version = | 142 chrome::search::EmbeddedSearchPageVersion(profile_); |
148 chrome::search::EmbeddedSearchPageVersion(profile_); | 143 if (instant_extended_api_version) { |
149 if (instant_extended_api_version != 0) { | 144 return std::string(google_util::kInstantExtendedAPIParam) + "=" + |
150 return std::string(google_util::kInstantExtendedAPIParam) + "=" + | 145 base::Uint64ToString(instant_extended_api_version) + "&"; |
151 base::Uint64ToString(instant_extended_api_version) + "&"; | |
152 } | |
153 } | 146 } |
154 return std::string(); | 147 return std::string(); |
155 } | 148 } |
156 | 149 |
157 // static | 150 // static |
158 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { | 151 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { |
159 delete google_base_url_; | 152 delete google_base_url_; |
160 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); | 153 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); |
161 } | 154 } |
OLD | NEW |