Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit.cc

Issue 3322001: Handle ctrl press when arrowing to a search keyword (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/autocomplete_edit.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 void AutocompleteEditModel::OnControlKeyChanged(bool pressed) { 492 void AutocompleteEditModel::OnControlKeyChanged(bool pressed) {
493 // Don't change anything unless the key state is actually toggling. 493 // Don't change anything unless the key state is actually toggling.
494 if (pressed == (control_key_state_ == UP)) { 494 if (pressed == (control_key_state_ == UP)) {
495 ControlKeyState old_state = control_key_state_; 495 ControlKeyState old_state = control_key_state_;
496 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP; 496 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP;
497 if ((control_key_state_ == DOWN_WITHOUT_CHANGE) && has_temporary_text_) { 497 if ((control_key_state_ == DOWN_WITHOUT_CHANGE) && has_temporary_text_) {
498 // Arrowing down and then hitting control accepts the temporary text as 498 // Arrowing down and then hitting control accepts the temporary text as
499 // the input text. 499 // the input text.
500 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); 500 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
501 has_temporary_text_ = false; 501 has_temporary_text_ = false;
502 if (KeywordIsSelected())
503 AcceptKeyword();
502 } 504 }
503 if ((old_state != DOWN_WITH_CHANGE) && popup_->IsOpen()) { 505 if ((old_state != DOWN_WITH_CHANGE) && popup_->IsOpen()) {
504 // Autocomplete history provider results may change, so refresh the 506 // Autocomplete history provider results may change, so refresh the
505 // popup. This will force user_input_in_progress_ to true, but if the 507 // popup. This will force user_input_in_progress_ to true, but if the
506 // popup is open, that should have already been the case. 508 // popup is open, that should have already been the case.
507 view_->UpdatePopup(); 509 view_->UpdatePopup();
508 } 510 }
509 } 511 }
510 } 512 }
511 513
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if ((text_differs || selection_differs) && 623 if ((text_differs || selection_differs) &&
622 (control_key_state_ == DOWN_WITHOUT_CHANGE)) { 624 (control_key_state_ == DOWN_WITHOUT_CHANGE)) {
623 control_key_state_ = DOWN_WITH_CHANGE; 625 control_key_state_ = DOWN_WITH_CHANGE;
624 if (!text_differs && !popup_->IsOpen()) 626 if (!text_differs && !popup_->IsOpen())
625 return false; // Don't open the popup for no reason. 627 return false; // Don't open the popup for no reason.
626 } else if (!text_differs && 628 } else if (!text_differs &&
627 (inline_autocomplete_text_.empty() || !selection_differs)) { 629 (inline_autocomplete_text_.empty() || !selection_differs)) {
628 return false; 630 return false;
629 } 631 }
630 632
631 const bool had_keyword = (keyword_ui_state_ != NO_KEYWORD) && 633 const bool had_keyword = KeywordIsSelected();
632 !is_keyword_hint_ && !keyword_.empty();
633 634
634 // Modifying the selection counts as accepting the autocompleted text. 635 // Modifying the selection counts as accepting the autocompleted text.
635 InternalSetUserText(UserTextFromDisplayText(new_text)); 636 InternalSetUserText(UserTextFromDisplayText(new_text));
636 has_temporary_text_ = false; 637 has_temporary_text_ = false;
637 638
638 // Track when the user has deleted text so we won't allow inline autocomplete. 639 // Track when the user has deleted text so we won't allow inline autocomplete.
639 just_deleted_text_ = just_deleted_text; 640 just_deleted_text_ = just_deleted_text;
640 641
641 // Disable the fancy keyword UI if the user didn't already have a visible 642 // Disable the fancy keyword UI if the user didn't already have a visible
642 // keyword and is not at the end of the edit. This prevents us from showing 643 // keyword and is not at the end of the edit. This prevents us from showing
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 AutocompleteMatch* match, 741 AutocompleteMatch* match,
741 GURL* alternate_nav_url) const { 742 GURL* alternate_nav_url) const {
742 if (popup_->IsOpen() || query_in_progress()) { 743 if (popup_->IsOpen() || query_in_progress()) {
743 popup_->InfoForCurrentSelection(match, alternate_nav_url); 744 popup_->InfoForCurrentSelection(match, alternate_nav_url);
744 } else { 745 } else {
745 profile_->GetAutocompleteClassifier()->Classify( 746 profile_->GetAutocompleteClassifier()->Classify(
746 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(), match, 747 UserTextFromDisplayText(view_->GetText()), GetDesiredTLD(), match,
747 alternate_nav_url); 748 alternate_nav_url);
748 } 749 }
749 } 750 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698