OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
9 #include "base/metrics/histogram_samples.h" | 9 #include "base/metrics/histogram_samples.h" |
10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return template_url_service->GetDefaultSearchProvider(); | 195 return template_url_service->GetDefaultSearchProvider(); |
196 return NULL; | 196 return NULL; |
197 } | 197 } |
198 | 198 |
199 bool AddSearchToHistory(base::string16 term, int visit_count) { | 199 bool AddSearchToHistory(base::string16 term, int visit_count) { |
200 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(); | 200 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(); |
201 if (!template_url) | 201 if (!template_url) |
202 return false; | 202 return false; |
203 | 203 |
204 HistoryService* history = HistoryServiceFactory::GetForProfile( | 204 HistoryService* history = HistoryServiceFactory::GetForProfile( |
205 browser()->profile(), Profile::EXPLICIT_ACCESS); | 205 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); |
206 GURL search(template_url->url_ref().ReplaceSearchTerms( | 206 GURL search(template_url->url_ref().ReplaceSearchTerms( |
207 TemplateURLRef::SearchTermsArgs(term), | 207 TemplateURLRef::SearchTermsArgs(term), |
208 TemplateURLServiceFactory::GetForProfile( | 208 TemplateURLServiceFactory::GetForProfile( |
209 browser()->profile())->search_terms_data())); | 209 browser()->profile())->search_terms_data())); |
210 history->AddPageWithDetails( | 210 history->AddPageWithDetails( |
211 search, base::string16(), visit_count, visit_count, | 211 search, base::string16(), visit_count, visit_count, |
212 base::Time::Now(), false, history::SOURCE_BROWSED); | 212 base::Time::Now(), false, history::SOURCE_BROWSED); |
213 history->SetKeywordSearchTermsForURL( | 213 history->SetKeywordSearchTermsForURL( |
214 search, template_url->id(), term); | 214 search, template_url->id(), term); |
215 return true; | 215 return true; |
216 } | 216 } |
217 | 217 |
218 void BlockUntilHistoryProcessesPendingRequests() { | 218 void BlockUntilHistoryProcessesPendingRequests() { |
219 HistoryService* history = HistoryServiceFactory::GetForProfile( | 219 HistoryService* history = HistoryServiceFactory::GetForProfile( |
220 browser()->profile(), Profile::EXPLICIT_ACCESS); | 220 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); |
221 DCHECK(history); | 221 DCHECK(history); |
222 DCHECK(base::MessageLoop::current()); | 222 DCHECK(base::MessageLoop::current()); |
223 | 223 |
224 base::CancelableTaskTracker tracker; | 224 base::CancelableTaskTracker tracker; |
225 history->ScheduleDBTask( | 225 history->ScheduleDBTask( |
226 scoped_ptr<history::HistoryDBTask>( | 226 scoped_ptr<history::HistoryDBTask>( |
227 new QuittingHistoryDBTask()), | 227 new QuittingHistoryDBTask()), |
228 &tracker); | 228 &tracker); |
229 base::MessageLoop::current()->Run(); | 229 base::MessageLoop::current()->Run(); |
230 } | 230 } |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 stream << "link.href = \"" << result_url.spec() << "\";"; | 968 stream << "link.href = \"" << result_url.spec() << "\";"; |
969 stream << "document.body.appendChild(link);"; | 969 stream << "document.body.appendChild(link);"; |
970 stream << "link.click();"; | 970 stream << "link.click();"; |
971 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 971 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
972 | 972 |
973 content::WaitForLoadStop(contents); | 973 content::WaitForLoadStop(contents); |
974 std::string expected_title = | 974 std::string expected_title = |
975 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 975 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
976 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 976 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
977 } | 977 } |
OLD | NEW |