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/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #endif | 67 #endif |
68 | 68 |
69 namespace views { | 69 namespace views { |
70 | 70 |
71 namespace { | 71 namespace { |
72 | 72 |
73 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { | 73 void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { |
74 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); | 74 window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); |
75 } | 75 } |
76 | 76 |
| 77 void SetIcon(aura::Window* window, |
| 78 const aura::WindowProperty<gfx::ImageSkia*>* key, |
| 79 const gfx::ImageSkia& value) { |
| 80 if (value.isNull()) |
| 81 window->ClearProperty(key); |
| 82 else |
| 83 window->SetProperty(key, new gfx::ImageSkia(value)); |
| 84 } |
| 85 |
77 } // namespace | 86 } // namespace |
78 | 87 |
79 //////////////////////////////////////////////////////////////////////////////// | 88 //////////////////////////////////////////////////////////////////////////////// |
80 // NativeWidgetAura, public: | 89 // NativeWidgetAura, public: |
81 | 90 |
82 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) | 91 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
83 : delegate_(delegate), | 92 : delegate_(delegate), |
84 window_(new aura::Window(this)), | 93 window_(new aura::Window(this)), |
85 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 94 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
86 destroying_(false), | 95 destroying_(false), |
87 cursor_(gfx::kNullCursor), | 96 cursor_(gfx::kNullCursor), |
88 saved_window_state_(ui::SHOW_STATE_DEFAULT), | 97 saved_window_state_(ui::SHOW_STATE_DEFAULT), |
89 close_widget_factory_(this) { | 98 close_widget_factory_(this) { |
90 aura::client::SetFocusChangeObserver(window_, this); | 99 aura::client::SetFocusChangeObserver(window_, this); |
91 aura::client::SetActivationChangeObserver(window_, this); | 100 aura::client::SetActivationChangeObserver(window_, this); |
92 } | 101 } |
93 | 102 |
94 // static | 103 // static |
95 void NativeWidgetAura::RegisterNativeWidgetForWindow( | 104 void NativeWidgetAura::RegisterNativeWidgetForWindow( |
96 internal::NativeWidgetPrivate* native_widget, | 105 internal::NativeWidgetPrivate* native_widget, |
97 aura::Window* window) { | 106 aura::Window* window) { |
98 window->set_user_data(native_widget); | 107 window->set_user_data(native_widget); |
99 } | 108 } |
100 | 109 |
101 // static | 110 // static |
102 void NativeWidgetAura::AssignIconToAuraWindow(aura::Window* window, | 111 void NativeWidgetAura::AssignIconToAuraWindow(aura::Window* window, |
103 const gfx::ImageSkia& window_icon, | 112 const gfx::ImageSkia& window_icon, |
104 const gfx::ImageSkia& app_icon) { | 113 const gfx::ImageSkia& app_icon) { |
105 if (!window) | 114 if (window) { |
106 return; | 115 SetIcon(window, aura::client::kWindowIconKey, window_icon); |
107 | 116 SetIcon(window, aura::client::kAppIconKey, app_icon); |
108 if (window_icon.isNull() && app_icon.isNull()) { | |
109 window->ClearProperty(aura::client::kWindowIconKey); | |
110 return; | |
111 } | 117 } |
112 | |
113 window->SetProperty( | |
114 aura::client::kWindowIconKey, | |
115 new gfx::ImageSkia(!window_icon.isNull() ? window_icon : app_icon)); | |
116 } | 118 } |
117 | 119 |
118 //////////////////////////////////////////////////////////////////////////////// | 120 //////////////////////////////////////////////////////////////////////////////// |
119 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: | 121 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: |
120 | 122 |
121 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { | 123 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
122 // Aura needs to know which desktop (Ash or regular) will manage this widget. | 124 // Aura needs to know which desktop (Ash or regular) will manage this widget. |
123 // See Widget::InitParams::context for details. | 125 // See Widget::InitParams::context for details. |
124 DCHECK(params.parent || params.context); | 126 DCHECK(params.parent || params.context); |
125 | 127 |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 gfx::NativeView native_view) { | 1216 gfx::NativeView native_view) { |
1215 aura::client::CaptureClient* capture_client = | 1217 aura::client::CaptureClient* capture_client = |
1216 aura::client::GetCaptureClient(native_view->GetRootWindow()); | 1218 aura::client::GetCaptureClient(native_view->GetRootWindow()); |
1217 if (!capture_client) | 1219 if (!capture_client) |
1218 return nullptr; | 1220 return nullptr; |
1219 return capture_client->GetGlobalCaptureWindow(); | 1221 return capture_client->GetGlobalCaptureWindow(); |
1220 } | 1222 } |
1221 | 1223 |
1222 } // namespace internal | 1224 } // namespace internal |
1223 } // namespace views | 1225 } // namespace views |
OLD | NEW |