| 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/test/test_views_delegate.h" | 5 #include "ui/views/test/test_views_delegate.h" |
| 6 | 6 |
| 7 #include "ui/wm/core/wm_state.h" | 7 #include "ui/wm/core/wm_state.h" |
| 8 | 8 |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| 11 | 11 |
| 12 TestViewsDelegate::TestViewsDelegate() | 12 TestViewsDelegate::TestViewsDelegate() |
| 13 : use_transparent_windows_(false) { | 13 : use_transparent_windows_(false) { |
| 14 DCHECK(!ViewsDelegate::views_delegate); | 14 DCHECK(!ViewsDelegate::views_delegate); |
| 15 ViewsDelegate::views_delegate = this; | 15 ViewsDelegate::views_delegate = this; |
| 16 wm_state_.reset(new wm::WMState); | 16 wm_state_.reset(new wm::WMState); |
| 17 } | 17 } |
| 18 | 18 |
| 19 TestViewsDelegate::~TestViewsDelegate() { | 19 TestViewsDelegate::~TestViewsDelegate() { |
| 20 ViewsDelegate::views_delegate = NULL; | 20 if (ViewsDelegate::views_delegate == this) |
| 21 ViewsDelegate::views_delegate = NULL; |
| 21 } | 22 } |
| 22 | 23 |
| 23 void TestViewsDelegate::SetUseTransparentWindows(bool transparent) { | 24 void TestViewsDelegate::SetUseTransparentWindows(bool transparent) { |
| 24 use_transparent_windows_ = transparent; | 25 use_transparent_windows_ = transparent; |
| 25 } | 26 } |
| 26 | 27 |
| 27 void TestViewsDelegate::OnBeforeWidgetInit( | 28 void TestViewsDelegate::OnBeforeWidgetInit( |
| 28 Widget::InitParams* params, | 29 Widget::InitParams* params, |
| 29 internal::NativeWidgetDelegate* delegate) { | 30 internal::NativeWidgetDelegate* delegate) { |
| 30 if (params->opacity == Widget::InitParams::INFER_OPACITY) { | 31 if (params->opacity == Widget::InitParams::INFER_OPACITY) { |
| 31 params->opacity = use_transparent_windows_ ? | 32 params->opacity = use_transparent_windows_ ? |
| 32 Widget::InitParams::TRANSLUCENT_WINDOW : | 33 Widget::InitParams::TRANSLUCENT_WINDOW : |
| 33 Widget::InitParams::OPAQUE_WINDOW; | 34 Widget::InitParams::OPAQUE_WINDOW; |
| 34 } | 35 } |
| 35 } | 36 } |
| 36 | 37 |
| 37 } // namespace views | 38 } // namespace views |
| OLD | NEW |