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

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

Issue 2817403002: [Omnibox] Elide omnibox text (Closed)
Patch Set: Address pkasting's review 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 InsertOrReplaceText(action_data.value); 744 InsertOrReplaceText(action_data.value);
744 TextChanged(); 745 TextChanged();
745 return true; 746 return true;
746 } 747 }
747 748
748 return Textfield::HandleAccessibleAction(action_data); 749 return Textfield::HandleAccessibleAction(action_data);
749 } 750 }
750 751
751 void OmniboxViewViews::OnFocus() { 752 void OmniboxViewViews::OnFocus() {
752 views::Textfield::OnFocus(); 753 views::Textfield::OnFocus();
754 GetRenderText()->SetElideBehavior(gfx::NO_ELIDE);
Peter Kasting 2017/04/17 20:00:03 Nit: Now that I think about it I might move these
simonhong 2017/04/17 20:06:34 Done.
753 // TODO(oshima): Get control key state. 755 // TODO(oshima): Get control key state.
754 model()->OnSetFocus(false); 756 model()->OnSetFocus(false);
755 // Don't call controller()->OnSetFocus, this view has already acquired focus. 757 // Don't call controller()->OnSetFocus, this view has already acquired focus.
756 758
757 // Restore the selection we saved in OnBlur() if it's still valid. 759 // Restore the selection we saved in OnBlur() if it's still valid.
758 if (saved_selection_for_focus_change_.IsValid()) { 760 if (saved_selection_for_focus_change_.IsValid()) {
759 SelectRange(saved_selection_for_focus_change_); 761 SelectRange(saved_selection_for_focus_change_);
760 saved_selection_for_focus_change_ = gfx::Range::InvalidRange(); 762 saved_selection_for_focus_change_ = gfx::Range::InvalidRange();
761 } 763 }
762 764
763 // Focus changes can affect the visibility of any keyword hint. 765 // Focus changes can affect the visibility of any keyword hint.
764 if (model()->is_keyword_hint()) 766 if (model()->is_keyword_hint())
765 location_bar_view_->Layout(); 767 location_bar_view_->Layout();
766 } 768 }
767 769
768 void OmniboxViewViews::OnBlur() { 770 void OmniboxViewViews::OnBlur() {
769 // Save the user's existing selection to restore it later. 771 // Save the user's existing selection to restore it later.
770 saved_selection_for_focus_change_ = GetSelectedRange(); 772 saved_selection_for_focus_change_ = GetSelectedRange();
771 773
772 views::Textfield::OnBlur(); 774 views::Textfield::OnBlur();
775 GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL);
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
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); 1061 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO);
1059 1062
1060 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); 1063 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
1061 1064
1062 // Minor note: We use IDC_ for command id here while the underlying textfield 1065 // 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 1066 // is using IDS_ for all its command ids. This is because views cannot depend
1064 // on IDC_ for now. 1067 // on IDC_ for now.
1065 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1068 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1066 IDS_EDIT_SEARCH_ENGINES); 1069 IDS_EDIT_SEARCH_ENGINES);
1067 } 1070 }
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