OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/tray_action/tray_action.h" | 5 #include "ash/tray_action/tray_action.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/tray_action/tray_action_observer.h" | 9 #include "ash/tray_action/tray_action_observer.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 void TrayAction::RemoveObserver(TrayActionObserver* observer) { | 24 void TrayAction::RemoveObserver(TrayActionObserver* observer) { |
25 observers_.RemoveObserver(observer); | 25 observers_.RemoveObserver(observer); |
26 } | 26 } |
27 | 27 |
28 void TrayAction::BindRequest(mojom::TrayActionRequest request) { | 28 void TrayAction::BindRequest(mojom::TrayActionRequest request) { |
29 bindings_.AddBinding(this, std::move(request)); | 29 bindings_.AddBinding(this, std::move(request)); |
30 } | 30 } |
31 | 31 |
32 mojom::TrayActionState TrayAction::GetLockScreenNoteState() { | 32 mojom::TrayActionState TrayAction::GetLockScreenNoteState() const { |
33 if (!tray_action_client_) | 33 if (!tray_action_client_) |
34 return mojom::TrayActionState::kNotAvailable; | 34 return mojom::TrayActionState::kNotAvailable; |
35 return lock_screen_note_state_; | 35 return lock_screen_note_state_; |
36 } | 36 } |
37 | 37 |
| 38 bool TrayAction::IsLockScreenNoteActive() const { |
| 39 return GetLockScreenNoteState() == mojom::TrayActionState::kActive; |
| 40 } |
| 41 |
38 void TrayAction::SetClient(mojom::TrayActionClientPtr tray_action_client, | 42 void TrayAction::SetClient(mojom::TrayActionClientPtr tray_action_client, |
39 mojom::TrayActionState lock_screen_note_state) { | 43 mojom::TrayActionState lock_screen_note_state) { |
40 mojom::TrayActionState old_lock_screen_note_state = GetLockScreenNoteState(); | 44 mojom::TrayActionState old_lock_screen_note_state = GetLockScreenNoteState(); |
41 | 45 |
42 tray_action_client_ = std::move(tray_action_client); | 46 tray_action_client_ = std::move(tray_action_client); |
43 | 47 |
44 if (tray_action_client_) { | 48 if (tray_action_client_) { |
45 // Makes sure the state is updated in case the connection is lost. | 49 // Makes sure the state is updated in case the connection is lost. |
46 tray_action_client_.set_connection_error_handler( | 50 tray_action_client_.set_connection_error_handler( |
47 base::Bind(&TrayAction::SetClient, base::Unretained(this), nullptr, | 51 base::Bind(&TrayAction::SetClient, base::Unretained(this), nullptr, |
(...skipping 27 matching lines...) Expand all Loading... |
75 DCHECK(tray_action_client_); | 79 DCHECK(tray_action_client_); |
76 tray_action_client_->RequestNewLockScreenNote(); | 80 tray_action_client_->RequestNewLockScreenNote(); |
77 } | 81 } |
78 | 82 |
79 void TrayAction::NotifyLockScreenNoteStateChanged() { | 83 void TrayAction::NotifyLockScreenNoteStateChanged() { |
80 for (auto& observer : observers_) | 84 for (auto& observer : observers_) |
81 observer.OnLockScreenNoteStateChanged(GetLockScreenNoteState()); | 85 observer.OnLockScreenNoteStateChanged(GetLockScreenNoteState()); |
82 } | 86 } |
83 | 87 |
84 } // namespace ash | 88 } // namespace ash |
OLD | NEW |