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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_impl.cc

Issue 12556002: Always Close the Autofill UI through the same path (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Disable Test On Linux Created 7 years, 9 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
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/autofill/autofill_popup_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 AutofillPopupControllerImpl::AutofillPopupControllerImpl( 94 AutofillPopupControllerImpl::AutofillPopupControllerImpl(
95 AutofillPopupDelegate* delegate, 95 AutofillPopupDelegate* delegate,
96 gfx::NativeView container_view, 96 gfx::NativeView container_view,
97 const gfx::RectF& element_bounds) 97 const gfx::RectF& element_bounds)
98 : view_(NULL), 98 : view_(NULL),
99 delegate_(delegate), 99 delegate_(delegate),
100 container_view_(container_view), 100 container_view_(container_view),
101 element_bounds_(element_bounds), 101 element_bounds_(element_bounds),
102 selected_line_(kNoSelection), 102 selected_line_(kNoSelection),
103 is_hiding_(false),
104 weak_ptr_factory_(this) { 103 weak_ptr_factory_(this) {
105 #if !defined(OS_ANDROID) 104 #if !defined(OS_ANDROID)
106 subtext_font_ = name_font_.DeriveFont(kLabelFontSizeDelta); 105 subtext_font_ = name_font_.DeriveFont(kLabelFontSizeDelta);
107 warning_font_ = name_font_.DeriveFont(0, gfx::Font::ITALIC); 106 warning_font_ = name_font_.DeriveFont(0, gfx::Font::ITALIC);
108 #endif 107 #endif
109 } 108 }
110 109
111 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {} 110 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {}
112 111
113 void AutofillPopupControllerImpl::Show( 112 void AutofillPopupControllerImpl::Show(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 view_ = AutofillPopupView::Create(this); 159 view_ = AutofillPopupView::Create(this);
161 ShowView(); 160 ShowView();
162 } else { 161 } else {
163 UpdateBoundsAndRedrawPopup(); 162 UpdateBoundsAndRedrawPopup();
164 } 163 }
165 164
166 delegate_->OnPopupShown(this); 165 delegate_->OnPopupShown(this);
167 } 166 }
168 167
169 void AutofillPopupControllerImpl::Hide() { 168 void AutofillPopupControllerImpl::Hide() {
170 if (is_hiding_)
171 return;
172 is_hiding_ = true;
173
174 SetSelectedLine(kNoSelection); 169 SetSelectedLine(kNoSelection);
175 170
176 delegate_->OnPopupHidden(this); 171 delegate_->OnPopupHidden(this);
177 172
178 if (view_) 173 if (view_)
179 view_->Hide(); 174 view_->Hide();
180 else 175
181 delete this; 176 delete this;
182 } 177 }
183 178
184 bool AutofillPopupControllerImpl::HandleKeyPressEvent( 179 bool AutofillPopupControllerImpl::HandleKeyPressEvent(
185 const content::NativeWebKeyboardEvent& event) { 180 const content::NativeWebKeyboardEvent& event) {
186 switch (event.windowsKeyCode) { 181 switch (event.windowsKeyCode) {
187 case ui::VKEY_UP: 182 case ui::VKEY_UP:
188 SelectPreviousLine(); 183 SelectPreviousLine();
189 return true; 184 return true;
190 case ui::VKEY_DOWN: 185 case ui::VKEY_DOWN:
191 SelectNextLine(); 186 SelectNextLine();
(...skipping 10 matching lines...) Expand all
202 case ui::VKEY_DELETE: 197 case ui::VKEY_DELETE:
203 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) && 198 return (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) &&
204 RemoveSelectedLine(); 199 RemoveSelectedLine();
205 case ui::VKEY_RETURN: 200 case ui::VKEY_RETURN:
206 return AcceptSelectedLine(); 201 return AcceptSelectedLine();
207 default: 202 default:
208 return false; 203 return false;
209 } 204 }
210 } 205 }
211 206
212 void AutofillPopupControllerImpl::ViewDestroyed() {
213 delete this;
214 }
215
216 void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() { 207 void AutofillPopupControllerImpl::UpdateBoundsAndRedrawPopup() {
217 #if !defined(OS_ANDROID) 208 #if !defined(OS_ANDROID)
218 // TODO(csharp): Since UpdatePopupBounds can change the position of the popup, 209 // TODO(csharp): Since UpdatePopupBounds can change the position of the popup,
219 // the popup could end up jumping from above the element to below it. 210 // the popup could end up jumping from above the element to below it.
220 // It is unclear if it is better to keep the popup where it was, or if it 211 // It is unclear if it is better to keep the popup where it was, or if it
221 // should try and move to its desired position. 212 // should try and move to its desired position.
222 UpdatePopupBounds(); 213 UpdatePopupBounds();
223 #endif 214 #endif
224 215
225 view_->UpdateBoundsAndRedrawPopup(); 216 view_->UpdateBoundsAndRedrawPopup();
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 if (bottom_available >= popup_required_height || 602 if (bottom_available >= popup_required_height ||
612 bottom_available >= top_available) { 603 bottom_available >= top_available) {
613 // The popup can appear below the field. 604 // The popup can appear below the field.
614 return std::make_pair(bottom_growth_start, popup_required_height); 605 return std::make_pair(bottom_growth_start, popup_required_height);
615 } else { 606 } else {
616 // The popup must appear above the field. 607 // The popup must appear above the field.
617 return std::make_pair(top_growth_end - popup_required_height, 608 return std::make_pair(top_growth_end - popup_required_height,
618 popup_required_height); 609 popup_required_height);
619 } 610 }
620 } 611 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698