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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 2817403002: [Omnibox] Elide omnibox text (Closed)
Patch Set: Add comment Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/views/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 #endif 131 #endif
132 132
133 // Explicitly teardown members which have a reference to us. Just to be safe 133 // Explicitly teardown members which have a reference to us. Just to be safe
134 // we want them to be destroyed before destroying any other internal state. 134 // we want them to be destroyed before destroying any other internal state.
135 popup_view_.reset(); 135 popup_view_.reset();
136 } 136 }
137 137
138 void OmniboxViewViews::Init() { 138 void OmniboxViewViews::Init() {
139 set_controller(this); 139 set_controller(this);
140 SetTextInputType(ui::TEXT_INPUT_TYPE_URL); 140 SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
141 GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL);
141 142
142 if (popup_window_mode_) 143 if (popup_window_mode_)
143 SetReadOnly(true); 144 SetReadOnly(true);
144 145
145 if (location_bar_view_) { 146 if (location_bar_view_) {
146 // Initialize the popup view using the same font. 147 // Initialize the popup view using the same font.
147 popup_view_.reset(OmniboxPopupContentsView::Create( 148 popup_view_.reset(OmniboxPopupContentsView::Create(
148 GetFontList(), this, model(), location_bar_view_)); 149 GetFontList(), this, model(), location_bar_view_));
149 } 150 }
150 151
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 // TODO(oshima): Get control key state. 754 // TODO(oshima): Get control key state.
754 model()->OnSetFocus(false); 755 model()->OnSetFocus(false);
755 // Don't call controller()->OnSetFocus, this view has already acquired focus. 756 // Don't call controller()->OnSetFocus, this view has already acquired focus.
756 757
757 // Restore the selection we saved in OnBlur() if it's still valid. 758 // Restore the selection we saved in OnBlur() if it's still valid.
758 if (saved_selection_for_focus_change_.IsValid()) { 759 if (saved_selection_for_focus_change_.IsValid()) {
759 SelectRange(saved_selection_for_focus_change_); 760 SelectRange(saved_selection_for_focus_change_);
760 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); 761 saved_selection_for_focus_change_ = gfx::Range::InvalidRange();
761 } 762 }
762 763
764 GetRenderText()->SetElideBehavior(gfx::NO_ELIDE);
765
763 // Focus changes can affect the visibility of any keyword hint. 766 // Focus changes can affect the visibility of any keyword hint.
764 if (model()->is_keyword_hint()) 767 if (model()->is_keyword_hint())
765 location_bar_view_->Layout(); 768 location_bar_view_->Layout();
766 } 769 }
767 770
768 void OmniboxViewViews::OnBlur() { 771 void OmniboxViewViews::OnBlur() {
769 // Save the user's existing selection to restore it later. 772 // Save the user's existing selection to restore it later.
770 saved_selection_for_focus_change_ = GetSelectedRange(); 773 saved_selection_for_focus_change_ = GetSelectedRange();
771 774
772 views::Textfield::OnBlur(); 775 views::Textfield::OnBlur();
773 model()->OnWillKillFocus(); 776 model()->OnWillKillFocus();
774 777
775 // If ZeroSuggest is active, we may have refused to show an update to the 778 // If ZeroSuggest is active, we may have refused to show an update to the
776 // underlying permanent URL that happened while the popup was open, so 779 // underlying permanent URL that happened while the popup was open, so
777 // revert to ensure that update is shown now. Otherwise, make sure to call 780 // revert to ensure that update is shown now. Otherwise, make sure to call
778 // CloseOmniboxPopup() unconditionally, so that if ZeroSuggest is in the midst 781 // CloseOmniboxPopup() unconditionally, so that if ZeroSuggest is in the midst
779 // of running but hasn't yet opened the popup, it will be halted. 782 // of running but hasn't yet opened the popup, it will be halted.
780 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen()) 783 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen())
781 RevertAll(); 784 RevertAll();
782 else 785 else
783 CloseOmniboxPopup(); 786 CloseOmniboxPopup();
784 787
785 // Tell the model to reset itself. 788 // Tell the model to reset itself.
786 model()->OnKillFocus(); 789 model()->OnKillFocus();
787 790
788 // Make sure the beginning of the text is visible. 791 // Make sure the beginning of the text is visible.
789 SelectRange(gfx::Range(0)); 792 SelectRange(gfx::Range(0));
790 793
794 GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL);
795
791 // Focus changes can affect the visibility of any keyword hint. 796 // Focus changes can affect the visibility of any keyword hint.
792 if (model()->is_keyword_hint()) 797 if (model()->is_keyword_hint())
793 location_bar_view_->Layout(); 798 location_bar_view_->Layout();
794 799
795 // The location bar needs to repaint without a focus ring. 800 // The location bar needs to repaint without a focus ring.
796 location_bar_view_->SchedulePaint(); 801 location_bar_view_->SchedulePaint();
797 } 802 }
798 803
799 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { 804 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const {
800 if (command_id == IDS_APP_PASTE) 805 if (command_id == IDS_APP_PASTE)
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); 1063 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO);
1059 1064
1060 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); 1065 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
1061 1066
1062 // Minor note: We use IDC_ for command id here while the underlying textfield 1067 // Minor note: We use IDC_ for command id here while the underlying textfield
1063 // is using IDS_ for all its command ids. This is because views cannot depend 1068 // is using IDS_ for all its command ids. This is because views cannot depend
1064 // on IDC_ for now. 1069 // on IDC_ for now.
1065 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1070 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1066 IDS_EDIT_SEARCH_ENGINES); 1071 IDS_EDIT_SEARCH_ENGINES);
1067 } 1072 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698