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

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

Issue 11359198: Implement the Instant extended API startMargin, endMargin, and rtl properties and the onmarginchang… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 // determine what keyword, if any, is applicable. 1006 // determine what keyword, if any, is applicable.
1007 // 1007 //
1008 // If MaybeAcceptKeywordBySpace() accepts the keyword and returns true, that 1008 // If MaybeAcceptKeywordBySpace() accepts the keyword and returns true, that
1009 // will have updated our state already, so in that case we don't also return 1009 // will have updated our state already, so in that case we don't also return
1010 // true from this function. 1010 // true from this function.
1011 return !(text_differs && allow_keyword_ui_change && !just_deleted_text && 1011 return !(text_differs && allow_keyword_ui_change && !just_deleted_text &&
1012 no_selection && (selection_start == user_text_.length()) && 1012 no_selection && (selection_start == user_text_.length()) &&
1013 MaybeAcceptKeywordBySpace(user_text_)); 1013 MaybeAcceptKeywordBySpace(user_text_));
1014 } 1014 }
1015 1015
1016 void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { 1016 void OmniboxEditModel::OnPopupBoundsChanged(const gfx::Rect& bounds) {
1017 if (InstantController* instant = controller_->GetInstant()) 1017 if (InstantController* instant = controller_->GetInstant())
1018 instant->SetOmniboxBounds(bounds); 1018 instant->SetPopupBounds(bounds);
1019 } 1019 }
1020 1020
1021 void OmniboxEditModel::OnResultChanged(bool default_match_changed) { 1021 void OmniboxEditModel::OnResultChanged(bool default_match_changed) {
1022 const bool was_open = popup_->IsOpen(); 1022 const bool was_open = popup_->IsOpen();
1023 if (default_match_changed) { 1023 if (default_match_changed) {
1024 string16 inline_autocomplete_text; 1024 string16 inline_autocomplete_text;
1025 string16 keyword; 1025 string16 keyword;
1026 bool is_keyword_hint = false; 1026 bool is_keyword_hint = false;
1027 const AutocompleteResult& result = this->result(); 1027 const AutocompleteResult& result = this->result();
1028 const AutocompleteResult::const_iterator match(result.default_match()); 1028 const AutocompleteResult::const_iterator match(result.default_match());
(...skipping 16 matching lines...) Expand all
1045 } 1045 }
1046 1046
1047 popup_->OnResultChanged(); 1047 popup_->OnResultChanged();
1048 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, 1048 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword,
1049 is_keyword_hint); 1049 is_keyword_hint);
1050 } else { 1050 } else {
1051 popup_->OnResultChanged(); 1051 popup_->OnResultChanged();
1052 } 1052 }
1053 1053
1054 if (popup_->IsOpen()) { 1054 if (popup_->IsOpen()) {
1055 PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); 1055 OnPopupBoundsChanged(popup_->view()->GetTargetBounds());
1056 } else if (was_open) { 1056 } else if (was_open) {
1057 // Accepts the temporary text as the user text, because it makes little 1057 // Accepts the temporary text as the user text, because it makes little
1058 // sense to have temporary text when the popup is closed. 1058 // sense to have temporary text when the popup is closed.
1059 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); 1059 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
1060 has_temporary_text_ = false; 1060 has_temporary_text_ = false;
1061 is_temporary_text_set_by_instant_ = false; 1061 is_temporary_text_set_by_instant_ = false;
1062 PopupBoundsChangedTo(gfx::Rect()); 1062 OnPopupBoundsChanged(gfx::Rect());
1063 NotifySearchTabHelper(); 1063 NotifySearchTabHelper();
1064 } 1064 }
1065 1065
1066 if (InstantController* instant = controller_->GetInstant()) 1066 if (InstantController* instant = controller_->GetInstant())
1067 instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); 1067 instant->HandleAutocompleteResults(*autocomplete_controller_->providers());
1068 } 1068 }
1069 1069
1070 bool OmniboxEditModel::query_in_progress() const { 1070 bool OmniboxEditModel::query_in_progress() const {
1071 return !autocomplete_controller_->done(); 1071 return !autocomplete_controller_->done();
1072 } 1072 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 } 1281 }
1282 1282
1283 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1283 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1284 const string16& text, 1284 const string16& text,
1285 AutocompleteMatch* match, 1285 AutocompleteMatch* match,
1286 GURL* alternate_nav_url) const { 1286 GURL* alternate_nav_url) const {
1287 DCHECK(match); 1287 DCHECK(match);
1288 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1288 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1289 string16(), false, false, match, alternate_nav_url); 1289 string16(), false, false, match, alternate_nav_url);
1290 } 1290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698