fake_do_not_disturb_controller.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/components/phonehub/fake_do_not_disturb_controller.h"
  5. namespace ash {
  6. namespace phonehub {
  7. FakeDoNotDisturbController::FakeDoNotDisturbController() = default;
  8. FakeDoNotDisturbController::~FakeDoNotDisturbController() = default;
  9. bool FakeDoNotDisturbController::IsDndEnabled() const {
  10. return is_dnd_enabled_;
  11. }
  12. void FakeDoNotDisturbController::SetDoNotDisturbStateInternal(
  13. bool is_dnd_enabled,
  14. bool can_request_new_dnd_state) {
  15. if (is_dnd_enabled_ == is_dnd_enabled &&
  16. can_request_new_dnd_state_ == can_request_new_dnd_state) {
  17. return;
  18. }
  19. is_dnd_enabled_ = is_dnd_enabled;
  20. can_request_new_dnd_state_ = can_request_new_dnd_state;
  21. NotifyDndStateChanged();
  22. }
  23. void FakeDoNotDisturbController::RequestNewDoNotDisturbState(bool enabled) {
  24. if (!should_request_fail_)
  25. SetDoNotDisturbStateInternal(enabled, /*can_request_new_dnd_state=*/true);
  26. }
  27. bool FakeDoNotDisturbController::CanRequestNewDndState() const {
  28. return can_request_new_dnd_state_;
  29. }
  30. void FakeDoNotDisturbController::SetShouldRequestFail(
  31. bool should_request_fail) {
  32. should_request_fail_ = should_request_fail;
  33. }
  34. } // namespace phonehub
  35. } // namespace ash