OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 show_timer_.Start( | 671 show_timer_.Start( |
672 base::TimeDelta::FromMilliseconds(kShowDelayMS), | 672 base::TimeDelta::FromMilliseconds(kShowDelayMS), |
673 this, &InstantController::ShowTimerFired); | 673 this, &InstantController::ShowTimerFired); |
674 } | 674 } |
675 } | 675 } |
676 UpdateDisplayableLoader(); | 676 UpdateDisplayableLoader(); |
677 } | 677 } |
678 | 678 |
679 InstantController::PreviewCondition InstantController::GetPreviewConditionFor( | 679 InstantController::PreviewCondition InstantController::GetPreviewConditionFor( |
680 const AutocompleteMatch& match, const TemplateURL** template_url) { | 680 const AutocompleteMatch& match, const TemplateURL** template_url) { |
681 const TemplateURL* t_url = GetTemplateURL(match); | 681 const TemplateURL* t_url = match.template_url; |
682 if (t_url) { | 682 if (t_url) { |
683 if (!t_url->id() || | 683 if (!t_url->id() || |
684 !t_url->instant_url() || | 684 !t_url->instant_url() || |
685 IsBlacklistedFromInstant(t_url->id()) || | 685 IsBlacklistedFromInstant(t_url->id()) || |
686 !t_url->instant_url()->SupportsReplacement()) { | 686 !t_url->instant_url()->SupportsReplacement()) { |
687 // To avoid extra load on other search engines we only enable previews if | 687 // To avoid extra load on other search engines we only enable previews if |
688 // they support the instant API. | 688 // they support the instant API. |
689 return PREVIEW_CONDITION_INVALID_TEMPLATE_URL; | 689 return PREVIEW_CONDITION_INVALID_TEMPLATE_URL; |
690 } | 690 } |
691 } | 691 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 if (destroy_factory_.empty()) { | 731 if (destroy_factory_.empty()) { |
732 MessageLoop::current()->PostTask( | 732 MessageLoop::current()->PostTask( |
733 FROM_HERE, destroy_factory_.NewRunnableMethod( | 733 FROM_HERE, destroy_factory_.NewRunnableMethod( |
734 &InstantController::DestroyLoaders)); | 734 &InstantController::DestroyLoaders)); |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 void InstantController::DestroyLoaders() { | 738 void InstantController::DestroyLoaders() { |
739 loaders_to_destroy_.reset(); | 739 loaders_to_destroy_.reset(); |
740 } | 740 } |
741 | |
742 const TemplateURL* InstantController::GetTemplateURL( | |
743 const AutocompleteMatch& match) { | |
744 const TemplateURL* template_url = match.template_url; | |
745 if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || | |
746 match.type == AutocompleteMatch::SEARCH_HISTORY || | |
747 match.type == AutocompleteMatch::SEARCH_SUGGEST) { | |
748 TemplateURLService* model = TemplateURLServiceFactory::GetForProfile( | |
749 tab_contents_->profile()); | |
750 template_url = model ? model->GetDefaultSearchProvider() : NULL; | |
751 } | |
752 return template_url; | |
753 } | |
OLD | NEW |