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

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: Use ASCIIToUTF16 to create string16 Created 6 years, 4 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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 has_temporary_text_ = false; 893 has_temporary_text_ = false;
894 894
895 if (user_input_in_progress_ || !in_revert_) 895 if (user_input_in_progress_ || !in_revert_)
896 delegate_->OnInputStateChanged(); 896 delegate_->OnInputStateChanged();
897 } 897 }
898 898
899 void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) { 899 void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) {
900 autocomplete_controller()->Stop(false); 900 autocomplete_controller()->Stop(false);
901 omnibox_controller_->ClearPopupKeywordMode(); 901 omnibox_controller_->ClearPopupKeywordMode();
902 902
903 const base::string16 window_text(keyword_ + visible_text); 903 // Add a space after the keyword to allow the user to continue typing without
904 // re-enabling keyword mode (http://crbug.com/393371)
Peter Kasting 2014/08/22 00:41:13 Nit: Don't refer to bugs in code comments. Provid
905 const base::string16 window_text(keyword_ + base::ASCIIToUTF16(" ") +
Peter Kasting 2014/08/22 00:41:12 Nit: Break after initial '(' instead; consider usi
906 visible_text);
Peter Kasting 2014/08/22 00:41:12 Nit: Continuations of previous lines are indented
904 907
905 // Only reset the result if the edit text has changed since the 908 // Only reset the result if the edit text has changed since the
906 // keyword was accepted, or if the popup is closed. 909 // keyword was accepted, or if the popup is closed.
907 if (just_deleted_text_ || !visible_text.empty() || 910 if (just_deleted_text_ || !visible_text.empty() ||
908 !(popup_model() && popup_model()->IsOpen())) { 911 !(popup_model() && popup_model()->IsOpen())) {
909 view_->OnBeforePossibleChange(); 912 view_->OnBeforePossibleChange();
910 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 913 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1,
911 false, false); 914 false, false);
912 keyword_.clear(); 915 keyword_.clear();
913 is_keyword_hint_ = false; 916 is_keyword_hint_ = false;
914 view_->OnAfterPossibleChange(); 917 view_->OnAfterPossibleChange();
915 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this 918 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this
916 // since the edit contents have actually grown 919 // since the edit contents have actually grown
917 // longer. 920 // longer.
918 } else { 921 } else {
919 is_keyword_hint_ = true; 922 is_keyword_hint_ = true;
920 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 923 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1,
921 false, true); 924 false, true);
922 } 925 }
923 926
924 view_->UpdatePlaceholderText(); 927 view_->UpdatePlaceholderText();
925 } 928 }
926 929
927 void OmniboxEditModel::OnSetFocus(bool control_down) { 930 void OmniboxEditModel::OnSetFocus(bool control_down) {
928 last_omnibox_focus_ = base::TimeTicks::Now(); 931 last_omnibox_focus_ = base::TimeTicks::Now();
929 user_input_since_focus_ = false; 932 user_input_since_focus_ = false;
930 933
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 // Update state and notify view if the omnibox has focus and the caret 1478 // Update state and notify view if the omnibox has focus and the caret
1476 // visibility changed. 1479 // visibility changed.
1477 const bool was_caret_visible = is_caret_visible(); 1480 const bool was_caret_visible = is_caret_visible();
1478 focus_state_ = state; 1481 focus_state_ = state;
1479 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1482 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1480 is_caret_visible() != was_caret_visible) 1483 is_caret_visible() != was_caret_visible)
1481 view_->ApplyCaretVisibility(); 1484 view_->ApplyCaretVisibility();
1482 1485
1483 delegate_->OnFocusChanged(focus_state_, reason); 1486 delegate_->OnFocusChanged(focus_state_, reason);
1484 } 1487 }
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