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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 saved_show_state_(ui::SHOW_STATE_DEFAULT), | 176 saved_show_state_(ui::SHOW_STATE_DEFAULT), |
177 focus_on_creation_(true), | 177 focus_on_creation_(true), |
178 is_top_level_(false), | 178 is_top_level_(false), |
179 native_widget_initialized_(false), | 179 native_widget_initialized_(false), |
180 native_widget_destroyed_(false), | 180 native_widget_destroyed_(false), |
181 is_mouse_button_pressed_(false), | 181 is_mouse_button_pressed_(false), |
182 is_touch_down_(false), | 182 is_touch_down_(false), |
183 last_mouse_event_was_move_(false), | 183 last_mouse_event_was_move_(false), |
184 auto_release_capture_(true), | 184 auto_release_capture_(true), |
185 root_layers_dirty_(false), | 185 root_layers_dirty_(false), |
186 movement_disabled_(false) { | 186 movement_disabled_(false), |
| 187 observer_manager_(this) { |
187 } | 188 } |
188 | 189 |
189 Widget::~Widget() { | 190 Widget::~Widget() { |
190 DestroyRootView(); | 191 DestroyRootView(); |
191 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) { | 192 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) { |
192 delete native_widget_; | 193 delete native_widget_; |
193 } else { | 194 } else { |
194 DCHECK(native_widget_destroyed_) | 195 DCHECK(native_widget_destroyed_) |
195 << "Destroying a widget with a live native widget. " | 196 << "Destroying a widget with a live native widget. " |
196 << "Widget probably should use WIDGET_OWNS_NATIVE_WIDGET ownership."; | 197 << "Widget probably should use WIDGET_OWNS_NATIVE_WIDGET ownership."; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 ownership_ = params.ownership; | 362 ownership_ = params.ownership; |
362 native_widget_ = CreateNativeWidget(params.native_widget, this)-> | 363 native_widget_ = CreateNativeWidget(params.native_widget, this)-> |
363 AsNativeWidgetPrivate(); | 364 AsNativeWidgetPrivate(); |
364 root_view_.reset(CreateRootView()); | 365 root_view_.reset(CreateRootView()); |
365 default_theme_provider_.reset(new ui::DefaultThemeProvider); | 366 default_theme_provider_.reset(new ui::DefaultThemeProvider); |
366 if (params.type == InitParams::TYPE_MENU) { | 367 if (params.type == InitParams::TYPE_MENU) { |
367 is_mouse_button_pressed_ = | 368 is_mouse_button_pressed_ = |
368 internal::NativeWidgetPrivate::IsMouseButtonDown(); | 369 internal::NativeWidgetPrivate::IsMouseButtonDown(); |
369 } | 370 } |
370 native_widget_->InitNativeWidget(params); | 371 native_widget_->InitNativeWidget(params); |
| 372 observer_manager_.Add(GetNativeTheme()); |
371 if (RequiresNonClientView(params.type)) { | 373 if (RequiresNonClientView(params.type)) { |
372 non_client_view_ = new NonClientView; | 374 non_client_view_ = new NonClientView; |
373 non_client_view_->SetFrameView(CreateNonClientFrameView()); | 375 non_client_view_->SetFrameView(CreateNonClientFrameView()); |
374 // Create the ClientView, add it to the NonClientView and add the | 376 // Create the ClientView, add it to the NonClientView and add the |
375 // NonClientView to the RootView. This will cause everything to be parented. | 377 // NonClientView to the RootView. This will cause everything to be parented. |
376 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); | 378 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); |
377 non_client_view_->SetOverlayView(widget_delegate_->CreateOverlayView()); | 379 non_client_view_->SetOverlayView(widget_delegate_->CreateOverlayView()); |
378 SetContentsView(non_client_view_); | 380 SetContentsView(non_client_view_); |
379 // Initialize the window's title before setting the window's initial bounds; | 381 // Initialize the window's title before setting the window's initial bounds; |
380 // the frame view's preferred height may depend on the presence of a title. | 382 // the frame view's preferred height may depend on the presence of a title. |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 } | 1334 } |
1333 | 1335 |
1334 View* Widget::GetFocusTraversableParentView() { | 1336 View* Widget::GetFocusTraversableParentView() { |
1335 // We are a proxy to the root view, so we should be bypassed when traversing | 1337 // We are a proxy to the root view, so we should be bypassed when traversing |
1336 // up and as a result this should not be called. | 1338 // up and as a result this should not be called. |
1337 NOTREACHED(); | 1339 NOTREACHED(); |
1338 return NULL; | 1340 return NULL; |
1339 } | 1341 } |
1340 | 1342 |
1341 //////////////////////////////////////////////////////////////////////////////// | 1343 //////////////////////////////////////////////////////////////////////////////// |
| 1344 // Widget, ui::NativeThemeObserver implementation: |
| 1345 |
| 1346 void Widget::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) { |
| 1347 DCHECK_EQ(observed_theme, GetNativeTheme()); |
| 1348 root_view_->PropagateNativeThemeChanged(GetNativeTheme()); |
| 1349 } |
| 1350 |
| 1351 //////////////////////////////////////////////////////////////////////////////// |
1342 // Widget, protected: | 1352 // Widget, protected: |
1343 | 1353 |
1344 internal::RootView* Widget::CreateRootView() { | 1354 internal::RootView* Widget::CreateRootView() { |
1345 return new internal::RootView(this); | 1355 return new internal::RootView(this); |
1346 } | 1356 } |
1347 | 1357 |
1348 void Widget::DestroyRootView() { | 1358 void Widget::DestroyRootView() { |
1349 non_client_view_ = NULL; | 1359 non_client_view_ = NULL; |
1350 root_view_.reset(); | 1360 root_view_.reset(); |
1351 // Input method has to be destroyed before focus manager. | 1361 // Input method has to be destroyed before focus manager. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 | 1473 |
1464 //////////////////////////////////////////////////////////////////////////////// | 1474 //////////////////////////////////////////////////////////////////////////////// |
1465 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1475 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1466 | 1476 |
1467 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1477 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1468 return this; | 1478 return this; |
1469 } | 1479 } |
1470 | 1480 |
1471 } // namespace internal | 1481 } // namespace internal |
1472 } // namespace views | 1482 } // namespace views |
OLD | NEW |