OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ash/common/shelf/shelf_widget.h" | 5 #include "ash/common/shelf/shelf_widget.h" |
6 | 6 |
7 #include "ash/common/focus_cycler.h" | 7 #include "ash/common/focus_cycler.h" |
8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/shelf/app_list_button.h" | 10 #include "ash/common/shelf/app_list_button.h" |
11 #include "ash/common/shelf/shelf_background_animator_observer.h" | 11 #include "ash/common/shelf/shelf_background_animator_observer.h" |
12 #include "ash/common/shelf/shelf_constants.h" | 12 #include "ash/common/shelf/shelf_constants.h" |
13 #include "ash/common/shelf/shelf_delegate.h" | 13 #include "ash/common/shelf/shelf_delegate.h" |
14 #include "ash/common/shelf/shelf_layout_manager.h" | 14 #include "ash/common/shelf/shelf_layout_manager.h" |
15 #include "ash/common/shelf/shelf_view.h" | 15 #include "ash/common/shelf/shelf_view.h" |
16 #include "ash/common/shelf/wm_shelf.h" | 16 #include "ash/common/shelf/wm_shelf.h" |
17 #include "ash/common/shelf/wm_shelf_util.h" | 17 #include "ash/common/shelf/wm_shelf_util.h" |
18 #include "ash/common/system/chromeos/network/sms_observer.h" | |
18 #include "ash/common/system/status_area_layout_manager.h" | 19 #include "ash/common/system/status_area_layout_manager.h" |
19 #include "ash/common/system/status_area_widget.h" | 20 #include "ash/common/system/status_area_widget.h" |
20 #include "ash/common/wm_lookup.h" | 21 #include "ash/common/wm_lookup.h" |
21 #include "ash/common/wm_shell.h" | 22 #include "ash/common/wm_shell.h" |
22 #include "ash/common/wm_window.h" | 23 #include "ash/common/wm_window.h" |
23 #include "ash/common/wm_window_property.h" | 24 #include "ash/common/wm_window_property.h" |
24 #include "ash/root_window_controller.h" | 25 #include "ash/root_window_controller.h" |
25 #include "base/memory/ptr_util.h" | 26 #include "base/memory/ptr_util.h" |
26 #include "grit/ash_resources.h" | 27 #include "grit/ash_resources.h" |
27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 asset_background_alpha_ = alpha; | 213 asset_background_alpha_ = alpha; |
213 SchedulePaint(); | 214 SchedulePaint(); |
214 } | 215 } |
215 | 216 |
216 ShelfWidget::ShelfWidget(WmWindow* shelf_container, WmShelf* wm_shelf) | 217 ShelfWidget::ShelfWidget(WmWindow* shelf_container, WmShelf* wm_shelf) |
217 : wm_shelf_(wm_shelf), | 218 : wm_shelf_(wm_shelf), |
218 status_area_widget_(nullptr), | 219 status_area_widget_(nullptr), |
219 delegate_view_(new DelegateView(wm_shelf, this)), | 220 delegate_view_(new DelegateView(wm_shelf, this)), |
220 shelf_view_(nullptr), | 221 shelf_view_(nullptr), |
221 background_animator_(SHELF_BACKGROUND_DEFAULT, wm_shelf_), | 222 background_animator_(SHELF_BACKGROUND_DEFAULT, wm_shelf_), |
223 sms_observer_(nullptr), | |
222 activating_as_fallback_(false) { | 224 activating_as_fallback_(false) { |
223 background_animator_.AddObserver(this); | 225 background_animator_.AddObserver(this); |
224 background_animator_.AddObserver(delegate_view_); | 226 background_animator_.AddObserver(delegate_view_); |
225 | 227 |
226 views::Widget::InitParams params( | 228 views::Widget::InitParams params( |
227 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 229 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
228 params.name = "ShelfWidget"; | 230 params.name = "ShelfWidget"; |
229 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 231 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
230 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 232 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
231 params.delegate = delegate_view_; | 233 params.delegate = delegate_view_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 DCHECK(!status_area_widget_); | 266 DCHECK(!status_area_widget_); |
265 // TODO(jamescook): Move ownership to RootWindowController. | 267 // TODO(jamescook): Move ownership to RootWindowController. |
266 status_area_widget_ = new StatusAreaWidget(status_container, wm_shelf_); | 268 status_area_widget_ = new StatusAreaWidget(status_container, wm_shelf_); |
267 status_area_widget_->CreateTrayViews(); | 269 status_area_widget_->CreateTrayViews(); |
268 if (WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()) | 270 if (WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()) |
269 status_area_widget_->Show(); | 271 status_area_widget_->Show(); |
270 WmShell::Get()->focus_cycler()->AddWidget(status_area_widget_); | 272 WmShell::Get()->focus_cycler()->AddWidget(status_area_widget_); |
271 background_animator_.AddObserver(status_area_widget_); | 273 background_animator_.AddObserver(status_area_widget_); |
272 status_container->SetLayoutManager( | 274 status_container->SetLayoutManager( |
273 base::MakeUnique<StatusAreaLayoutManager>(this)); | 275 base::MakeUnique<StatusAreaLayoutManager>(this)); |
276 sms_observer_ = new SmsObserver(); | |
tdanderson
2017/01/26 22:19:06
Is there a specific reason why you chose to instan
yiyix
2017/02/02 20:43:55
sorry, it's a mistake.
tdanderson
2017/02/07 00:15:44
Acknowledged.
| |
274 } | 277 } |
275 | 278 |
276 void ShelfWidget::SetPaintsBackground( | 279 void ShelfWidget::SetPaintsBackground( |
277 ShelfBackgroundType background_type, | 280 ShelfBackgroundType background_type, |
278 BackgroundAnimatorChangeType change_type) { | 281 BackgroundAnimatorChangeType change_type) { |
279 background_animator_.PaintBackground(background_type, change_type); | 282 background_animator_.PaintBackground(background_type, change_type); |
280 } | 283 } |
281 | 284 |
282 ShelfBackgroundType ShelfWidget::GetBackgroundType() const { | 285 ShelfBackgroundType ShelfWidget::GetBackgroundType() const { |
283 return background_animator_.target_background_type(); | 286 return background_animator_.target_background_type(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 if (shelf_layout_manager_) | 381 if (shelf_layout_manager_) |
379 shelf_layout_manager_->PrepareForShutdown(); | 382 shelf_layout_manager_->PrepareForShutdown(); |
380 | 383 |
381 if (status_area_widget_) { | 384 if (status_area_widget_) { |
382 background_animator_.RemoveObserver(status_area_widget_); | 385 background_animator_.RemoveObserver(status_area_widget_); |
383 WmShell::Get()->focus_cycler()->RemoveWidget(status_area_widget_); | 386 WmShell::Get()->focus_cycler()->RemoveWidget(status_area_widget_); |
384 status_area_widget_->Shutdown(); | 387 status_area_widget_->Shutdown(); |
385 status_area_widget_ = nullptr; | 388 status_area_widget_ = nullptr; |
386 } | 389 } |
387 | 390 |
391 sms_observer_->Shutdown(); | |
tdanderson
2017/01/26 22:19:06
Is there a reason why you need to introduce a Shut
yiyix
2017/02/02 20:43:55
I originally didn't create the shutdown method, th
yiyix
2017/02/02 21:24:19
Sorry, after analyzing again, I understand that th
tdanderson
2017/02/07 00:15:45
Thanks for looking into this in more detail, what
| |
388 CloseNow(); | 392 CloseNow(); |
389 } | 393 } |
390 | 394 |
391 void ShelfWidget::UpdateIconPositionForPanel(WmWindow* panel) { | 395 void ShelfWidget::UpdateIconPositionForPanel(WmWindow* panel) { |
392 if (!shelf_view_) | 396 if (!shelf_view_) |
393 return; | 397 return; |
394 | 398 |
395 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(this); | 399 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(this); |
396 shelf_view_->UpdatePanelIconPosition( | 400 shelf_view_->UpdatePanelIconPosition( |
397 panel->GetIntProperty(WmWindowProperty::SHELF_ID), | 401 panel->GetIntProperty(WmWindowProperty::SHELF_ID), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 if (shelf_view_) | 440 if (shelf_view_) |
437 shelf_view_->UpdateShelfItemBackground(alpha); | 441 shelf_view_->UpdateShelfItemBackground(alpha); |
438 } | 442 } |
439 | 443 |
440 void ShelfWidget::WillDeleteShelfLayoutManager() { | 444 void ShelfWidget::WillDeleteShelfLayoutManager() { |
441 shelf_layout_manager_->RemoveObserver(this); | 445 shelf_layout_manager_->RemoveObserver(this); |
442 shelf_layout_manager_ = nullptr; | 446 shelf_layout_manager_ = nullptr; |
443 } | 447 } |
444 | 448 |
445 } // namespace ash | 449 } // namespace ash |
OLD | NEW |