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

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

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 const AutocompleteMatch& match = CurrentMatch(NULL); 928 const AutocompleteMatch& match = CurrentMatch(NULL);
929 original_url_ = match.destination_url; 929 original_url_ = match.destination_url;
930 view_->OnTemporaryTextMaybeChanged( 930 view_->OnTemporaryTextMaybeChanged(
931 DisplayTextFromUserText(match.fill_into_edit), 931 DisplayTextFromUserText(match.fill_into_edit),
932 save_original_selection, true); 932 save_original_selection, true);
933 } else { 933 } else {
934 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(user_text_), 934 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(user_text_),
935 false, true); 935 false, true);
936 } 936 }
937 937
938 view_->UpdatePlaceholderText();
939
940 content::RecordAction(base::UserMetricsAction("AcceptedKeywordHint")); 938 content::RecordAction(base::UserMetricsAction("AcceptedKeywordHint"));
941 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram, entered_method, 939 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram, entered_method,
942 ENTERED_KEYWORD_MODE_NUM_ITEMS); 940 ENTERED_KEYWORD_MODE_NUM_ITEMS);
943 941
944 return true; 942 return true;
945 } 943 }
946 944
947 void OmniboxEditModel::AcceptTemporaryTextAsUserText() { 945 void OmniboxEditModel::AcceptTemporaryTextAsUserText() {
948 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); 946 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
949 has_temporary_text_ = false; 947 has_temporary_text_ = false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 979 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(),
982 false, true); 980 false, true);
983 } else { 981 } else {
984 view_->OnBeforePossibleChange(); 982 view_->OnBeforePossibleChange();
985 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), 983 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(),
986 false, false); 984 false, false);
987 keyword_.clear(); 985 keyword_.clear();
988 is_keyword_hint_ = false; 986 is_keyword_hint_ = false;
989 view_->OnAfterPossibleChange(); 987 view_->OnAfterPossibleChange();
990 } 988 }
991
992 view_->UpdatePlaceholderText();
993 } 989 }
994 990
995 void OmniboxEditModel::OnSetFocus(bool control_down) { 991 void OmniboxEditModel::OnSetFocus(bool control_down) {
996 last_omnibox_focus_ = base::TimeTicks::Now(); 992 last_omnibox_focus_ = base::TimeTicks::Now();
997 user_input_since_focus_ = false; 993 user_input_since_focus_ = false;
998 994
999 // If the omnibox lost focus while the caret was hidden and then regained 995 // If the omnibox lost focus while the caret was hidden and then regained
1000 // focus, OnSetFocus() is called and should restore visibility. Note that 996 // focus, OnSetFocus() is called and should restore visibility. Note that
1001 // focus can be regained without an accompanying call to 997 // focus can be regained without an accompanying call to
1002 // OmniboxView::SetFocus(), e.g. by tabbing in. 998 // OmniboxView::SetFocus(), e.g. by tabbing in.
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 // if the user hit space in mid-string after a keyword. 1288 // if the user hit space in mid-string after a keyword.
1293 // |allow_exact_keyword_match_| will be used by StartAutocomplete() method, 1289 // |allow_exact_keyword_match_| will be used by StartAutocomplete() method,
1294 // which will be called by |view_->UpdatePopup()|; so after that returns we 1290 // which will be called by |view_->UpdatePopup()|; so after that returns we
1295 // can safely reset this flag. 1291 // can safely reset this flag.
1296 allow_exact_keyword_match_ = text_differs && allow_keyword_ui_change && 1292 allow_exact_keyword_match_ = text_differs && allow_keyword_ui_change &&
1297 !just_deleted_text && no_selection && 1293 !just_deleted_text && no_selection &&
1298 CreatedKeywordSearchByInsertingSpaceInMiddle(old_text, user_text_, 1294 CreatedKeywordSearchByInsertingSpaceInMiddle(old_text, user_text_,
1299 selection_start); 1295 selection_start);
1300 view_->UpdatePopup(); 1296 view_->UpdatePopup();
1301 if (allow_exact_keyword_match_) { 1297 if (allow_exact_keyword_match_) {
1302 view_->UpdatePlaceholderText();
1303 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram, 1298 UMA_HISTOGRAM_ENUMERATION(kEnteredKeywordModeHistogram,
1304 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE, 1299 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE,
1305 ENTERED_KEYWORD_MODE_NUM_ITEMS); 1300 ENTERED_KEYWORD_MODE_NUM_ITEMS);
1306 allow_exact_keyword_match_ = false; 1301 allow_exact_keyword_match_ = false;
1307 } 1302 }
1308 1303
1309 // Change to keyword mode if the user is now pressing space after a keyword 1304 // Change to keyword mode if the user is now pressing space after a keyword
1310 // name. Note that if this is the case, then even if there was no keyword 1305 // name. Note that if this is the case, then even if there was no keyword
1311 // hint when we entered this function (e.g. if the user has used space to 1306 // hint when we entered this function (e.g. if the user has used space to
1312 // replace some selected text that was adjoined to this keyword), there will 1307 // replace some selected text that was adjoined to this keyword), there will
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 // Update state and notify view if the omnibox has focus and the caret 1534 // Update state and notify view if the omnibox has focus and the caret
1540 // visibility changed. 1535 // visibility changed.
1541 const bool was_caret_visible = is_caret_visible(); 1536 const bool was_caret_visible = is_caret_visible();
1542 focus_state_ = state; 1537 focus_state_ = state;
1543 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1538 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1544 is_caret_visible() != was_caret_visible) 1539 is_caret_visible() != was_caret_visible)
1545 view_->ApplyCaretVisibility(); 1540 view_->ApplyCaretVisibility();
1546 1541
1547 delegate_->OnFocusChanged(focus_state_, reason); 1542 delegate_->OnFocusChanged(focus_state_, reason);
1548 } 1543 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/network_profile_bubble.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698