| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 336 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| 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::Rect layer_bounds = host->GetLocalBounds(); | 346 const gfx::Size layer_size = host->size(); |
| 347 const gfx::Rect mask_bounds = GetInkDropBounds(ink_drop_style, host); | 347 const gfx::Rect mask_bounds = GetInkDropBounds(ink_drop_style, host); |
| 348 switch (ink_drop_style) { | 348 switch (ink_drop_style) { |
| 349 case TrayPopupInkDropStyle::HOST_CENTERED: { | 349 case TrayPopupInkDropStyle::HOST_CENTERED: { |
| 350 const int radius = | 350 const int radius = |
| 351 std::min(mask_bounds.width(), mask_bounds.height()) / 2; | 351 std::min(mask_bounds.width(), mask_bounds.height()) / 2; |
| 352 return base::MakeUnique<views::CircleInkDropMask>( | 352 return base::MakeUnique<views::CircleInkDropMask>( |
| 353 layer_bounds, mask_bounds.CenterPoint(), radius); | 353 layer_size, mask_bounds.CenterPoint(), radius); |
| 354 } | 354 } |
| 355 case TrayPopupInkDropStyle::INSET_BOUNDS: | 355 case TrayPopupInkDropStyle::INSET_BOUNDS: |
| 356 return base::MakeUnique<views::RoundRectInkDropMask>( | 356 return base::MakeUnique<views::RoundRectInkDropMask>( |
| 357 layer_bounds, mask_bounds, kTrayPopupInkDropCornerRadius); | 357 layer_size, mask_bounds, kTrayPopupInkDropCornerRadius); |
| 358 case TrayPopupInkDropStyle::FILL_BOUNDS: | 358 case TrayPopupInkDropStyle::FILL_BOUNDS: |
| 359 // Handled by quick return above. | 359 // Handled by quick return above. |
| 360 break; | 360 break; |
| 361 } | 361 } |
| 362 // Required by some compilers. | 362 // Required by some compilers. |
| 363 NOTREACHED(); | 363 NOTREACHED(); |
| 364 return nullptr; | 364 return nullptr; |
| 365 } | 365 } |
| 366 | 366 |
| 367 gfx::Rect TrayPopupUtils::GetInkDropBounds(TrayPopupInkDropStyle ink_drop_style, | 367 gfx::Rect TrayPopupUtils::GetInkDropBounds(TrayPopupInkDropStyle ink_drop_style, |
| 368 const views::View* host) { | 368 const views::View* host) { |
| 369 gfx::Rect bounds = host->GetLocalBounds(); | 369 gfx::Rect bounds = host->GetLocalBounds(); |
| 370 if (ink_drop_style == TrayPopupInkDropStyle::HOST_CENTERED || | 370 if (ink_drop_style == TrayPopupInkDropStyle::HOST_CENTERED || |
| 371 ink_drop_style == TrayPopupInkDropStyle::INSET_BOUNDS) { | 371 ink_drop_style == TrayPopupInkDropStyle::INSET_BOUNDS) { |
| 372 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); | 372 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| 373 } | 373 } |
| 374 return bounds; | 374 return bounds; |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { | 377 bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) { |
| 378 // TODO(tdanderson): Consider moving this into WmShell, or introduce a | 378 // TODO(tdanderson): Consider moving this into WmShell, or introduce a |
| 379 // CanShowSettings() method in each delegate type that has a | 379 // CanShowSettings() method in each delegate type that has a |
| 380 // ShowSettings() method. | 380 // ShowSettings() method. |
| 381 return status != LoginStatus::NOT_LOGGED_IN && | 381 return status != LoginStatus::NOT_LOGGED_IN && |
| 382 status != LoginStatus::LOCKED && | 382 status != LoginStatus::LOCKED && |
| 383 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 383 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 } // namespace ash | 386 } // namespace ash |
| OLD | NEW |