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

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

Issue 2703933002: Fix a crash due to reentrancy in the widget while processing a theme changed notification after com… (Closed)
Patch Set: Created 3 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
« no previous file with comments | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »
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/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 focus_on_creation_(true), 167 focus_on_creation_(true),
168 is_top_level_(false), 168 is_top_level_(false),
169 native_widget_initialized_(false), 169 native_widget_initialized_(false),
170 native_widget_destroyed_(false), 170 native_widget_destroyed_(false),
171 is_mouse_button_pressed_(false), 171 is_mouse_button_pressed_(false),
172 ignore_capture_loss_(false), 172 ignore_capture_loss_(false),
173 last_mouse_event_was_move_(false), 173 last_mouse_event_was_move_(false),
174 auto_release_capture_(true), 174 auto_release_capture_(true),
175 views_with_layers_dirty_(false), 175 views_with_layers_dirty_(false),
176 movement_disabled_(false), 176 movement_disabled_(false),
177 observer_manager_(this) {} 177 observer_manager_(this),
178 processing_theme_changed_(false) {}
178 179
179 Widget::~Widget() { 180 Widget::~Widget() {
180 DestroyRootView(); 181 DestroyRootView();
181 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) { 182 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) {
182 delete native_widget_; 183 delete native_widget_;
183 } else { 184 } else {
184 DCHECK(native_widget_destroyed_) 185 DCHECK(native_widget_destroyed_)
185 << "Destroying a widget with a live native widget. " 186 << "Destroying a widget with a live native widget. "
186 << "Widget probably should use WIDGET_OWNS_NATIVE_WIDGET ownership."; 187 << "Widget probably should use WIDGET_OWNS_NATIVE_WIDGET ownership.";
187 } 188 }
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM : 892 frame_type_ = ShouldUseNativeFrame() ? FRAME_TYPE_FORCE_CUSTOM :
892 FRAME_TYPE_FORCE_NATIVE; 893 FRAME_TYPE_FORCE_NATIVE;
893 } else { 894 } else {
894 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ? 895 frame_type_ = frame_type_ == FRAME_TYPE_FORCE_CUSTOM ?
895 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM; 896 FRAME_TYPE_FORCE_NATIVE : FRAME_TYPE_FORCE_CUSTOM;
896 } 897 }
897 FrameTypeChanged(); 898 FrameTypeChanged();
898 } 899 }
899 900
900 void Widget::FrameTypeChanged() { 901 void Widget::FrameTypeChanged() {
902 if (processing_theme_changed_)
903 return;
901 native_widget_->FrameTypeChanged(); 904 native_widget_->FrameTypeChanged();
902 } 905 }
903 906
904 const ui::Compositor* Widget::GetCompositor() const { 907 const ui::Compositor* Widget::GetCompositor() const {
905 return native_widget_->GetCompositor(); 908 return native_widget_->GetCompositor();
906 } 909 }
907 910
908 const ui::Layer* Widget::GetLayer() const { 911 const ui::Layer* Widget::GetLayer() const {
909 return native_widget_->GetLayer(); 912 return native_widget_->GetLayer();
910 } 913 }
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 1397
1395 void Widget::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) { 1398 void Widget::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
1396 DCHECK(observer_manager_.IsObserving(observed_theme)); 1399 DCHECK(observer_manager_.IsObserving(observed_theme));
1397 1400
1398 ui::NativeTheme* current_native_theme = GetNativeTheme(); 1401 ui::NativeTheme* current_native_theme = GetNativeTheme();
1399 if (!observer_manager_.IsObserving(current_native_theme)) { 1402 if (!observer_manager_.IsObserving(current_native_theme)) {
1400 observer_manager_.RemoveAll(); 1403 observer_manager_.RemoveAll();
1401 observer_manager_.Add(current_native_theme); 1404 observer_manager_.Add(current_native_theme);
1402 } 1405 }
1403 1406
1407 DCHECK_EQ(processing_theme_changed_, false);
1408 processing_theme_changed_ = true;
sky 2017/02/17 22:50:03 Use AutoReset.
ananta 2017/02/17 22:55:04 Done.
1404 root_view_->PropagateNativeThemeChanged(current_native_theme); 1409 root_view_->PropagateNativeThemeChanged(current_native_theme);
1410 processing_theme_changed_ = false;
1405 } 1411 }
1406 1412
1407 //////////////////////////////////////////////////////////////////////////////// 1413 ////////////////////////////////////////////////////////////////////////////////
1408 // Widget, protected: 1414 // Widget, protected:
1409 1415
1410 internal::RootView* Widget::CreateRootView() { 1416 internal::RootView* Widget::CreateRootView() {
1411 return new internal::RootView(this); 1417 return new internal::RootView(this);
1412 } 1418 }
1413 1419
1414 void Widget::DestroyRootView() { 1420 void Widget::DestroyRootView() {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 1550
1545 //////////////////////////////////////////////////////////////////////////////// 1551 ////////////////////////////////////////////////////////////////////////////////
1546 // internal::NativeWidgetPrivate, NativeWidget implementation: 1552 // internal::NativeWidgetPrivate, NativeWidget implementation:
1547 1553
1548 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1554 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1549 return this; 1555 return this;
1550 } 1556 }
1551 1557
1552 } // namespace internal 1558 } // namespace internal
1553 } // namespace views 1559 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698