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/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 SearchTabHelper::FromWebContents(web_contents())->set_omnibox_has_focus_fn( | 394 SearchTabHelper::FromWebContents(web_contents())->set_omnibox_has_focus_fn( |
395 omnibox_has_focus); | 395 omnibox_has_focus); |
396 SearchTabHelperPrerenderTest::omnibox_has_focus_ = true; | 396 SearchTabHelperPrerenderTest::omnibox_has_focus_ = true; |
397 } | 397 } |
398 | 398 |
399 content::WebContents* web_contents() { | 399 content::WebContents* web_contents() { |
400 return browser()->tab_strip_model()->GetActiveWebContents(); | 400 return browser()->tab_strip_model()->GetActiveWebContents(); |
401 } | 401 } |
402 | 402 |
403 bool IsInstantURLMarkedForPrerendering() { | 403 bool IsInstantURLMarkedForPrerendering() { |
404 GURL instant_url(chrome::GetSearchResultPrefetchBaseURL(profile())); | 404 GURL instant_url(search::GetSearchResultPrefetchBaseURL(profile())); |
405 prerender::PrerenderManager* prerender_manager = | 405 prerender::PrerenderManager* prerender_manager = |
406 prerender::PrerenderManagerFactory::GetForProfile(profile()); | 406 prerender::PrerenderManagerFactory::GetForProfile(profile()); |
407 return prerender_manager->HasPrerenderedUrl(instant_url, web_contents()); | 407 return prerender_manager->HasPrerenderedUrl(instant_url, web_contents()); |
408 } | 408 } |
409 | 409 |
410 static bool omnibox_has_focus(OmniboxView* omnibox) { | 410 static bool omnibox_has_focus(OmniboxView* omnibox) { |
411 return omnibox_has_focus_; | 411 return omnibox_has_focus_; |
412 } | 412 } |
413 | 413 |
414 static bool omnibox_has_focus_; | 414 static bool omnibox_has_focus_; |
(...skipping 20 matching lines...) Expand all Loading... |
435 } | 435 } |
436 | 436 |
437 TEST_F(SearchTabHelperPrerenderTest, | 437 TEST_F(SearchTabHelperPrerenderTest, |
438 OnTabActivatedNoPrerenderIfOmniboxBlurred) { | 438 OnTabActivatedNoPrerenderIfOmniboxBlurred) { |
439 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; | 439 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; |
440 SearchTabHelper* search_tab_helper = | 440 SearchTabHelper* search_tab_helper = |
441 SearchTabHelper::FromWebContents(web_contents()); | 441 SearchTabHelper::FromWebContents(web_contents()); |
442 search_tab_helper->OnTabActivated(); | 442 search_tab_helper->OnTabActivated(); |
443 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); | 443 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); |
444 } | 444 } |
OLD | NEW |