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

Side by Side Diff: chrome/browser/ui/gtk/location_bar_view_gtk.cc

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, 11 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 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 451
452 InstantController* instant = browser_->instant(); 452 InstantController* instant = browser_->instant();
453 if (instant) 453 if (instant)
454 instant->OnAutocompleteLostFocus(view_gaining_focus); 454 instant->OnAutocompleteLostFocus(view_gaining_focus);
455 } 455 }
456 456
457 void LocationBarViewGtk::OnAutocompleteWillAccept() { 457 void LocationBarViewGtk::OnAutocompleteWillAccept() {
458 update_instant_ = false; 458 update_instant_ = false;
459 } 459 }
460 460
461 bool LocationBarViewGtk::OnCommitSuggestedText( 461 bool LocationBarViewGtk::OnCommitSuggestedText(bool skip_inline_autocomplete) {
462 const string16& typed_text) { 462 if (!browser_->instant())
463 return browser_->instant() && location_entry_->CommitInstantSuggestion(); 463 return false;
464
465 const string16 suggestion = location_entry_->GetInstantSuggestion();
466 if (suggestion.empty())
467 return false;
468
469 location_entry_->model()->FinalizeInstantQuery(
470 location_entry_->GetText(), suggestion, skip_inline_autocomplete);
471 return true;
464 } 472 }
465 473
466 bool LocationBarViewGtk::AcceptCurrentInstantPreview() { 474 bool LocationBarViewGtk::AcceptCurrentInstantPreview() {
467 return InstantController::CommitIfCurrent(browser_->instant()); 475 return InstantController::CommitIfCurrent(browser_->instant());
468 } 476 }
469 477
470 void LocationBarViewGtk::OnPopupBoundsChanged(const gfx::Rect& bounds) { 478 void LocationBarViewGtk::OnPopupBoundsChanged(const gfx::Rect& bounds) {
471 InstantController* instant = browser_->instant(); 479 InstantController* instant = browser_->instant();
472 if (instant) 480 if (instant)
473 instant->SetOmniboxBounds(bounds); 481 instant->SetOmniboxBounds(bounds);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 if (update_instant_ && instant && GetTabContents()) { 539 if (update_instant_ && instant && GetTabContents()) {
532 if (location_entry_->model()->user_input_in_progress() && 540 if (location_entry_->model()->user_input_in_progress() &&
533 location_entry_->model()->popup_model()->IsOpen()) { 541 location_entry_->model()->popup_model()->IsOpen()) {
534 instant->Update( 542 instant->Update(
535 browser_->GetSelectedTabContentsWrapper(), 543 browser_->GetSelectedTabContentsWrapper(),
536 location_entry_->model()->CurrentMatch(), 544 location_entry_->model()->CurrentMatch(),
537 location_entry_->GetText(), 545 location_entry_->GetText(),
538 location_entry_->model()->UseVerbatimInstant(), 546 location_entry_->model()->UseVerbatimInstant(),
539 &suggested_text); 547 &suggested_text);
540 if (!instant->MightSupportInstant()) { 548 if (!instant->MightSupportInstant()) {
541 location_entry_->model()->FinalizeInstantQuery(string16(), 549 location_entry_->model()->FinalizeInstantQuery(
542 string16()); 550 string16(), string16(), false);
543 } 551 }
544 } else { 552 } else {
545 instant->DestroyPreviewContents(); 553 instant->DestroyPreviewContents();
546 location_entry_->model()->FinalizeInstantQuery(string16(), 554 location_entry_->model()->FinalizeInstantQuery(
547 string16()); 555 string16(), string16(), false);
548 } 556 }
549 } 557 }
550 558
551 SetSuggestedText(suggested_text); 559 SetSuggestedText(suggested_text);
552 } 560 }
553 561
554 void LocationBarViewGtk::OnSelectionBoundsChanged() { 562 void LocationBarViewGtk::OnSelectionBoundsChanged() {
555 NOTIMPLEMENTED(); 563 NOTIMPLEMENTED();
556 } 564 }
557 565
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 628
621 void LocationBarViewGtk::SetSuggestedText(const string16& text) { 629 void LocationBarViewGtk::SetSuggestedText(const string16& text) {
622 if (CommandLine::ForCurrentProcess()->HasSwitch( 630 if (CommandLine::ForCurrentProcess()->HasSwitch(
623 switches::kInstantAutocompleteImmediately)) { 631 switches::kInstantAutocompleteImmediately)) {
624 // This method is internally invoked to reset suggest text, so we only do 632 // This method is internally invoked to reset suggest text, so we only do
625 // anything if the text isn't empty. 633 // anything if the text isn't empty.
626 // TODO: if we keep autocomplete, make it so this isn't invoked with empty 634 // TODO: if we keep autocomplete, make it so this isn't invoked with empty
627 // text. 635 // text.
628 if (!text.empty()) { 636 if (!text.empty()) {
629 location_entry_->model()->FinalizeInstantQuery( 637 location_entry_->model()->FinalizeInstantQuery(
630 location_entry_->GetText(), text); 638 location_entry_->GetText(), text, false);
631 } 639 }
632 } else { 640 } else {
633 location_entry_->SetInstantSuggestion(text); 641 location_entry_->SetInstantSuggestion(text);
634 } 642 }
635 } 643 }
636 644
637 std::wstring LocationBarViewGtk::GetInputString() const { 645 std::wstring LocationBarViewGtk::GetInputString() const {
638 return location_input_; 646 return location_input_;
639 } 647 }
640 648
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 1551
1544 std::string badge_text = page_action_->GetBadgeText(tab_id); 1552 std::string badge_text = page_action_->GetBadgeText(tab_id);
1545 if (badge_text.empty()) 1553 if (badge_text.empty())
1546 return FALSE; 1554 return FALSE;
1547 1555
1548 gfx::CanvasSkiaPaint canvas(event, false); 1556 gfx::CanvasSkiaPaint canvas(event, false);
1549 gfx::Rect bounding_rect(widget->allocation); 1557 gfx::Rect bounding_rect(widget->allocation);
1550 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); 1558 page_action_->PaintBadge(&canvas, bounding_rect, tab_id);
1551 return FALSE; 1559 return FALSE;
1552 } 1560 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698