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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/chromeos/screen_security/screen_share_tray_item.h"
#include "ash/shell.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/notification.h"
using message_center::Notification;
namespace ash {
namespace internal {
namespace {
const char kScreenShareNotificationId[] = "chrome://screen/share";
}
ScreenShareTrayItem::ScreenShareTrayItem(SystemTray* system_tray)
: ScreenTrayItem(system_tray) {
Shell::GetInstance()->system_tray_notifier()->
AddScreenShareObserver(this);
}
ScreenShareTrayItem::~ScreenShareTrayItem() {
Shell::GetInstance()->system_tray_notifier()->
RemoveScreenShareObserver(this);
}
views::View* ScreenShareTrayItem::CreateTrayView(user::LoginStatus status) {
set_tray_view(
new tray::ScreenTrayView(this, IDR_AURA_UBER_TRAY_DISPLAY_LIGHT));
return tray_view();
}
views::View* ScreenShareTrayItem::CreateDefaultView(user::LoginStatus status) {
set_default_view(new tray::ScreenStatusView(
this,
IDR_AURA_UBER_TRAY_DISPLAY,
l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED),
l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP)));
return default_view();
}
void ScreenShareTrayItem::CreateOrUpdateNotification() {
base::string16 help_label_text;
if (!helper_name_.empty()) {
help_label_text = l10n_util::GetStringFUTF16(
IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED_NAME,
helper_name_);
} else {
help_label_text = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED);
}
message_center::RichNotificationData data;
data.buttons.push_back(message_center::ButtonInfo(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP)));
ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
scoped_ptr<Notification> notification(new Notification(
message_center::NOTIFICATION_TYPE_SIMPLE,
kScreenShareNotificationId,
help_label_text,
base::string16() /* body is blank */,
resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY),
base::string16() /* display_source */,
std::string() /* extension_id */,
data,
new tray::ScreenNotificationDelegate(this)));
notification->SetSystemPriority();
message_center::MessageCenter::Get()->AddNotification(notification.Pass());
}
std::string ScreenShareTrayItem::GetNotificationId() {
return kScreenShareNotificationId;
}
void ScreenShareTrayItem::OnScreenShareStart(
const base::Closure& stop_callback,
const base::string16& helper_name) {
helper_name_ = helper_name;
Start(stop_callback);
}
void ScreenShareTrayItem::OnScreenShareStop() {
// We do not need to run the stop callback
// when screening is stopped externally.
set_is_started(false);
Update();
}
} // namespace internal
} // namespace ash
|