| 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/animation/animation_change_type.h" | 7 #include "ash/animation/animation_change_type.h" |
| 8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/public/cpp/window_properties.h" | 9 #include "ash/public/cpp/window_properties.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 this, shelf_container->aura_window()->id(), ¶ms); | 149 this, shelf_container->aura_window()->id(), ¶ms); |
| 150 Init(params); | 150 Init(params); |
| 151 | 151 |
| 152 // The shelf should not take focus when initially shown. | 152 // The shelf should not take focus when initially shown. |
| 153 set_focus_on_creation(false); | 153 set_focus_on_creation(false); |
| 154 SetContentsView(delegate_view_); | 154 SetContentsView(delegate_view_); |
| 155 delegate_view_->SetParentLayer(GetLayer()); | 155 delegate_view_->SetParentLayer(GetLayer()); |
| 156 | 156 |
| 157 shelf_layout_manager_ = new ShelfLayoutManager(this, wm_shelf_); | 157 shelf_layout_manager_ = new ShelfLayoutManager(this, wm_shelf_); |
| 158 shelf_layout_manager_->AddObserver(this); | 158 shelf_layout_manager_->AddObserver(this); |
| 159 shelf_container->SetLayoutManager(base::WrapUnique(shelf_layout_manager_)); | 159 shelf_container->aura_window()->SetLayoutManager(shelf_layout_manager_); |
| 160 background_animator_.PaintBackground( | 160 background_animator_.PaintBackground( |
| 161 shelf_layout_manager_->GetShelfBackgroundType(), | 161 shelf_layout_manager_->GetShelfBackgroundType(), |
| 162 AnimationChangeType::IMMEDIATE); | 162 AnimationChangeType::IMMEDIATE); |
| 163 | 163 |
| 164 views::Widget::AddObserver(this); | 164 views::Widget::AddObserver(this); |
| 165 } | 165 } |
| 166 | 166 |
| 167 ShelfWidget::~ShelfWidget() { | 167 ShelfWidget::~ShelfWidget() { |
| 168 // Must call Shutdown() before destruction. | 168 // Must call Shutdown() before destruction. |
| 169 DCHECK(!status_area_widget_); | 169 DCHECK(!status_area_widget_); |
| 170 Shell::Get()->focus_cycler()->RemoveWidget(this); | 170 Shell::Get()->focus_cycler()->RemoveWidget(this); |
| 171 SetFocusCycler(nullptr); | 171 SetFocusCycler(nullptr); |
| 172 RemoveObserver(this); | 172 RemoveObserver(this); |
| 173 background_animator_.RemoveObserver(delegate_view_); | 173 background_animator_.RemoveObserver(delegate_view_); |
| 174 background_animator_.RemoveObserver(this); | 174 background_animator_.RemoveObserver(this); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void ShelfWidget::CreateStatusAreaWidget(WmWindow* status_container) { | 177 void ShelfWidget::CreateStatusAreaWidget(WmWindow* status_container) { |
| 178 DCHECK(status_container); | 178 DCHECK(status_container); |
| 179 DCHECK(!status_area_widget_); | 179 DCHECK(!status_area_widget_); |
| 180 // TODO(jamescook): Move ownership to RootWindowController. | 180 // TODO(jamescook): Move ownership to RootWindowController. |
| 181 status_area_widget_ = new StatusAreaWidget(status_container, wm_shelf_); | 181 status_area_widget_ = new StatusAreaWidget(status_container, wm_shelf_); |
| 182 status_area_widget_->CreateTrayViews(); | 182 status_area_widget_->CreateTrayViews(); |
| 183 if (Shell::Get()->session_controller()->IsActiveUserSessionStarted()) | 183 if (Shell::Get()->session_controller()->IsActiveUserSessionStarted()) |
| 184 status_area_widget_->Show(); | 184 status_area_widget_->Show(); |
| 185 Shell::Get()->focus_cycler()->AddWidget(status_area_widget_); | 185 Shell::Get()->focus_cycler()->AddWidget(status_area_widget_); |
| 186 background_animator_.AddObserver(status_area_widget_); | 186 background_animator_.AddObserver(status_area_widget_); |
| 187 status_container->SetLayoutManager( | 187 status_container->aura_window()->SetLayoutManager( |
| 188 base::MakeUnique<StatusAreaLayoutManager>(this)); | 188 new StatusAreaLayoutManager(this)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ShelfWidget::SetPaintsBackground(ShelfBackgroundType background_type, | 191 void ShelfWidget::SetPaintsBackground(ShelfBackgroundType background_type, |
| 192 AnimationChangeType change_type) { | 192 AnimationChangeType change_type) { |
| 193 background_animator_.PaintBackground(background_type, change_type); | 193 background_animator_.PaintBackground(background_type, change_type); |
| 194 } | 194 } |
| 195 | 195 |
| 196 ShelfBackgroundType ShelfWidget::GetBackgroundType() const { | 196 ShelfBackgroundType ShelfWidget::GetBackgroundType() const { |
| 197 return background_animator_.target_background_type(); | 197 return background_animator_.target_background_type(); |
| 198 } | 198 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (shelf_view_) | 346 if (shelf_view_) |
| 347 shelf_view_->UpdateShelfItemBackground(color); | 347 shelf_view_->UpdateShelfItemBackground(color); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void ShelfWidget::WillDeleteShelfLayoutManager() { | 350 void ShelfWidget::WillDeleteShelfLayoutManager() { |
| 351 shelf_layout_manager_->RemoveObserver(this); | 351 shelf_layout_manager_->RemoveObserver(this); |
| 352 shelf_layout_manager_ = nullptr; | 352 shelf_layout_manager_ = nullptr; |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace ash | 355 } // namespace ash |
| OLD | NEW |