quick_actions_view.cc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/system/phonehub/quick_actions_view.h"
  5. #include "ash/system/phonehub/enable_hotspot_quick_action_controller.h"
  6. #include "ash/system/phonehub/locate_phone_quick_action_controller.h"
  7. #include "ash/system/phonehub/phone_hub_view_ids.h"
  8. #include "ash/system/phonehub/quick_action_item.h"
  9. #include "ash/system/phonehub/silence_phone_quick_action_controller.h"
  10. #include "ui/views/layout/box_layout.h"
  11. namespace ash {
  12. namespace {
  13. constexpr auto kQuickActionsViewPadding = gfx::Insets::TLBR(16, 4, 12, 4);
  14. } // namespace
  15. QuickActionsView::QuickActionsView(phonehub::PhoneHubManager* phone_hub_manager)
  16. : phone_hub_manager_(phone_hub_manager) {
  17. SetID(PhoneHubViewID::kQuickActionsView);
  18. auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
  19. views::BoxLayout::Orientation::kHorizontal, kQuickActionsViewPadding));
  20. layout->set_main_axis_alignment(views::BoxLayout::MainAxisAlignment::kCenter);
  21. layout->set_cross_axis_alignment(
  22. views::BoxLayout::CrossAxisAlignment::kCenter);
  23. InitQuickActionItems();
  24. }
  25. QuickActionsView::~QuickActionsView() = default;
  26. void QuickActionsView::InitQuickActionItems() {
  27. auto enable_hotspot_controller =
  28. std::make_unique<EnableHotspotQuickActionController>(
  29. phone_hub_manager_->GetTetherController());
  30. enable_hotspot_ = AddChildView(enable_hotspot_controller->CreateItem());
  31. quick_action_controllers_.push_back(std::move(enable_hotspot_controller));
  32. auto silence_phone_controller =
  33. std::make_unique<SilencePhoneQuickActionController>(
  34. phone_hub_manager_->GetDoNotDisturbController());
  35. silence_phone_ = AddChildView(silence_phone_controller->CreateItem());
  36. auto locate_phone_controller =
  37. std::make_unique<LocatePhoneQuickActionController>(
  38. phone_hub_manager_->GetFindMyDeviceController());
  39. locate_phone_ = AddChildView(locate_phone_controller->CreateItem());
  40. quick_action_controllers_.push_back(std::move(silence_phone_controller));
  41. quick_action_controllers_.push_back(std::move(locate_phone_controller));
  42. }
  43. } // namespace ash