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

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

Issue 12223106: Properly Remove Autofill Keyboard Listener. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove inform_delegate_of_of_destruction Created 7 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
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 AutofillPopupDelegate* delegate, 97 AutofillPopupDelegate* delegate,
98 gfx::NativeView container_view, 98 gfx::NativeView container_view,
99 const gfx::RectF& element_bounds) 99 const gfx::RectF& element_bounds)
100 : view_(NULL), 100 : view_(NULL),
101 delegate_(delegate), 101 delegate_(delegate),
102 container_view_(container_view), 102 container_view_(container_view),
103 element_bounds_(element_bounds), 103 element_bounds_(element_bounds),
104 selected_line_(kNoSelection), 104 selected_line_(kNoSelection),
105 delete_icon_hovered_(false), 105 delete_icon_hovered_(false),
106 is_hiding_(false), 106 is_hiding_(false),
107 inform_delegate_of_destruction_(true),
108 weak_ptr_factory_(this) { 107 weak_ptr_factory_(this) {
109 #if !defined(OS_ANDROID) 108 #if !defined(OS_ANDROID)
110 subtext_font_ = name_font_.DeriveFont(kLabelFontSizeDelta); 109 subtext_font_ = name_font_.DeriveFont(kLabelFontSizeDelta);
111 warning_font_ = name_font_.DeriveFont(0, gfx::Font::ITALIC); 110 warning_font_ = name_font_.DeriveFont(0, gfx::Font::ITALIC);
112 #endif 111 #endif
113 } 112 }
114 113
115 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {} 114 AutofillPopupControllerImpl::~AutofillPopupControllerImpl() {}
116 115
117 void AutofillPopupControllerImpl::Show( 116 void AutofillPopupControllerImpl::Show(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 view_ = AutofillPopupView::Create(this); 163 view_ = AutofillPopupView::Create(this);
165 ShowView(); 164 ShowView();
166 } else { 165 } else {
167 UpdateBoundsAndRedrawPopup(); 166 UpdateBoundsAndRedrawPopup();
168 } 167 }
169 168
170 delegate_->OnPopupShown(this); 169 delegate_->OnPopupShown(this);
171 } 170 }
172 171
173 void AutofillPopupControllerImpl::Hide() { 172 void AutofillPopupControllerImpl::Hide() {
174 inform_delegate_of_destruction_ = false;
175 HideInternal(); 173 HideInternal();
Ilya Sherman 2013/02/12 21:15:25 nit: No longer a need for HideInternal() to be dis
csharp 2013/02/12 21:21:19 Done.
176 } 174 }
177 175
178 bool AutofillPopupControllerImpl::HandleKeyPressEvent( 176 bool AutofillPopupControllerImpl::HandleKeyPressEvent(
179 const content::NativeWebKeyboardEvent& event) { 177 const content::NativeWebKeyboardEvent& event) {
180 switch (event.windowsKeyCode) { 178 switch (event.windowsKeyCode) {
181 case ui::VKEY_UP: 179 case ui::VKEY_UP:
182 SelectPreviousLine(); 180 SelectPreviousLine();
183 return true; 181 return true;
184 case ui::VKEY_DOWN: 182 case ui::VKEY_DOWN:
185 SelectNextLine(); 183 SelectNextLine();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 return delete_icon_hovered_; 331 return delete_icon_hovered_;
334 } 332 }
335 333
336 void AutofillPopupControllerImpl::HideInternal() { 334 void AutofillPopupControllerImpl::HideInternal() {
337 if (is_hiding_) 335 if (is_hiding_)
338 return; 336 return;
339 is_hiding_ = true; 337 is_hiding_ = true;
340 338
341 SetSelectedLine(kNoSelection); 339 SetSelectedLine(kNoSelection);
342 340
343 if (inform_delegate_of_destruction_) 341 delegate_->OnPopupHidden(this);
344 delegate_->OnPopupHidden(this);
345 342
346 if (view_) 343 if (view_)
347 view_->Hide(); 344 view_->Hide();
348 else 345 else
349 delete this; 346 delete this;
350 } 347 }
351 348
352 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { 349 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) {
353 if (selected_line_ == selected_line) 350 if (selected_line_ == selected_line)
354 return; 351 return;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 if (bottom_available >= popup_required_height || 658 if (bottom_available >= popup_required_height ||
662 bottom_available >= top_available) { 659 bottom_available >= top_available) {
663 // The popup can appear below the field. 660 // The popup can appear below the field.
664 return std::make_pair(bottom_growth_start, popup_required_height); 661 return std::make_pair(bottom_growth_start, popup_required_height);
665 } else { 662 } else {
666 // The popup must appear above the field. 663 // The popup must appear above the field.
667 return std::make_pair(top_growth_end - popup_required_height, 664 return std::make_pair(top_growth_end - popup_required_height,
668 popup_required_height); 665 popup_required_height);
669 } 666 }
670 } 667 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698