Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: ash/common/system/chromeos/screen_security/screen_share_tray_item.cc

Issue 2732813002: chromeos: Move files in //ash/common to //ash, part 1 (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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
5 #include "ash/common/system/chromeos/screen_security/screen_share_tray_item.h"
6
7 #include <utility>
8
9 #include "ash/common/system/system_notifier.h"
10 #include "ash/common/system/tray/system_tray_notifier.h"
11 #include "ash/common/wm_shell.h"
12 #include "ash/resources/grit/ash_resources.h"
13 #include "ash/strings/grit/ash_strings.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/message_center/message_center.h"
17 #include "ui/message_center/notification.h"
18
19 using message_center::Notification;
20
21 namespace ash {
22 namespace {
23
24 const char kScreenShareNotificationId[] = "chrome://screen/share";
25 }
26
27 ScreenShareTrayItem::ScreenShareTrayItem(SystemTray* system_tray)
28 : ScreenTrayItem(system_tray, UMA_SCREEN_SHARE) {
29 WmShell::Get()->system_tray_notifier()->AddScreenShareObserver(this);
30 }
31
32 ScreenShareTrayItem::~ScreenShareTrayItem() {
33 WmShell::Get()->system_tray_notifier()->RemoveScreenShareObserver(this);
34 }
35
36 views::View* ScreenShareTrayItem::CreateDefaultView(LoginStatus status) {
37 set_default_view(new tray::ScreenStatusView(
38 this,
39 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED),
40 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP)));
41 return default_view();
42 }
43
44 void ScreenShareTrayItem::CreateOrUpdateNotification() {
45 base::string16 help_label_text;
46 if (!helper_name_.empty()) {
47 help_label_text = l10n_util::GetStringFUTF16(
48 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED_NAME, helper_name_);
49 } else {
50 help_label_text = l10n_util::GetStringUTF16(
51 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED);
52 }
53
54 message_center::RichNotificationData data;
55 data.buttons.push_back(message_center::ButtonInfo(
56 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP)));
57 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
58 std::unique_ptr<Notification> notification(new Notification(
59 message_center::NOTIFICATION_TYPE_SIMPLE, kScreenShareNotificationId,
60 help_label_text, base::string16() /* body is blank */,
61 resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK),
62 base::string16() /* display_source */, GURL(),
63 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
64 system_notifier::kNotifierScreenShare),
65 data, new tray::ScreenNotificationDelegate(this)));
66 notification->SetSystemPriority();
67 message_center::MessageCenter::Get()->AddNotification(
68 std::move(notification));
69 }
70
71 std::string ScreenShareTrayItem::GetNotificationId() {
72 return kScreenShareNotificationId;
73 }
74
75 void ScreenShareTrayItem::RecordStoppedFromDefaultViewMetric() {
76 // Intentionally not recording a metric.
77 }
78
79 void ScreenShareTrayItem::RecordStoppedFromNotificationViewMetric() {
80 // Intentionally not recording a metric.
81 }
82
83 void ScreenShareTrayItem::OnScreenShareStart(
84 const base::Closure& stop_callback,
85 const base::string16& helper_name) {
86 helper_name_ = helper_name;
87 Start(stop_callback);
88 }
89
90 void ScreenShareTrayItem::OnScreenShareStop() {
91 // We do not need to run the stop callback
92 // when screening is stopped externally.
93 set_is_started(false);
94 Update();
95 }
96
97 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698