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

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

Issue 2109613005: mash: Move system tray cast code into //ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forward decl Created 4 years, 5 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/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 "grit/ash_resources.h"
13 #include "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) {
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::CreateTrayView(LoginStatus status) {
37 set_tray_view(new tray::ScreenTrayView(this, IDR_AURA_UBER_TRAY_SCREENSHARE));
38 return tray_view();
39 }
40
41 views::View* ScreenShareTrayItem::CreateDefaultView(LoginStatus status) {
42 set_default_view(new tray::ScreenStatusView(
43 this, IDR_AURA_UBER_TRAY_SCREENSHARE_DARK,
44 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED),
45 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP)));
46 return default_view();
47 }
48
49 void ScreenShareTrayItem::CreateOrUpdateNotification() {
50 base::string16 help_label_text;
51 if (!helper_name_.empty()) {
52 help_label_text = l10n_util::GetStringFUTF16(
53 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED_NAME, helper_name_);
54 } else {
55 help_label_text = l10n_util::GetStringUTF16(
56 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED);
57 }
58
59 message_center::RichNotificationData data;
60 data.buttons.push_back(message_center::ButtonInfo(
61 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP)));
62 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
63 std::unique_ptr<Notification> notification(new Notification(
64 message_center::NOTIFICATION_TYPE_SIMPLE, kScreenShareNotificationId,
65 help_label_text, base::string16() /* body is blank */,
66 resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK),
67 base::string16() /* display_source */, GURL(),
68 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
69 system_notifier::kNotifierScreenShare),
70 data, new tray::ScreenNotificationDelegate(this)));
71 notification->SetSystemPriority();
72 message_center::MessageCenter::Get()->AddNotification(
73 std::move(notification));
74 }
75
76 std::string ScreenShareTrayItem::GetNotificationId() {
77 return kScreenShareNotificationId;
78 }
79
80 void ScreenShareTrayItem::OnScreenShareStart(
81 const base::Closure& stop_callback,
82 const base::string16& helper_name) {
83 helper_name_ = helper_name;
84 Start(stop_callback);
85 }
86
87 void ScreenShareTrayItem::OnScreenShareStop() {
88 // We do not need to run the stop callback
89 // when screening is stopped externally.
90 set_is_started(false);
91 Update();
92 }
93
94 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/screen_security/screen_share_tray_item.h ('k') | ash/system/chromeos/screen_security/screen_tray_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698