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
70
71
72
73
74
75
ash / system / privacy / screen_security_controller.h [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_PRIVACY_SCREEN_SECURITY_CONTROLLER_H_
#define ASH_SYSTEM_PRIVACY_SCREEN_SECURITY_CONTROLLER_H_
#include <string>
#include <vector>
#include "ash/shell_observer.h"
#include "ash/system/privacy/screen_security_observer.h"
#include "base/memory/weak_ptr.h"
namespace ash {
extern ASH_EXPORT const char kScreenAccessNotificationId[];
extern ASH_EXPORT const char kRemotingScreenShareNotificationId[];
extern ASH_EXPORT const char kNotifierScreenAccess[];
extern ASH_EXPORT const char kNotifierRemotingScreenShare[];
// Controller class to manage screen security notifications.
class ASH_EXPORT ScreenSecurityController : public ScreenSecurityObserver,
public ShellObserver {
public:
ScreenSecurityController();
ScreenSecurityController(const ScreenSecurityController&) = delete;
ScreenSecurityController& operator=(const ScreenSecurityController&) = delete;
~ScreenSecurityController() override;
// Stop all sharing/accessing sessions by calling all the callbacks in
// `screen_access_stop_callbacks_` or `remoting_share_stop_callbacks_`,
// depending on `is_screen_access` argument. Also removes any privacy
// notifications if exist.
void StopAllSessions(bool is_screen_access);
private:
// Creates the screen security notification. If
// `is_screen_access_notification`, the notification is created for screen
// access. Otherwise it is for remoting screen share.
void CreateNotification(const std::u16string& message,
bool is_screen_access_notification);
// Changes the source of current capture session by bringing up the picker
// again, only if there is only one screen capture session.
void ChangeSource();
// ScreenSecurityObserver:
void OnScreenAccessStart(base::OnceClosure stop_callback,
const base::RepeatingClosure& source_callback,
const std::u16string& access_app_name) override;
void OnScreenAccessStop() override;
void OnRemotingScreenShareStart(base::OnceClosure stop_callback) override;
void OnRemotingScreenShareStop() override;
// ShellObserver:
void OnCastingSessionStartedOrStopped(bool started) override;
bool is_casting_ = false;
// There can be multiple cast sessions at the same time. If the user hits the
// stop button, stops all sessions since there is not a good UI to distinguish
// between the different sessions.
std::vector<base::OnceClosure> screen_access_stop_callbacks_;
std::vector<base::OnceClosure> remoting_share_stop_callbacks_;
base::RepeatingClosure change_source_callback_;
base::WeakPtrFactory<ScreenSecurityController> weak_ptr_factory_{this};
};
} // namespace ash
#endif // ASH_SYSTEM_PRIVACY_SCREEN_SECURITY_CONTROLLER_H_