| 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_shelf_aura.h" | 7 #include "ash/aura/wm_shelf_aura.h" |
| 8 #include "ash/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
| 9 #include "ash/common/focus_cycler.h" | 9 #include "ash/common/focus_cycler.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| 11 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
| 12 #include "ash/common/shelf/shelf_background_animator_observer.h" | 12 #include "ash/common/shelf/shelf_background_animator_observer.h" |
| 13 #include "ash/common/shelf/shelf_constants.h" | 13 #include "ash/common/shelf/shelf_constants.h" |
| 14 #include "ash/common/shelf/shelf_delegate.h" | 14 #include "ash/common/shelf/shelf_delegate.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" | 15 #include "ash/common/shelf/wm_shelf.h" |
| 16 #include "ash/common/shelf/wm_shelf_util.h" | 16 #include "ash/common/shelf/wm_shelf_util.h" |
| 17 #include "ash/common/system/status_area_widget.h" | 17 #include "ash/common/system/status_area_widget.h" |
| 18 #include "ash/common/system/tray/system_tray_delegate.h" | 18 #include "ash/common/system/tray/system_tray_delegate.h" |
| 19 #include "ash/common/wm_root_window_controller.h" | 19 #include "ash/common/wm_root_window_controller.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/shelf/dimmer_view.h" | 21 #include "ash/shelf/dimmer_view.h" |
| 22 #include "ash/shelf/shelf.h" | 22 #include "ash/shelf/shelf.h" |
| 23 #include "ash/shelf/shelf_layout_manager.h" | 23 #include "ash/shelf/shelf_layout_manager.h" |
| 24 #include "ash/shell.h" | 24 #include "ash/shell.h" |
| 25 #include "ash/wm/status_area_layout_manager.h" | 25 #include "ash/wm/status_area_layout_manager.h" |
| 26 #include "ash/wm/workspace_controller.h" | 26 #include "ash/wm/workspace_controller.h" |
| 27 #include "base/memory/ptr_util.h" |
| 27 #include "grit/ash_resources.h" | 28 #include "grit/ash_resources.h" |
| 28 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/compositor/layer.h" | 31 #include "ui/compositor/layer.h" |
| 31 #include "ui/compositor/scoped_layer_animation_settings.h" | 32 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 32 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 33 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
| 34 #include "ui/gfx/image/image_skia_operations.h" | 35 #include "ui/gfx/image/image_skia_operations.h" |
| 35 #include "ui/gfx/skbitmap_operations.h" | 36 #include "ui/gfx/skbitmap_operations.h" |
| 36 #include "ui/views/accessible_pane_view.h" | 37 #include "ui/views/accessible_pane_view.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 this, wm_shelf_container->GetShellWindowId(), ¶ms); | 358 this, wm_shelf_container->GetShellWindowId(), ¶ms); |
| 358 Init(params); | 359 Init(params); |
| 359 | 360 |
| 360 // The shelf should not take focus when initially shown. | 361 // The shelf should not take focus when initially shown. |
| 361 set_focus_on_creation(false); | 362 set_focus_on_creation(false); |
| 362 SetContentsView(delegate_view_); | 363 SetContentsView(delegate_view_); |
| 363 delegate_view_->SetParentLayer(GetLayer()); | 364 delegate_view_->SetParentLayer(GetLayer()); |
| 364 | 365 |
| 365 shelf_layout_manager_ = new ShelfLayoutManager(this); | 366 shelf_layout_manager_ = new ShelfLayoutManager(this); |
| 366 shelf_layout_manager_->AddObserver(this); | 367 shelf_layout_manager_->AddObserver(this); |
| 367 aura::Window* shelf_container = | 368 wm_shelf_container->SetLayoutManager(base::WrapUnique(shelf_layout_manager_)); |
| 368 WmWindowAura::GetAuraWindow(wm_shelf_container); | |
| 369 shelf_container->SetLayoutManager(shelf_layout_manager_); | |
| 370 shelf_layout_manager_->set_workspace_controller(workspace_controller); | 369 shelf_layout_manager_->set_workspace_controller(workspace_controller); |
| 371 workspace_controller->SetShelf(shelf_layout_manager_); | 370 workspace_controller->SetShelf(shelf_layout_manager_); |
| 372 background_animator_.PaintBackground( | 371 background_animator_.PaintBackground( |
| 373 shelf_layout_manager_->GetShelfBackgroundType(), | 372 shelf_layout_manager_->GetShelfBackgroundType(), |
| 374 BACKGROUND_CHANGE_IMMEDIATE); | 373 BACKGROUND_CHANGE_IMMEDIATE); |
| 375 wm_shelf_aura_->SetShelfLayoutManager(shelf_layout_manager_); | 374 wm_shelf_aura_->SetShelfLayoutManager(shelf_layout_manager_); |
| 376 | 375 |
| 377 // TODO(jamescook): Move ownership to RootWindowController. | 376 // TODO(jamescook): Move ownership to RootWindowController. |
| 378 status_area_widget_ = | 377 status_area_widget_ = |
| 379 new StatusAreaWidget(wm_status_container, wm_shelf_aura_); | 378 new StatusAreaWidget(wm_status_container, wm_shelf_aura_); |
| 380 status_area_widget_->CreateTrayViews(); | 379 status_area_widget_->CreateTrayViews(); |
| 381 if (WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()) | 380 if (WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()) |
| 382 status_area_widget_->Show(); | 381 status_area_widget_->Show(); |
| 383 WmShell::Get()->focus_cycler()->AddWidget(status_area_widget_); | 382 WmShell::Get()->focus_cycler()->AddWidget(status_area_widget_); |
| 384 background_animator_.AddObserver(status_area_widget_); | 383 background_animator_.AddObserver(status_area_widget_); |
| 384 wm_status_container->SetLayoutManager( |
| 385 base::MakeUnique<StatusAreaLayoutManager>(this)); |
| 385 | 386 |
| 387 aura::Window* shelf_container = |
| 388 WmWindowAura::GetAuraWindow(wm_shelf_container); |
| 386 aura::Window* status_container = | 389 aura::Window* status_container = |
| 387 WmWindowAura::GetAuraWindow(wm_status_container); | 390 WmWindowAura::GetAuraWindow(wm_status_container); |
| 388 status_container->SetLayoutManager( | |
| 389 new StatusAreaLayoutManager(status_container, this)); | |
| 390 | |
| 391 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 391 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 392 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); | 392 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); |
| 393 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 393 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 394 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); | 394 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); |
| 395 | 395 |
| 396 views::Widget::AddObserver(this); | 396 views::Widget::AddObserver(this); |
| 397 } | 397 } |
| 398 | 398 |
| 399 ShelfWidget::~ShelfWidget() { | 399 ShelfWidget::~ShelfWidget() { |
| 400 // Must call Shutdown() before destruction. | 400 // Must call Shutdown() before destruction. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event); | 595 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) { | 598 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) { |
| 599 Widget::OnGestureEvent(event); | 599 Widget::OnGestureEvent(event); |
| 600 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) | 600 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) |
| 601 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event); | 601 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event); |
| 602 } | 602 } |
| 603 | 603 |
| 604 } // namespace ash | 604 } // namespace ash |
| OLD | NEW |