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

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

Issue 1104513003: Omnibox: Remove Hint Text Code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed WITH_DEFAULT_SEARCH_PROVIDER part of string Created 5 years, 8 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
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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 // so that moving to another line and then reverting the text will restore 906 // so that moving to another line and then reverting the text will restore
907 // the current state properly. 907 // the current state properly.
908 bool save_original_selection = !has_temporary_text_; 908 bool save_original_selection = !has_temporary_text_;
909 has_temporary_text_ = true; 909 has_temporary_text_ = true;
910 const AutocompleteMatch& match = CurrentMatch(NULL); 910 const AutocompleteMatch& match = CurrentMatch(NULL);
911 original_url_ = match.destination_url; 911 original_url_ = match.destination_url;
912 view_->OnTemporaryTextMaybeChanged( 912 view_->OnTemporaryTextMaybeChanged(
913 DisplayTextFromUserText(match.fill_into_edit), 913 DisplayTextFromUserText(match.fill_into_edit),
914 save_original_selection, true); 914 save_original_selection, true);
915 915
916 view_->UpdatePlaceholderText();
917
918 content::RecordAction(base::UserMetricsAction("AcceptedKeywordHint")); 916 content::RecordAction(base::UserMetricsAction("AcceptedKeywordHint"));
919 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram, entered_method, 917 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram, entered_method,
920 ENTERED_KEYWORD_MODE_NUM_ITEMS); 918 ENTERED_KEYWORD_MODE_NUM_ITEMS);
921 919
922 return true; 920 return true;
923 } 921 }
924 922
925 void OmniboxEditModel::AcceptTemporaryTextAsUserText() { 923 void OmniboxEditModel::AcceptTemporaryTextAsUserText() {
926 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); 924 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
927 has_temporary_text_ = false; 925 has_temporary_text_ = false;
(...skipping 19 matching lines...) Expand all
947 is_keyword_hint_ = false; 945 is_keyword_hint_ = false;
948 view_->OnAfterPossibleChange(); 946 view_->OnAfterPossibleChange();
949 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this 947 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this
950 // since the edit contents have actually grown 948 // since the edit contents have actually grown
951 // longer. 949 // longer.
952 } else { 950 } else {
953 is_keyword_hint_ = true; 951 is_keyword_hint_ = true;
954 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 952 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(),
955 false, true); 953 false, true);
956 } 954 }
957
958 view_->UpdatePlaceholderText();
959 } 955 }
960 956
961 void OmniboxEditModel::OnSetFocus(bool control_down) { 957 void OmniboxEditModel::OnSetFocus(bool control_down) {
962 last_omnibox_focus_ = base::TimeTicks::Now(); 958 last_omnibox_focus_ = base::TimeTicks::Now();
963 user_input_since_focus_ = false; 959 user_input_since_focus_ = false;
964 960
965 // If the omnibox lost focus while the caret was hidden and then regained 961 // If the omnibox lost focus while the caret was hidden and then regained
966 // focus, OnSetFocus() is called and should restore visibility. Note that 962 // focus, OnSetFocus() is called and should restore visibility. Note that
967 // focus can be regained without an accompanying call to 963 // focus can be regained without an accompanying call to
968 // OmniboxView::SetFocus(), e.g. by tabbing in. 964 // OmniboxView::SetFocus(), e.g. by tabbing in.
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 // if the user hit space in mid-string after a keyword. 1254 // if the user hit space in mid-string after a keyword.
1259 // |allow_exact_keyword_match_| will be used by StartAutocomplete() method, 1255 // |allow_exact_keyword_match_| will be used by StartAutocomplete() method,
1260 // which will be called by |view_->UpdatePopup()|; so after that returns we 1256 // which will be called by |view_->UpdatePopup()|; so after that returns we
1261 // can safely reset this flag. 1257 // can safely reset this flag.
1262 allow_exact_keyword_match_ = text_differs && allow_keyword_ui_change && 1258 allow_exact_keyword_match_ = text_differs && allow_keyword_ui_change &&
1263 !just_deleted_text && no_selection && 1259 !just_deleted_text && no_selection &&
1264 CreatedKeywordSearchByInsertingSpaceInMiddle(old_text, user_text_, 1260 CreatedKeywordSearchByInsertingSpaceInMiddle(old_text, user_text_,
1265 selection_start); 1261 selection_start);
1266 view_->UpdatePopup(); 1262 view_->UpdatePopup();
1267 if (allow_exact_keyword_match_) { 1263 if (allow_exact_keyword_match_) {
1268 view_->UpdatePlaceholderText();
1269 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram, 1264 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram,
1270 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE, 1265 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE,
1271 ENTERED_KEYWORD_MODE_NUM_ITEMS); 1266 ENTERED_KEYWORD_MODE_NUM_ITEMS);
1272 allow_exact_keyword_match_ = false; 1267 allow_exact_keyword_match_ = false;
1273 } 1268 }
1274 1269
1275 // Change to keyword mode if the user is now pressing space after a keyword 1270 // Change to keyword mode if the user is now pressing space after a keyword
1276 // name. Note that if this is the case, then even if there was no keyword 1271 // name. Note that if this is the case, then even if there was no keyword
1277 // hint when we entered this function (e.g. if the user has used space to 1272 // hint when we entered this function (e.g. if the user has used space to
1278 // replace some selected text that was adjoined to this keyword), there will 1273 // replace some selected text that was adjoined to this keyword), there will
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 // Update state and notify view if the omnibox has focus and the caret 1501 // Update state and notify view if the omnibox has focus and the caret
1507 // visibility changed. 1502 // visibility changed.
1508 const bool was_caret_visible = is_caret_visible(); 1503 const bool was_caret_visible = is_caret_visible();
1509 focus_state_ = state; 1504 focus_state_ = state;
1510 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1505 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1511 is_caret_visible() != was_caret_visible) 1506 is_caret_visible() != was_caret_visible)
1512 view_->ApplyCaretVisibility(); 1507 view_->ApplyCaretVisibility();
1513 1508
1514 delegate_->OnFocusChanged(focus_state_, reason); 1509 delegate_->OnFocusChanged(focus_state_, reason);
1515 } 1510 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm ('k') | chrome/browser/ui/omnibox/omnibox_edit_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698