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

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, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 // determine what keyword, if any, is applicable. 999 // determine what keyword, if any, is applicable.
1000 // 1000 //
1001 // If MaybeAcceptKeywordBySpace() accepts the keyword and returns true, that 1001 // If MaybeAcceptKeywordBySpace() accepts the keyword and returns true, that
1002 // will have updated our state already, so in that case we don't also return 1002 // will have updated our state already, so in that case we don't also return
1003 // true from this function. 1003 // true from this function.
1004 return !(text_differs && allow_keyword_ui_change && !just_deleted_text && 1004 return !(text_differs && allow_keyword_ui_change && !just_deleted_text &&
1005 no_selection && (selection_start == user_text_.length()) && 1005 no_selection && (selection_start == user_text_.length()) &&
1006 MaybeAcceptKeywordBySpace(user_text_)); 1006 MaybeAcceptKeywordBySpace(user_text_));
1007 } 1007 }
1008 1008
1009 void OmniboxEditModel::PopupBoundsChangedTo(const gfx::Rect& bounds) { 1009 void OmniboxEditModel::OnPopupBoundsChanged(const gfx::Rect& bounds) {
1010 InstantController* instant = controller_->GetInstant(); 1010 InstantController* instant = controller_->GetInstant();
1011 if (instant) 1011 if (instant)
1012 instant->SetOmniboxBounds(bounds); 1012 instant->SetPopupBounds(bounds);
1013 }
1014
1015 void OmniboxEditModel::OnOmniboxBoundsChanged(const gfx::Rect& bounds) {
1016 InstantController* instant = controller_->GetInstant();
1017 if (instant)
1018 instant->SetMarginSize(bounds.x(), bounds.x() + bounds.width());
1013 } 1019 }
1014 1020
1015 void OmniboxEditModel::OnResultChanged(bool default_match_changed) { 1021 void OmniboxEditModel::OnResultChanged(bool default_match_changed) {
1016 const bool was_open = popup_->IsOpen(); 1022 const bool was_open = popup_->IsOpen();
1017 if (default_match_changed) { 1023 if (default_match_changed) {
1018 string16 inline_autocomplete_text; 1024 string16 inline_autocomplete_text;
1019 string16 keyword; 1025 string16 keyword;
1020 bool is_keyword_hint = false; 1026 bool is_keyword_hint = false;
1021 const AutocompleteResult& result = this->result(); 1027 const AutocompleteResult& result = this->result();
1022 const AutocompleteResult::const_iterator match(result.default_match()); 1028 const AutocompleteResult::const_iterator match(result.default_match());
(...skipping 16 matching lines...) Expand all
1039 } 1045 }
1040 1046
1041 popup_->OnResultChanged(); 1047 popup_->OnResultChanged();
1042 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword, 1048 OnPopupDataChanged(inline_autocomplete_text, NULL, keyword,
1043 is_keyword_hint); 1049 is_keyword_hint);
1044 } else { 1050 } else {
1045 popup_->OnResultChanged(); 1051 popup_->OnResultChanged();
1046 } 1052 }
1047 1053
1048 if (popup_->IsOpen()) { 1054 if (popup_->IsOpen()) {
1049 PopupBoundsChangedTo(popup_->view()->GetTargetBounds()); 1055 OnPopupBoundsChanged(popup_->view()->GetTargetBounds());
1050 } else if (was_open) { 1056 } else if (was_open) {
1051 // 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
1052 // sense to have temporary text when the popup is closed. 1058 // sense to have temporary text when the popup is closed.
1053 InternalSetUserText(UserTextFromDisplayText(view_->GetText())); 1059 InternalSetUserText(UserTextFromDisplayText(view_->GetText()));
1054 has_temporary_text_ = false; 1060 has_temporary_text_ = false;
1055 is_temporary_text_set_by_instant_ = false; 1061 is_temporary_text_set_by_instant_ = false;
1056 PopupBoundsChangedTo(gfx::Rect()); 1062 OnPopupBoundsChanged(gfx::Rect());
1057 NotifySearchTabHelper(); 1063 NotifySearchTabHelper();
1058 } 1064 }
1059 1065
1060 if (InstantController* instant = controller_->GetInstant()) 1066 if (InstantController* instant = controller_->GetInstant())
1061 instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); 1067 instant->HandleAutocompleteResults(*autocomplete_controller_->providers());
1062 } 1068 }
1063 1069
1064 bool OmniboxEditModel::query_in_progress() const { 1070 bool OmniboxEditModel::query_in_progress() const {
1065 return !autocomplete_controller_->done(); 1071 return !autocomplete_controller_->done();
1066 } 1072 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 } 1294 }
1289 1295
1290 void OmniboxEditModel::ClassifyStringForPasteAndGo( 1296 void OmniboxEditModel::ClassifyStringForPasteAndGo(
1291 const string16& text, 1297 const string16& text,
1292 AutocompleteMatch* match, 1298 AutocompleteMatch* match,
1293 GURL* alternate_nav_url) const { 1299 GURL* alternate_nav_url) const {
1294 DCHECK(match); 1300 DCHECK(match);
1295 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text, 1301 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(text,
1296 string16(), false, false, match, alternate_nav_url); 1302 string16(), false, false, match, alternate_nav_url);
1297 } 1303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698