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

Unified Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 11308124: Hide new Autofill Popup on Main Widget Resize or Move. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
index 385f745ffa231e5fe3fa01136b397ece780b4709..9f7d5662865a4e3d41ddb7b29d140c38833e63f7 100644
--- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
@@ -45,6 +45,11 @@ void AutofillPopupViewViews::Hide() {
if (GetWidget())
GetWidget()->Close();
web_contents_->GetRenderViewHost()->RemoveKeyboardListener(this);
+
+ views::Widget* browser_widget =
+ views::Widget::GetTopLevelWidgetForNativeView(
+ web_contents_->GetView()->GetTopLevelNativeWindow());
+ browser_widget->RemoveObserver(this);
}
void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
@@ -61,6 +66,15 @@ void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
}
}
+void AutofillPopupViewViews::OnWidgetMoved(views::Widget* widget) {
+ external_delegate()->HideAutofillPopup();
+}
+
+void AutofillPopupViewViews::OnWidgetSizeChanged(views::Widget* widget,
+ const gfx::Size& size) {
+ external_delegate()->HideAutofillPopup();
+}
+
bool AutofillPopupViewViews::HandleKeyPressEvent(ui::KeyEvent* event) {
switch (event->key_code()) {
case ui::VKEY_UP:
@@ -76,11 +90,7 @@ bool AutofillPopupViewViews::HandleKeyPressEvent(ui::KeyEvent* event) {
SetSelectedLine(autofill_values().size() - 1);
return true;
case ui::VKEY_ESCAPE:
- if (external_delegate()) {
- external_delegate()->HideAutofillPopup();
- } else {
- Hide();
- }
+ external_delegate()->HideAutofillPopup();
return true;
case ui::VKEY_DELETE:
return event->IsShiftDown() && RemoveSelectedLine();
@@ -109,6 +119,13 @@ void AutofillPopupViewViews::ShowInternal() {
gfx::Rect client_area;
web_contents_->GetContainerBounds(&client_area);
widget->SetBounds(client_area);
+
+ // Setup an observer to check for when the browser moves or changes size,
+ // since the popup should always be hidden in those cases.
+ views::Widget* browser_widget =
+ views::Widget::GetTopLevelWidgetForNativeView(
+ web_contents_->GetView()->GetTopLevelNativeWindow());
+ browser_widget->AddObserver(this);
}
set_border(views::Border::CreateSolidBorder(kBorderThickness, kBorderColor));

Powered by Google App Engine
This is Rietveld 408576698