| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/autocomplete/keyword_provider.h" | 5 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 void StayInKeywordMode() { | 39 void StayInKeywordMode() { |
| 40 provider_ = NULL; | 40 provider_ = NULL; |
| 41 } | 41 } |
| 42 private: | 42 private: |
| 43 KeywordProvider* provider_; | 43 KeywordProvider* provider_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 KeywordProvider::KeywordProvider(AutocompleteProviderListener* listener, | 46 KeywordProvider::KeywordProvider(AutocompleteProviderListener* listener, |
| 47 Profile* profile) | 47 Profile* profile) |
| 48 : AutocompleteProvider(listener, profile, "Keyword"), | 48 : AutocompleteProvider(listener, profile, |
| 49 AutocompleteProvider::TYPE_KEYWORD), |
| 49 model_(NULL), | 50 model_(NULL), |
| 50 current_input_id_(0) { | 51 current_input_id_(0) { |
| 51 // Extension suggestions always come from the original profile, since that's | 52 // Extension suggestions always come from the original profile, since that's |
| 52 // where extensions run. We use the input ID to distinguish whether the | 53 // where extensions run. We use the input ID to distinguish whether the |
| 53 // suggestions are meant for us. | 54 // suggestions are meant for us. |
| 54 registrar_.Add(this, | 55 registrar_.Add(this, |
| 55 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, | 56 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, |
| 56 content::Source<Profile>(profile->GetOriginalProfile())); | 57 content::Source<Profile>(profile->GetOriginalProfile())); |
| 57 registrar_.Add( | 58 registrar_.Add( |
| 58 this, chrome::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, | 59 this, chrome::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, |
| 59 content::Source<Profile>(profile->GetOriginalProfile())); | 60 content::Source<Profile>(profile->GetOriginalProfile())); |
| 60 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, | 61 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, |
| 61 content::Source<Profile>(profile)); | 62 content::Source<Profile>(profile)); |
| 62 } | 63 } |
| 63 | 64 |
| 64 KeywordProvider::KeywordProvider(AutocompleteProviderListener* listener, | 65 KeywordProvider::KeywordProvider(AutocompleteProviderListener* listener, |
| 65 TemplateURLService* model) | 66 TemplateURLService* model) |
| 66 : AutocompleteProvider(listener, NULL, "Keyword"), | 67 : AutocompleteProvider(listener, NULL, AutocompleteProvider::TYPE_KEYWORD), |
| 67 model_(model), | 68 model_(model), |
| 68 current_input_id_(0) { | 69 current_input_id_(0) { |
| 69 } | 70 } |
| 70 | 71 |
| 71 | 72 |
| 72 namespace { | 73 namespace { |
| 73 | 74 |
| 74 // Helper functor for Start(), for sorting keyword matches by quality. | 75 // Helper functor for Start(), for sorting keyword matches by quality. |
| 75 class CompareQuality { | 76 class CompareQuality { |
| 76 public: | 77 public: |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 } | 582 } |
| 582 | 583 |
| 583 void KeywordProvider::MaybeEndExtensionKeywordMode() { | 584 void KeywordProvider::MaybeEndExtensionKeywordMode() { |
| 584 if (!current_keyword_extension_id_.empty()) { | 585 if (!current_keyword_extension_id_.empty()) { |
| 585 extensions::ExtensionOmniboxEventRouter::OnInputCancelled( | 586 extensions::ExtensionOmniboxEventRouter::OnInputCancelled( |
| 586 profile_, current_keyword_extension_id_); | 587 profile_, current_keyword_extension_id_); |
| 587 | 588 |
| 588 current_keyword_extension_id_.clear(); | 589 current_keyword_extension_id_.clear(); |
| 589 } | 590 } |
| 590 } | 591 } |
| OLD | NEW |