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

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

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs 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_capture_tray_item.h"
6
7 #include <utility>
8
9 #include "ash/common/metrics/user_metrics_action.h"
10 #include "ash/common/system/system_notifier.h"
11 #include "ash/common/system/tray/system_tray_notifier.h"
12 #include "ash/common/wm_shell.h"
13 #include "ash/resources/grit/ash_resources.h"
14 #include "ash/strings/grit/ash_strings.h"
15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/message_center/message_center.h"
18 #include "ui/message_center/notification.h"
19
20 using message_center::Notification;
21
22 namespace ash {
23 namespace {
24
25 const char kScreenCaptureNotificationId[] = "chrome://screen/capture";
26
27 } // namespace
28
29 ScreenCaptureTrayItem::ScreenCaptureTrayItem(SystemTray* system_tray)
30 : ScreenTrayItem(system_tray, UMA_SCREEN_CAPTURE) {
31 WmShell::Get()->AddShellObserver(this);
32 WmShell::Get()->system_tray_notifier()->AddScreenCaptureObserver(this);
33 }
34
35 ScreenCaptureTrayItem::~ScreenCaptureTrayItem() {
36 WmShell::Get()->RemoveShellObserver(this);
37 WmShell::Get()->system_tray_notifier()->RemoveScreenCaptureObserver(this);
38 }
39
40 views::View* ScreenCaptureTrayItem::CreateDefaultView(LoginStatus status) {
41 set_default_view(new tray::ScreenStatusView(
42 this, screen_capture_status_,
43 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_CAPTURE_STOP)));
44 return default_view();
45 }
46
47 void ScreenCaptureTrayItem::CreateOrUpdateNotification() {
48 message_center::RichNotificationData data;
49 data.buttons.push_back(message_center::ButtonInfo(
50 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_CAPTURE_STOP)));
51 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
52 std::unique_ptr<Notification> notification(new Notification(
53 message_center::NOTIFICATION_TYPE_SIMPLE, kScreenCaptureNotificationId,
54 screen_capture_status_, base::string16() /* body is blank */,
55 resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK),
56 base::string16() /* display_source */, GURL(),
57 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
58 system_notifier::kNotifierScreenCapture),
59 data, new tray::ScreenNotificationDelegate(this)));
60 notification->SetSystemPriority();
61 message_center::MessageCenter::Get()->AddNotification(
62 std::move(notification));
63 }
64
65 std::string ScreenCaptureTrayItem::GetNotificationId() {
66 return kScreenCaptureNotificationId;
67 }
68
69 void ScreenCaptureTrayItem::RecordStoppedFromDefaultViewMetric() {
70 WmShell::Get()->RecordUserMetricsAction(
71 UMA_STATUS_AREA_SCREEN_CAPTURE_DEFAULT_STOP);
72 }
73
74 void ScreenCaptureTrayItem::RecordStoppedFromNotificationViewMetric() {
75 WmShell::Get()->RecordUserMetricsAction(
76 UMA_STATUS_AREA_SCREEN_CAPTURE_NOTIFICATION_STOP);
77 }
78
79 void ScreenCaptureTrayItem::OnScreenCaptureStart(
80 const base::Closure& stop_callback,
81 const base::string16& screen_capture_status) {
82 screen_capture_status_ = screen_capture_status;
83
84 // We do not want to show the screen capture tray item and the chromecast
85 // casting tray item at the same time. We will hide this tray item.
86 //
87 // This suppression technique is currently dependent on the order
88 // that OnScreenCaptureStart and OnCastingSessionStartedOrStopped
89 // get invoked. OnCastingSessionStartedOrStopped currently gets
90 // called first.
91 if (is_casting_)
92 return;
93
94 Start(stop_callback);
95 }
96
97 void ScreenCaptureTrayItem::OnScreenCaptureStop() {
98 // We do not need to run the stop callback when
99 // screen capture is stopped externally.
100 set_is_started(false);
101 Update();
102 }
103
104 void ScreenCaptureTrayItem::OnCastingSessionStartedOrStopped(bool started) {
105 is_casting_ = started;
106 }
107
108 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698