| 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/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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 void KeywordProvider::Observe(NotificationType type, | 454 void KeywordProvider::Observe(NotificationType type, |
| 455 const NotificationSource& source, | 455 const NotificationSource& source, |
| 456 const NotificationDetails& details) { | 456 const NotificationDetails& details) { |
| 457 TemplateURLService* model = | 457 TemplateURLService* model = |
| 458 profile_ ? TemplateURLServiceFactory::GetForProfile(profile_) : model_; | 458 profile_ ? TemplateURLServiceFactory::GetForProfile(profile_) : model_; |
| 459 const AutocompleteInput& input = extension_suggest_last_input_; | 459 const AutocompleteInput& input = extension_suggest_last_input_; |
| 460 | 460 |
| 461 switch (type.value) { | 461 switch (type.value) { |
| 462 case NotificationType::EXTENSION_OMNIBOX_INPUT_ENTERED: | 462 case NotificationType::EXTENSION_OMNIBOX_INPUT_ENTERED: |
| 463 // Input has been accepted, so we're done with this input session. Ensure | 463 // Input has been accepted, so we're done with this input session. Ensure |
| 464 // we don't send the OnInputCancelled event. | 464 // we don't send the OnInputCancelled event, or handle any more stray |
| 465 // suggestions_ready events. |
| 465 current_keyword_extension_id_.clear(); | 466 current_keyword_extension_id_.clear(); |
| 467 current_input_id_ = 0; |
| 466 return; | 468 return; |
| 467 | 469 |
| 468 case NotificationType::EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED: { | 470 case NotificationType::EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED: { |
| 469 // It's possible to change the default suggestion while not in an editing | 471 // It's possible to change the default suggestion while not in an editing |
| 470 // session. | 472 // session. |
| 471 string16 keyword, remaining_input; | 473 string16 keyword, remaining_input; |
| 472 if (matches_.empty() || current_keyword_extension_id_.empty() || | 474 if (matches_.empty() || current_keyword_extension_id_.empty() || |
| 473 !ExtractKeywordFromInput(input, &keyword, &remaining_input)) | 475 !ExtractKeywordFromInput(input, &keyword, &remaining_input)) |
| 474 return; | 476 return; |
| 475 | 477 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 542 } |
| 541 | 543 |
| 542 void KeywordProvider::MaybeEndExtensionKeywordMode() { | 544 void KeywordProvider::MaybeEndExtensionKeywordMode() { |
| 543 if (!current_keyword_extension_id_.empty()) { | 545 if (!current_keyword_extension_id_.empty()) { |
| 544 ExtensionOmniboxEventRouter::OnInputCancelled( | 546 ExtensionOmniboxEventRouter::OnInputCancelled( |
| 545 profile_, current_keyword_extension_id_); | 547 profile_, current_keyword_extension_id_); |
| 546 | 548 |
| 547 current_keyword_extension_id_.clear(); | 549 current_keyword_extension_id_.clear(); |
| 548 } | 550 } |
| 549 } | 551 } |
| OLD | NEW |