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 "chrome/browser/ui/search/instant_search_prerenderer.h" | 5 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // Allow prerendering only for search type AutocompleteMatch suggestions. | 313 // Allow prerendering only for search type AutocompleteMatch suggestions. |
314 AutocompleteMatch search_type_match(NULL, 1100, false, | 314 AutocompleteMatch search_type_match(NULL, 1100, false, |
315 AutocompleteMatchType::SEARCH_SUGGEST); | 315 AutocompleteMatchType::SEARCH_SUGGEST); |
316 search_type_match.keyword = ASCIIToUTF16("{google:baseurl}"); | 316 search_type_match.keyword = ASCIIToUTF16("{google:baseurl}"); |
317 EXPECT_TRUE(AutocompleteMatch::IsSearchType(search_type_match.type)); | 317 EXPECT_TRUE(AutocompleteMatch::IsSearchType(search_type_match.type)); |
318 EXPECT_TRUE(prerenderer->IsAllowed(search_type_match, active_tab)); | 318 EXPECT_TRUE(prerenderer->IsAllowed(search_type_match, active_tab)); |
319 | 319 |
320 // Do not allow prerendering for custom search provider requests. | 320 // Do not allow prerendering for custom search provider requests. |
321 TemplateURLData data; | 321 TemplateURLData data; |
322 data.SetURL("https://www.dummyurl.com/search?q=%s&img=1"); | 322 data.SetURL("https://www.dummyurl.com/search?q=%s&img=1"); |
323 data.short_name = ASCIIToUTF16("t"); | 323 data.SetShortName(ASCIIToUTF16("t")); |
324 data.SetKeyword(ASCIIToUTF16("k")); | 324 data.SetKeyword(ASCIIToUTF16("k")); |
325 TemplateURL* t_url = new TemplateURL(data); | 325 TemplateURL* t_url = new TemplateURL(data); |
326 TemplateURLService* service = | 326 TemplateURLService* service = |
327 TemplateURLServiceFactory::GetForProfile(profile()); | 327 TemplateURLServiceFactory::GetForProfile(profile()); |
328 service->Add(t_url); | 328 service->Add(t_url); |
329 service->Load(); | 329 service->Load(); |
330 AutocompleteMatch custom_search_type_match( | 330 AutocompleteMatch custom_search_type_match( |
331 NULL, 1100, false, AutocompleteMatchType::SEARCH_SUGGEST); | 331 NULL, 1100, false, AutocompleteMatchType::SEARCH_SUGGEST); |
332 custom_search_type_match.keyword = ASCIIToUTF16("k"); | 332 custom_search_type_match.keyword = ASCIIToUTF16("k"); |
333 custom_search_type_match.destination_url = | 333 custom_search_type_match.destination_url = |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 Tuple<base::string16, EmbeddedSearchRequestParams> params; | 532 Tuple<base::string16, EmbeddedSearchRequestParams> params; |
533 ChromeViewMsg_SearchBoxSubmit::Read(message, ¶ms); | 533 ChromeViewMsg_SearchBoxSubmit::Read(message, ¶ms); |
534 EXPECT_EQ("foo", base::UTF16ToASCII(get<0>(params))); | 534 EXPECT_EQ("foo", base::UTF16ToASCII(get<0>(params))); |
535 EXPECT_EQ("f", base::UTF16ToASCII(get<1>(params).original_query)); | 535 EXPECT_EQ("f", base::UTF16ToASCII(get<1>(params).original_query)); |
536 EXPECT_EQ("utf-8", base::UTF16ToASCII(get<1>(params).input_encoding)); | 536 EXPECT_EQ("utf-8", base::UTF16ToASCII(get<1>(params).input_encoding)); |
537 EXPECT_EQ("", base::UTF16ToASCII(get<1>(params).rlz_parameter_value)); | 537 EXPECT_EQ("", base::UTF16ToASCII(get<1>(params).rlz_parameter_value)); |
538 EXPECT_EQ("chrome...0", | 538 EXPECT_EQ("chrome...0", |
539 base::UTF16ToASCII(get<1>(params).assisted_query_stats)); | 539 base::UTF16ToASCII(get<1>(params).assisted_query_stats)); |
540 } | 540 } |
541 #endif | 541 #endif |
OLD | NEW |