Chromium Code Reviews| 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" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 GetContentsView()->AddChildView(shelf_view_); | 324 GetContentsView()->AddChildView(shelf_view_); |
| 325 return shelf_view_; | 325 return shelf_view_; |
| 326 } | 326 } |
| 327 | 327 |
| 328 void ShelfWidget::PostCreateShelf() { | 328 void ShelfWidget::PostCreateShelf() { |
| 329 SetFocusCycler(WmShell::Get()->focus_cycler()); | 329 SetFocusCycler(WmShell::Get()->focus_cycler()); |
| 330 | 330 |
| 331 // Ensure the newly created |shelf_| gets current values. | 331 // Ensure the newly created |shelf_| gets current values. |
| 332 background_animator_.Initialize(this); | 332 background_animator_.Initialize(this); |
| 333 | 333 |
| 334 // TODO(jamescook): The IsActiveUserSessionStarted() check may not be needed | |
| 335 // because the shelf is only created after the first user session is active. | |
| 336 // The ShelfView seems to always be visible after login. At the lock screen | |
| 337 // the shelf is hidden because its container is hidden. During auto-hide it is | |
| 338 // hidden because ShelfWidget is transparent. Some of the ShelfView visibility | |
| 339 // code could be simplified. http://crbug.com/674773 | |
| 334 shelf_view_->SetVisible( | 340 shelf_view_->SetVisible( |
| 335 WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()); | 341 WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()); |
| 336 shelf_layout_manager_->LayoutShelf(); | 342 shelf_layout_manager_->LayoutShelf(); |
| 337 shelf_layout_manager_->UpdateAutoHideState(); | 343 shelf_layout_manager_->UpdateAutoHideState(); |
| 338 Show(); | 344 Show(); |
| 339 } | 345 } |
| 340 | 346 |
| 341 bool ShelfWidget::IsShelfVisible() const { | 347 bool ShelfWidget::IsShelfVisible() const { |
| 342 return shelf_view_ && shelf_view_->visible(); | 348 return shelf_view_ && shelf_view_->visible(); |
| 343 } | 349 } |
| 344 | 350 |
| 345 void ShelfWidget::SetShelfVisibility(bool visible) { | |
| 346 if (shelf_view_) | |
| 347 shelf_view_->SetVisible(visible); | |
| 348 } | |
| 349 | |
| 350 bool ShelfWidget::IsShowingAppList() const { | 351 bool ShelfWidget::IsShowingAppList() const { |
| 351 return GetAppListButton() && GetAppListButton()->is_showing_app_list(); | 352 return GetAppListButton() && GetAppListButton()->is_showing_app_list(); |
| 352 } | 353 } |
| 353 | 354 |
| 354 bool ShelfWidget::IsShowingContextMenu() const { | 355 bool ShelfWidget::IsShowingContextMenu() const { |
| 355 return shelf_view_ && shelf_view_->IsShowingMenu(); | 356 return shelf_view_ && shelf_view_->IsShowingMenu(); |
| 356 } | 357 } |
| 357 | 358 |
| 358 bool ShelfWidget::IsShowingOverflowBubble() const { | 359 bool ShelfWidget::IsShowingOverflowBubble() const { |
| 359 return shelf_view_ && shelf_view_->IsShowingOverflowBubble(); | 360 return shelf_view_ && shelf_view_->IsShowingOverflowBubble(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 381 background_animator_.RemoveObserver(status_area_widget_); | 382 background_animator_.RemoveObserver(status_area_widget_); |
| 382 WmShell::Get()->focus_cycler()->RemoveWidget(status_area_widget_); | 383 WmShell::Get()->focus_cycler()->RemoveWidget(status_area_widget_); |
| 383 status_area_widget_->Shutdown(); | 384 status_area_widget_->Shutdown(); |
| 384 status_area_widget_ = nullptr; | 385 status_area_widget_ = nullptr; |
| 385 } | 386 } |
| 386 | 387 |
| 387 CloseNow(); | 388 CloseNow(); |
| 388 } | 389 } |
| 389 | 390 |
| 390 void ShelfWidget::UpdateIconPositionForPanel(WmWindow* panel) { | 391 void ShelfWidget::UpdateIconPositionForPanel(WmWindow* panel) { |
| 392 if (!shelf_view_) | |
| 393 return; | |
| 394 | |
| 391 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(this); | 395 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(this); |
| 392 shelf_view_->UpdatePanelIconPosition( | 396 shelf_view_->UpdatePanelIconPosition( |
| 393 panel->GetIntProperty(WmWindowProperty::SHELF_ID), | 397 panel->GetIntProperty(WmWindowProperty::SHELF_ID), |
| 394 shelf_window->ConvertRectFromScreen(panel->GetBoundsInScreen()) | 398 shelf_window->ConvertRectFromScreen(panel->GetBoundsInScreen()) |
| 395 .CenterPoint()); | 399 .CenterPoint()); |
| 396 } | 400 } |
| 397 | 401 |
| 398 gfx::Rect ShelfWidget::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { | 402 gfx::Rect ShelfWidget::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { |
| 403 // Window animations can be triggered during session restore before the shelf | |
| 404 // view is created. | |
|
msw
2017/01/11 00:54:54
nit: "In that case, return default empty bounds" (
James Cook
2017/01/11 17:03:48
Done.
| |
| 405 if (!shelf_view_) | |
| 406 return gfx::Rect(); | |
|
James Cook
2017/01/11 00:39:50
This is the crash fix. It results in the window be
| |
| 407 | |
| 399 ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID); | 408 ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID); |
| 400 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); | 409 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); |
| 401 gfx::Point screen_origin; | 410 gfx::Point screen_origin; |
| 402 views::View::ConvertPointToScreen(shelf_view_, &screen_origin); | 411 views::View::ConvertPointToScreen(shelf_view_, &screen_origin); |
| 403 return gfx::Rect(screen_origin.x() + bounds.x(), | 412 return gfx::Rect(screen_origin.x() + bounds.x(), |
| 404 screen_origin.y() + bounds.y(), bounds.width(), | 413 screen_origin.y() + bounds.y(), bounds.width(), |
| 405 bounds.height()); | 414 bounds.height()); |
| 406 } | 415 } |
| 407 | 416 |
| 408 AppListButton* ShelfWidget::GetAppListButton() const { | 417 AppListButton* ShelfWidget::GetAppListButton() const { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 427 if (shelf_view_) | 436 if (shelf_view_) |
| 428 shelf_view_->UpdateShelfItemBackground(alpha); | 437 shelf_view_->UpdateShelfItemBackground(alpha); |
| 429 } | 438 } |
| 430 | 439 |
| 431 void ShelfWidget::WillDeleteShelfLayoutManager() { | 440 void ShelfWidget::WillDeleteShelfLayoutManager() { |
| 432 shelf_layout_manager_->RemoveObserver(this); | 441 shelf_layout_manager_->RemoveObserver(this); |
| 433 shelf_layout_manager_ = nullptr; | 442 shelf_layout_manager_ = nullptr; |
| 434 } | 443 } |
| 435 | 444 |
| 436 } // namespace ash | 445 } // namespace ash |
| OLD | NEW |