Chromium Code Reviews| 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 // To avoid extra load on other search engines we only enable previews if | 629 // To avoid extra load on other search engines we only enable previews if |
| 630 // they support the instant API. | 630 // they support the instant API. |
| 631 return false; | 631 return false; |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 *template_url = t_url; | 634 *template_url = t_url; |
| 635 | 635 |
| 636 if (match.destination_url.SchemeIs(chrome::kJavaScriptScheme)) | 636 if (match.destination_url.SchemeIs(chrome::kJavaScriptScheme)) |
| 637 return false; | 637 return false; |
| 638 | 638 |
| 639 // Extension keywords don't have a real destionation URL. | 639 // Extension keywords don't have a real destionation URL. |
|
Peter Kasting
2011/04/13 21:06:59
Nit: While here, destionation -> destination
| |
| 640 if (match.template_url && match.template_url->IsExtensionKeyword()) | 640 if (match.keyword_state == AutocompleteMatch::KEYWORD && |
|
Peter Kasting
2011/04/13 21:06:59
I don't think we need to check the keyword state h
| |
| 641 match.keyword_url && match.keyword_url->IsExtensionKeyword()) | |
| 641 return false; | 642 return false; |
| 642 | 643 |
| 643 // Was the host blacklisted? | 644 // Was the host blacklisted? |
| 644 if (host_blacklist_ && host_blacklist_->count(match.destination_url.host())) | 645 if (host_blacklist_ && host_blacklist_->count(match.destination_url.host())) |
| 645 return false; | 646 return false; |
| 646 | 647 |
| 647 return true; | 648 return true; |
| 648 } | 649 } |
| 649 | 650 |
| 650 void InstantController::BlacklistFromInstant(TemplateURLID id) { | 651 void InstantController::BlacklistFromInstant(TemplateURLID id) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 667 &InstantController::DestroyLoaders)); | 668 &InstantController::DestroyLoaders)); |
| 668 } | 669 } |
| 669 } | 670 } |
| 670 | 671 |
| 671 void InstantController::DestroyLoaders() { | 672 void InstantController::DestroyLoaders() { |
| 672 loaders_to_destroy_.reset(); | 673 loaders_to_destroy_.reset(); |
| 673 } | 674 } |
| 674 | 675 |
| 675 const TemplateURL* InstantController::GetTemplateURL( | 676 const TemplateURL* InstantController::GetTemplateURL( |
| 676 const AutocompleteMatch& match) { | 677 const AutocompleteMatch& match) { |
| 677 const TemplateURL* template_url = match.template_url; | 678 const TemplateURL* template_url = |
| 679 match.keyword_state == AutocompleteMatch::KEYWORD ? match.keyword_url : | |
|
Peter Kasting
2011/04/13 21:06:59
I think you also want to allow DUAL_SHOWING_KEYWOR
| |
| 680 NULL; | |
| 678 if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || | 681 if (match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || |
| 679 match.type == AutocompleteMatch::SEARCH_HISTORY || | 682 match.type == AutocompleteMatch::SEARCH_HISTORY || |
| 680 match.type == AutocompleteMatch::SEARCH_SUGGEST) { | 683 match.type == AutocompleteMatch::SEARCH_SUGGEST) { |
| 681 TemplateURLModel* model = tab_contents_->profile()->GetTemplateURLModel(); | 684 TemplateURLModel* model = tab_contents_->profile()->GetTemplateURLModel(); |
| 682 template_url = model ? model->GetDefaultSearchProvider() : NULL; | 685 template_url = model ? model->GetDefaultSearchProvider() : NULL; |
| 683 } | 686 } |
| 684 return template_url; | 687 return template_url; |
| 685 } | 688 } |
| OLD | NEW |