| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/system/tray/tray_popup_utils.h" | 5 #include "ash/common/system/tray/tray_popup_utils.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_constants.h" | 7 #include "ash/common/ash_constants.h" |
| 8 #include "ash/common/ash_view_ids.h" | 8 #include "ash/common/ash_view_ids.h" |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return highlight; | 337 return highlight; |
| 338 } | 338 } |
| 339 | 339 |
| 340 std::unique_ptr<views::InkDropMask> TrayPopupUtils::CreateInkDropMask( | 340 std::unique_ptr<views::InkDropMask> TrayPopupUtils::CreateInkDropMask( |
| 341 TrayPopupInkDropStyle ink_drop_style, | 341 TrayPopupInkDropStyle ink_drop_style, |
| 342 const views::View* host) { | 342 const views::View* host) { |
| 343 if (ink_drop_style == TrayPopupInkDropStyle::FILL_BOUNDS) | 343 if (ink_drop_style == TrayPopupInkDropStyle::FILL_BOUNDS) |
| 344 return nullptr; | 344 return nullptr; |
| 345 | 345 |
| 346 const gfx::Size layer_size = host->size(); | 346 const gfx::Size layer_size = host->size(); |
| 347 const gfx::Rect mask_bounds = GetInkDropBounds(ink_drop_style, host); | |
| 348 switch (ink_drop_style) { | 347 switch (ink_drop_style) { |
| 349 case TrayPopupInkDropStyle::HOST_CENTERED: { | 348 case TrayPopupInkDropStyle::HOST_CENTERED: { |
| 349 const gfx::Rect mask_bounds = |
| 350 GetInkDropBounds(TrayPopupInkDropStyle::HOST_CENTERED, host); |
| 350 const int radius = | 351 const int radius = |
| 351 std::min(mask_bounds.width(), mask_bounds.height()) / 2; | 352 std::min(mask_bounds.width(), mask_bounds.height()) / 2; |
| 352 return base::MakeUnique<views::CircleInkDropMask>( | 353 return base::MakeUnique<views::CircleInkDropMask>( |
| 353 layer_size, mask_bounds.CenterPoint(), radius); | 354 layer_size, mask_bounds.CenterPoint(), radius); |
| 354 } | 355 } |
| 355 case TrayPopupInkDropStyle::INSET_BOUNDS: | 356 case TrayPopupInkDropStyle::INSET_BOUNDS: { |
| 357 const gfx::Insets mask_insets = |
| 358 GetInkDropInsets(TrayPopupInkDropStyle::INSET_BOUNDS); |
| 356 return base::MakeUnique<views::RoundRectInkDropMask>( | 359 return base::MakeUnique<views::RoundRectInkDropMask>( |
| 357 layer_size, mask_bounds, kTrayPopupInkDropCornerRadius); | 360 layer_size, mask_insets, kTrayPopupInkDropCornerRadius); |
| 361 } |
| 358 case TrayPopupInkDropStyle::FILL_BOUNDS: | 362 case TrayPopupInkDropStyle::FILL_BOUNDS: |
| 359 // Handled by quick return above. | 363 // Handled by quick return above. |
| 360 break; | 364 break; |
| 361 } | 365 } |
| 362 // Required by some compilers. | 366 // Required by some compilers. |
| 363 NOTREACHED(); | 367 NOTREACHED(); |
| 364 return nullptr; | 368 return nullptr; |
| 365 } | 369 } |
| 366 | 370 |
| 371 gfx::Insets TrayPopupUtils::GetInkDropInsets( |
| 372 TrayPopupInkDropStyle ink_drop_style) { |
| 373 gfx::Insets insets; |
| 374 if (ink_drop_style == TrayPopupInkDropStyle::HOST_CENTERED || |
| 375 ink_drop_style == TrayPopupInkDropStyle::INSET_BOUNDS) { |
| 376 insets.Set(kTrayPopupInkDropInset, kTrayPopupInkDropInset, |
| 377 kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| 378 } |
| 379 return insets; |
| 380 } |
| 381 |
| 367 gfx::Rect TrayPopupUtils::GetInkDropBounds(TrayPopupInkDropStyle ink_drop_style, | 382 gfx::Rect TrayPopupUtils::GetInkDropBounds(TrayPopupInkDropStyle ink_drop_style, |
| 368 const views::View* host) { | 383 const views::View* host) { |
| 369 gfx::Rect bounds = host->GetLocalBounds(); | 384 gfx::Rect bounds = host->GetLocalBounds(); |
| 370 if (ink_drop_style == TrayPopupInkDropStyle::HOST_CENTERED || | 385 bounds.Inset(GetInkDropInsets(ink_drop_style)); |
| 371 ink_drop_style == TrayPopupInkDropStyle::INSET_BOUNDS) { | |
| 372 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); | |
| 373 } | |
| 374 return bounds; | 386 return bounds; |
| 375 } | 387 } |
| 376 | 388 |
| 377 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { | 389 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { |
| 378 // TODO(tdanderson): Consider moving this into WmShell, or introduce a | 390 // TODO(tdanderson): Consider moving this into WmShell, or introduce a |
| 379 // CanShowSettings() method in each delegate type that has a | 391 // CanShowSettings() method in each delegate type that has a |
| 380 // ShowSettings() method. | 392 // ShowSettings() method. |
| 381 return status != LoginStatus::NOT_LOGGED_IN && | 393 return status != LoginStatus::NOT_LOGGED_IN && |
| 382 status != LoginStatus::LOCKED && | 394 status != LoginStatus::LOCKED && |
| 383 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 395 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 384 } | 396 } |
| 385 | 397 |
| 386 } // namespace ash | 398 } // namespace ash |
| OLD | NEW |