| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 &submit_count_) && | 172 &submit_count_) && |
| 173 GetStringFromJS(contents, "apiHandle.value", | 173 GetStringFromJS(contents, "apiHandle.value", |
| 174 &query_value_) && | 174 &query_value_) && |
| 175 GetIntFromJS(contents, "onFocusChangedCalls", | 175 GetIntFromJS(contents, "onFocusChangedCalls", |
| 176 &on_focus_changed_calls_) && | 176 &on_focus_changed_calls_) && |
| 177 GetBoolFromJS(contents, "isFocused", | 177 GetBoolFromJS(contents, "isFocused", |
| 178 &is_focused_) && | 178 &is_focused_) && |
| 179 GetStringFromJS(contents, "prefetchQuery", &prefetch_query_value_); | 179 GetStringFromJS(contents, "prefetchQuery", &prefetch_query_value_); |
| 180 } | 180 } |
| 181 | 181 |
| 182 TemplateURL* GetDefaultSearchProviderTemplateURL() { | 182 const TemplateURL* GetDefaultSearchProviderTemplateURL() { |
| 183 TemplateURLService* template_url_service = | 183 TemplateURLService* template_url_service = |
| 184 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 184 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
| 185 if (template_url_service) | 185 if (template_url_service) |
| 186 return template_url_service->GetDefaultSearchProvider(); | 186 return template_url_service->GetDefaultSearchProvider(); |
| 187 return NULL; | 187 return NULL; |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool AddSearchToHistory(base::string16 term, int visit_count) { | 190 bool AddSearchToHistory(base::string16 term, int visit_count) { |
| 191 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(); | 191 const TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(); |
| 192 if (!template_url) | 192 if (!template_url) |
| 193 return false; | 193 return false; |
| 194 | 194 |
| 195 history::HistoryService* history = HistoryServiceFactory::GetForProfile( | 195 history::HistoryService* history = HistoryServiceFactory::GetForProfile( |
| 196 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); | 196 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); |
| 197 GURL search(template_url->url_ref().ReplaceSearchTerms( | 197 GURL search(template_url->url_ref().ReplaceSearchTerms( |
| 198 TemplateURLRef::SearchTermsArgs(term), | 198 TemplateURLRef::SearchTermsArgs(term), |
| 199 TemplateURLServiceFactory::GetForProfile( | 199 TemplateURLServiceFactory::GetForProfile( |
| 200 browser()->profile())->search_terms_data())); | 200 browser()->profile())->search_terms_data())); |
| 201 history->AddPageWithDetails( | 201 history->AddPageWithDetails( |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 stream << "link.href = \"" << result_url.spec() << "\";"; | 729 stream << "link.href = \"" << result_url.spec() << "\";"; |
| 730 stream << "document.body.appendChild(link);"; | 730 stream << "document.body.appendChild(link);"; |
| 731 stream << "link.click();"; | 731 stream << "link.click();"; |
| 732 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 732 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
| 733 | 733 |
| 734 content::WaitForLoadStop(contents); | 734 content::WaitForLoadStop(contents); |
| 735 std::string expected_title = | 735 std::string expected_title = |
| 736 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 736 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
| 737 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 737 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
| 738 } | 738 } |
| OLD | NEW |