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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 5966006: Hitting Tab should always move cursor to end of omnibox text. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build. Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 instant->SetCommitOnMouseUp(); 241 instant->SetCommitOnMouseUp();
242 } else { 242 } else {
243 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); 243 instant->CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST);
244 } 244 }
245 } 245 }
246 246
247 void LocationBarViewMac::OnAutocompleteWillAccept() { 247 void LocationBarViewMac::OnAutocompleteWillAccept() {
248 update_instant_ = false; 248 update_instant_ = false;
249 } 249 }
250 250
251 bool LocationBarViewMac::OnCommitSuggestedText(const string16& typed_text) { 251 bool LocationBarViewMac::OnCommitSuggestedText(bool skip_inline_autocomplete) {
252 return edit_view_->CommitSuggestText(); 252 if (!browser_->instant())
253 return false;
254
255 const string16 suggestion = edit_view_->GetInstantSuggestion();
256 if (suggestion.empty())
257 return false;
258
259 edit_view_->model()->FinalizeInstantQuery(
260 edit_view_->GetText(), suggestion, skip_inline_autocomplete);
261 return true;
253 } 262 }
254 263
255 bool LocationBarViewMac::AcceptCurrentInstantPreview() { 264 bool LocationBarViewMac::AcceptCurrentInstantPreview() {
256 return InstantController::CommitIfCurrent(browser_->instant()); 265 return InstantController::CommitIfCurrent(browser_->instant());
257 } 266 }
258 267
259 void LocationBarViewMac::OnPopupBoundsChanged(const gfx::Rect& bounds) { 268 void LocationBarViewMac::OnPopupBoundsChanged(const gfx::Rect& bounds) {
260 InstantController* instant = browser_->instant(); 269 InstantController* instant = browser_->instant();
261 if (instant) 270 if (instant)
262 instant->SetOmniboxBounds(bounds); 271 instant->SetOmniboxBounds(bounds);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 if (update_instant_ && instant && GetTabContents()) { 323 if (update_instant_ && instant && GetTabContents()) {
315 if (edit_view_->model()->user_input_in_progress() && 324 if (edit_view_->model()->user_input_in_progress() &&
316 edit_view_->model()->popup_model()->IsOpen()) { 325 edit_view_->model()->popup_model()->IsOpen()) {
317 instant->Update 326 instant->Update
318 (browser_->GetSelectedTabContentsWrapper(), 327 (browser_->GetSelectedTabContentsWrapper(),
319 edit_view_->model()->CurrentMatch(), 328 edit_view_->model()->CurrentMatch(),
320 edit_view_->GetText(), 329 edit_view_->GetText(),
321 edit_view_->model()->UseVerbatimInstant(), 330 edit_view_->model()->UseVerbatimInstant(),
322 &suggested_text); 331 &suggested_text);
323 if (!instant->MightSupportInstant()) { 332 if (!instant->MightSupportInstant()) {
324 edit_view_->model()->FinalizeInstantQuery(string16(), 333 edit_view_->model()->FinalizeInstantQuery(
325 string16()); 334 string16(), string16(), false);
326 } 335 }
327 } else { 336 } else {
328 instant->DestroyPreviewContents(); 337 instant->DestroyPreviewContents();
329 edit_view_->model()->FinalizeInstantQuery(string16(), 338 edit_view_->model()->FinalizeInstantQuery(
330 string16()); 339 string16(), string16(), false);
331 } 340 }
332 } 341 }
333 342
334 SetSuggestedText(suggested_text); 343 SetSuggestedText(suggested_text);
335 } 344 }
336 345
337 void LocationBarViewMac::OnSelectionBoundsChanged() { 346 void LocationBarViewMac::OnSelectionBoundsChanged() {
338 NOTIMPLEMENTED(); 347 NOTIMPLEMENTED();
339 } 348 }
340 349
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 690
682 // These need to change anytime the layout changes. 691 // These need to change anytime the layout changes.
683 // TODO(shess): Anytime the field editor might have changed, the 692 // TODO(shess): Anytime the field editor might have changed, the
684 // cursor rects almost certainly should have changed. The tooltips 693 // cursor rects almost certainly should have changed. The tooltips
685 // might change even when the rects don't change. 694 // might change even when the rects don't change.
686 [field_ resetFieldEditorFrameIfNeeded]; 695 [field_ resetFieldEditorFrameIfNeeded];
687 [field_ updateCursorAndToolTipRects]; 696 [field_ updateCursorAndToolTipRects];
688 697
689 [field_ setNeedsDisplay:YES]; 698 [field_ setNeedsDisplay:YES];
690 } 699 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698