OLD | NEW |
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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 574 } |
575 | 575 |
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 if (non_client_view_ && !non_client_view_->CanClose()) | 584 bool can_close = true; |
585 return; | 585 if (non_client_view_) |
| 586 can_close = non_client_view_->CanClose(); |
| 587 if (can_close) { |
| 588 SaveWindowPlacement(); |
586 | 589 |
587 // The actions below can cause this function to be called again, so mark | 590 // During tear-down the top-level focus manager becomes unavailable to |
588 // |this| as closed early. See crbug.com/714334 | 591 // GTK tabbed panes and their children, so normal deregistration via |
589 widget_closed_ = true; | 592 // |FormManager::ViewRemoved()| calls are fouled. We clear focus here |
590 SaveWindowPlacement(); | 593 // to avoid these redundant steps and to avoid accessing deleted views |
| 594 // that may have been in focus. |
| 595 if (is_top_level() && focus_manager_.get()) |
| 596 focus_manager_->SetFocusedView(NULL); |
591 | 597 |
592 // During tear-down the top-level focus manager becomes unavailable to | 598 for (WidgetObserver& observer : observers_) |
593 // GTK tabbed panes and their children, so normal deregistration via | 599 observer.OnWidgetClosing(this); |
594 // |FocusManager::ViewRemoved()| calls are fouled. We clear focus here | |
595 // to avoid these redundant steps and to avoid accessing deleted views | |
596 // that may have been in focus. | |
597 if (is_top_level() && focus_manager_.get()) | |
598 focus_manager_->SetFocusedView(nullptr); | |
599 | 600 |
600 for (WidgetObserver& observer : observers_) | 601 native_widget_->Close(); |
601 observer.OnWidgetClosing(this); | 602 widget_closed_ = true; |
602 | 603 } |
603 native_widget_->Close(); | |
604 } | 604 } |
605 | 605 |
606 void Widget::CloseNow() { | 606 void Widget::CloseNow() { |
607 for (WidgetObserver& observer : observers_) | 607 for (WidgetObserver& observer : observers_) |
608 observer.OnWidgetClosing(this); | 608 observer.OnWidgetClosing(this); |
609 native_widget_->CloseNow(); | 609 native_widget_->CloseNow(); |
610 } | 610 } |
611 | 611 |
612 bool Widget::IsClosed() const { | 612 bool Widget::IsClosed() const { |
613 return widget_closed_; | 613 return widget_closed_; |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 | 1567 |
1568 //////////////////////////////////////////////////////////////////////////////// | 1568 //////////////////////////////////////////////////////////////////////////////// |
1569 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1569 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1570 | 1570 |
1571 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1571 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1572 return this; | 1572 return this; |
1573 } | 1573 } |
1574 | 1574 |
1575 } // namespace internal | 1575 } // namespace internal |
1576 } // namespace views | 1576 } // namespace views |
OLD | NEW |