-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathlock_screen_action_background_controller.cc
69 lines (52 loc) · 2.03 KB
/
lock_screen_action_background_controller.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/lock_screen_action/lock_screen_action_background_controller.h"
#include "ash/lock_screen_action/lock_screen_action_background_controller_impl.h"
#include "ash/lock_screen_action/lock_screen_action_background_controller_stub.h"
#include "ash/lock_screen_action/lock_screen_action_background_observer.h"
#include "base/functional/callback.h"
namespace ash {
namespace {
LockScreenActionBackgroundController::FactoryCallback*
g_testing_factory_callback = nullptr;
} // namespace
// static
std::unique_ptr<LockScreenActionBackgroundController>
LockScreenActionBackgroundController::Create() {
if (g_testing_factory_callback)
return g_testing_factory_callback->Run();
return std::make_unique<LockScreenActionBackgroundControllerImpl>();
}
// static
void LockScreenActionBackgroundController::SetFactoryCallbackForTesting(
FactoryCallback* testing_factory_callback) {
g_testing_factory_callback = testing_factory_callback;
}
LockScreenActionBackgroundController::LockScreenActionBackgroundController() =
default;
LockScreenActionBackgroundController::~LockScreenActionBackgroundController() {
UpdateState(LockScreenActionBackgroundState::kHidden);
}
void LockScreenActionBackgroundController::SetParentWindow(
aura::Window* parent_window) {
DCHECK(!parent_window_);
parent_window_ = parent_window;
}
void LockScreenActionBackgroundController::AddObserver(
LockScreenActionBackgroundObserver* observer) {
observers_.AddObserver(observer);
}
void LockScreenActionBackgroundController::RemoveObserver(
LockScreenActionBackgroundObserver* observer) {
observers_.RemoveObserver(observer);
}
void LockScreenActionBackgroundController::UpdateState(
LockScreenActionBackgroundState state) {
if (state_ == state)
return;
state_ = state;
for (auto& observer : observers_)
observer.OnLockScreenActionBackgroundStateChanged(state_);
}
} // namespace ash