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

Side by Side Diff: ui/views/widget/widget.cc

Issue 2834943002: Don't allow a widget to send close notifications more than once. (Closed)
Patch Set: dont touch that one 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 | ui/views/widget/widget_unittest.cc » ('j') | ui/views/widget/widget_unittest.cc » ('J')
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 "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 void Widget::Close() { 576 void Widget::Close() {
577 if (widget_closed_) { 577 if (widget_closed_) {
578 // It appears we can hit this code path if you close a modal dialog then 578 // It appears we can hit this code path if you close a modal dialog then
579 // close the last browser before the destructor is hit, which triggers 579 // close the last browser before the destructor is hit, which triggers
580 // invoking Close again. 580 // invoking Close again.
581 return; 581 return;
582 } 582 }
583 583
584 bool can_close = true; 584 bool can_close = true;
585 if (non_client_view_) 585 if (non_client_view_)
586 can_close = non_client_view_->CanClose(); 586 can_close = non_client_view_->CanClose();
sky 2017/04/25 05:04:10 While you're here simplify this to an early return
Evan Stade 2017/04/25 22:52:51 Done.
587 if (can_close) { 587 if (can_close) {
588 // The actions below can cause this function to be called again, so mark
589 // |this| as closed early. See crbug.com/714334
590 widget_closed_ = true;
588 SaveWindowPlacement(); 591 SaveWindowPlacement();
589 592
590 // During tear-down the top-level focus manager becomes unavailable to 593 // During tear-down the top-level focus manager becomes unavailable to
591 // GTK tabbed panes and their children, so normal deregistration via 594 // GTK tabbed panes and their children, so normal deregistration via
sky 2017/04/25 05:04:09 This comment seems out of date.
Evan Stade 2017/04/25 22:52:51 I don't know what a GTK tabbed pane is, so I don't
592 // |FormManager::ViewRemoved()| calls are fouled. We clear focus here 595 // |FormManager::ViewRemoved()| calls are fouled. We clear focus here
593 // to avoid these redundant steps and to avoid accessing deleted views 596 // to avoid these redundant steps and to avoid accessing deleted views
594 // that may have been in focus. 597 // that may have been in focus.
595 if (is_top_level() && focus_manager_.get()) 598 if (is_top_level() && focus_manager_.get())
596 focus_manager_->SetFocusedView(NULL); 599 focus_manager_->SetFocusedView(NULL);
597 600
598 for (WidgetObserver& observer : observers_) 601 for (WidgetObserver& observer : observers_)
599 observer.OnWidgetClosing(this); 602 observer.OnWidgetClosing(this);
600 603
601 native_widget_->Close(); 604 native_widget_->Close();
602 widget_closed_ = true;
603 } 605 }
604 } 606 }
605 607
606 void Widget::CloseNow() { 608 void Widget::CloseNow() {
607 for (WidgetObserver& observer : observers_) 609 for (WidgetObserver& observer : observers_)
608 observer.OnWidgetClosing(this); 610 observer.OnWidgetClosing(this);
609 native_widget_->CloseNow(); 611 native_widget_->CloseNow();
610 } 612 }
611 613
612 bool Widget::IsClosed() const { 614 bool Widget::IsClosed() const {
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 1569
1568 //////////////////////////////////////////////////////////////////////////////// 1570 ////////////////////////////////////////////////////////////////////////////////
1569 // internal::NativeWidgetPrivate, NativeWidget implementation: 1571 // internal::NativeWidgetPrivate, NativeWidget implementation:
1570 1572
1571 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1573 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1572 return this; 1574 return this;
1573 } 1575 }
1574 1576
1575 } // namespace internal 1577 } // namespace internal
1576 } // namespace views 1578 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/widget_unittest.cc » ('j') | ui/views/widget/widget_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698