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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 477873002: Allow users to perform queries in the omnibox which begin with a search shortcut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment Created 5 years, 9 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 | « AUTHORS ('k') | 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/ui/omnibox/omnibox_edit_model.h" 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 has_temporary_text_ = false; 873 has_temporary_text_ = false;
874 874
875 if (user_input_in_progress_ || !in_revert_) 875 if (user_input_in_progress_ || !in_revert_)
876 delegate_->OnInputStateChanged(); 876 delegate_->OnInputStateChanged();
877 } 877 }
878 878
879 void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) { 879 void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) {
880 autocomplete_controller()->Stop(false); 880 autocomplete_controller()->Stop(false);
881 omnibox_controller_->ClearPopupKeywordMode(); 881 omnibox_controller_->ClearPopupKeywordMode();
882 882
883 const base::string16 window_text(keyword_ + visible_text); 883 // Add a space after the keyword to allow the user to continue typing without
884 // re-enabling keyword mode.
885 const base::string16 window_text =
886 keyword_ + base::ASCIIToUTF16(" ") + visible_text;
884 887
885 // Only reset the result if the edit text has changed since the 888 // Only reset the result if the edit text has changed since the
886 // keyword was accepted, or if the popup is closed. 889 // keyword was accepted, or if the popup is closed.
887 if (just_deleted_text_ || !visible_text.empty() || 890 if (just_deleted_text_ || !visible_text.empty() ||
888 !(popup_model() && popup_model()->IsOpen())) { 891 !(popup_model() && popup_model()->IsOpen())) {
889 view_->OnBeforePossibleChange(); 892 view_->OnBeforePossibleChange();
890 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 893 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1,
891 false, false); 894 false, false);
892 keyword_.clear(); 895 keyword_.clear();
893 is_keyword_hint_ = false; 896 is_keyword_hint_ = false;
894 view_->OnAfterPossibleChange(); 897 view_->OnAfterPossibleChange();
895 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this 898 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this
896 // since the edit contents have actually grown 899 // since the edit contents have actually grown
897 // longer. 900 // longer.
898 } else { 901 } else {
899 is_keyword_hint_ = true; 902 is_keyword_hint_ = true;
900 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 903 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1,
901 false, true); 904 false, true);
902 } 905 }
903 906
904 view_->UpdatePlaceholderText(); 907 view_->UpdatePlaceholderText();
905 } 908 }
906 909
907 void OmniboxEditModel::OnSetFocus(bool control_down) { 910 void OmniboxEditModel::OnSetFocus(bool control_down) {
908 last_omnibox_focus_ = base::TimeTicks::Now(); 911 last_omnibox_focus_ = base::TimeTicks::Now();
909 user_input_since_focus_ = false; 912 user_input_since_focus_ = false;
910 913
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 // Update state and notify view if the omnibox has focus and the caret 1445 // Update state and notify view if the omnibox has focus and the caret
1443 // visibility changed. 1446 // visibility changed.
1444 const bool was_caret_visible = is_caret_visible(); 1447 const bool was_caret_visible = is_caret_visible();
1445 focus_state_ = state; 1448 focus_state_ = state;
1446 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1449 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1447 is_caret_visible() != was_caret_visible) 1450 is_caret_visible() != was_caret_visible)
1448 view_->ApplyCaretVisibility(); 1451 view_->ApplyCaretVisibility();
1449 1452
1450 delegate_->OnFocusChanged(focus_state_, reason); 1453 delegate_->OnFocusChanged(focus_state_, reason);
1451 } 1454 }
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698