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

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

Issue 11418144: [Search] Implementation of the invisible focus on Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@samarthlatest
Patch Set: Rebased to master instead of other change Created 8 years 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 <string> 7 #include <string>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 using content::UserMetricsAction; 63 using content::UserMetricsAction;
64 using predictors::AutocompleteActionPredictor; 64 using predictors::AutocompleteActionPredictor;
65 using predictors::AutocompleteActionPredictorFactory; 65 using predictors::AutocompleteActionPredictorFactory;
66 66
67 /////////////////////////////////////////////////////////////////////////////// 67 ///////////////////////////////////////////////////////////////////////////////
68 // OmniboxEditModel::State 68 // OmniboxEditModel::State
69 69
70 OmniboxEditModel::State::State(bool user_input_in_progress, 70 OmniboxEditModel::State::State(bool user_input_in_progress,
71 const string16& user_text, 71 const string16& user_text,
72 const string16& keyword, 72 const string16& keyword,
73 bool is_keyword_hint) 73 bool is_keyword_hint,
74 bool is_focus_visible)
74 : user_input_in_progress(user_input_in_progress), 75 : user_input_in_progress(user_input_in_progress),
75 user_text(user_text), 76 user_text(user_text),
76 keyword(keyword), 77 keyword(keyword),
77 is_keyword_hint(is_keyword_hint) { 78 is_keyword_hint(is_keyword_hint),
79 is_focus_visible(is_focus_visible) {
78 } 80 }
79 81
80 OmniboxEditModel::State::~State() { 82 OmniboxEditModel::State::~State() {
81 } 83 }
82 84
83 /////////////////////////////////////////////////////////////////////////////// 85 ///////////////////////////////////////////////////////////////////////////////
84 // OmniboxEditModel 86 // OmniboxEditModel
85 87
86 OmniboxEditModel::OmniboxEditModel(OmniboxView* view, 88 OmniboxEditModel::OmniboxEditModel(OmniboxView* view,
87 OmniboxEditController* controller, 89 OmniboxEditController* controller,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // on switching back, typing will "just work"). 123 // on switching back, typing will "just work").
122 const string16 user_text(UserTextFromDisplayText(view_->GetText())); 124 const string16 user_text(UserTextFromDisplayText(view_->GetText()));
123 if (user_text.empty()) { 125 if (user_text.empty()) {
124 view_->RevertAll(); 126 view_->RevertAll();
125 view_->SelectAll(true); 127 view_->SelectAll(true);
126 } else { 128 } else {
127 InternalSetUserText(user_text); 129 InternalSetUserText(user_text);
128 } 130 }
129 } 131 }
130 132
131 return State(user_input_in_progress_, user_text_, keyword_, is_keyword_hint_); 133 return State(user_input_in_progress_, user_text_, keyword_, is_keyword_hint_,
134 is_focus_visible_);
132 } 135 }
133 136
134 void OmniboxEditModel::RestoreState(const State& state) { 137 void OmniboxEditModel::RestoreState(const State& state) {
138 is_focus_visible_ = state.is_focus_visible;
135 // Restore any user editing. 139 // Restore any user editing.
136 if (state.user_input_in_progress) { 140 if (state.user_input_in_progress) {
137 // NOTE: Be sure and set keyword-related state BEFORE invoking 141 // NOTE: Be sure and set keyword-related state BEFORE invoking
138 // DisplayTextFromUserText(), as its result depends upon this state. 142 // DisplayTextFromUserText(), as its result depends upon this state.
139 keyword_ = state.keyword; 143 keyword_ = state.keyword;
140 is_keyword_hint_ = state.is_keyword_hint; 144 is_keyword_hint_ = state.is_keyword_hint;
141 view_->SetUserText(state.user_text, 145 view_->SetUserText(state.user_text,
142 DisplayTextFromUserText(state.user_text), false); 146 DisplayTextFromUserText(state.user_text), false);
143 } 147 }
144 } 148 }
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 if (InstantController* instant = controller_->GetInstant()) 742 if (InstantController* instant = controller_->GetInstant())
739 instant->OmniboxLostFocus(view_gaining_focus); 743 instant->OmniboxLostFocus(view_gaining_focus);
740 744
741 // TODO(jered): Rip this out along with StartZeroSuggest. 745 // TODO(jered): Rip this out along with StartZeroSuggest.
742 autocomplete_controller_->StopZeroSuggest(); 746 autocomplete_controller_->StopZeroSuggest();
743 NotifySearchTabHelper(); 747 NotifySearchTabHelper();
744 } 748 }
745 749
746 void OmniboxEditModel::OnKillFocus() { 750 void OmniboxEditModel::OnKillFocus() {
747 has_focus_ = false; 751 has_focus_ = false;
752 is_focus_visible_ = true;
748 control_key_state_ = UP; 753 control_key_state_ = UP;
749 paste_state_ = NONE; 754 paste_state_ = NONE;
750 } 755 }
751 756
752 bool OmniboxEditModel::OnEscapeKeyPressed() { 757 bool OmniboxEditModel::OnEscapeKeyPressed() {
753 if (has_temporary_text_) { 758 if (has_temporary_text_) {
754 AutocompleteMatch match; 759 AutocompleteMatch match;
755 InfoForCurrentSelection(&match, NULL); 760 InfoForCurrentSelection(&match, NULL);
756 if (match.destination_url != original_url_) { 761 if (match.destination_url != original_url_) {
757 RevertTemporaryText(true); 762 RevertTemporaryText(true);
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 } 1276 }
1272 1277
1273 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1278 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1274 const string16& text, 1279 const string16& text,
1275 AutocompleteMatch* match, 1280 AutocompleteMatch* match,
1276 GURL* alternate_nav_url) const { 1281 GURL* alternate_nav_url) const {
1277 DCHECK(match); 1282 DCHECK(match);
1278 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1283 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1279 string16(), false, false, match, alternate_nav_url); 1284 string16(), false, false, match, alternate_nav_url);
1280 } 1285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698