OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/chromeos/screen_security/screen_capture_tray_item.h" | 5 #include "ash/system/chromeos/screen_security/screen_capture_tray_item.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/system_notifier.h" | 8 #include "ash/system/system_notifier.h" |
9 #include "grit/ash_resources.h" | 9 #include "grit/ash_resources.h" |
10 #include "grit/ash_strings.h" | 10 #include "grit/ash_strings.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/message_center/message_center.h" | 13 #include "ui/message_center/message_center.h" |
14 #include "ui/message_center/notification.h" | 14 #include "ui/message_center/notification.h" |
15 | 15 |
16 using message_center::Notification; | 16 using message_center::Notification; |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char kScreenCaptureNotificationId[] = "chrome://screen/capture"; | 21 const char kScreenCaptureNotificationId[] = "chrome://screen/capture"; |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 ScreenCaptureTrayItem::ScreenCaptureTrayItem(SystemTray* system_tray) | 25 ScreenCaptureTrayItem::ScreenCaptureTrayItem(SystemTray* system_tray) |
26 : ScreenTrayItem(system_tray) { | 26 : ScreenTrayItem(system_tray) { |
27 Shell::GetInstance()->AddShellObserver(this); | |
27 Shell::GetInstance()->system_tray_notifier()-> | 28 Shell::GetInstance()->system_tray_notifier()-> |
28 AddScreenCaptureObserver(this); | 29 AddScreenCaptureObserver(this); |
29 } | 30 } |
30 | 31 |
31 ScreenCaptureTrayItem::~ScreenCaptureTrayItem() { | 32 ScreenCaptureTrayItem::~ScreenCaptureTrayItem() { |
33 Shell::GetInstance()->RemoveShellObserver(this); | |
32 Shell::GetInstance()->system_tray_notifier()-> | 34 Shell::GetInstance()->system_tray_notifier()-> |
33 RemoveScreenCaptureObserver(this); | 35 RemoveScreenCaptureObserver(this); |
34 } | 36 } |
35 | 37 |
36 views::View* ScreenCaptureTrayItem::CreateTrayView(user::LoginStatus status) { | 38 views::View* ScreenCaptureTrayItem::CreateTrayView(user::LoginStatus status) { |
37 set_tray_view( | 39 set_tray_view( |
38 new tray::ScreenTrayView(this, IDR_AURA_UBER_TRAY_SCREENSHARE)); | 40 new tray::ScreenTrayView(this, IDR_AURA_UBER_TRAY_SCREENSHARE)); |
39 return tray_view(); | 41 return tray_view(); |
40 } | 42 } |
41 | 43 |
(...skipping 30 matching lines...) Expand all Loading... | |
72 } | 74 } |
73 | 75 |
74 std::string ScreenCaptureTrayItem::GetNotificationId() { | 76 std::string ScreenCaptureTrayItem::GetNotificationId() { |
75 return kScreenCaptureNotificationId; | 77 return kScreenCaptureNotificationId; |
76 } | 78 } |
77 | 79 |
78 void ScreenCaptureTrayItem::OnScreenCaptureStart( | 80 void ScreenCaptureTrayItem::OnScreenCaptureStart( |
79 const base::Closure& stop_callback, | 81 const base::Closure& stop_callback, |
80 const base::string16& screen_capture_status) { | 82 const base::string16& screen_capture_status) { |
81 screen_capture_status_ = screen_capture_status; | 83 screen_capture_status_ = screen_capture_status; |
84 | |
85 // This suppression technique is currently dependent on the order | |
86 // that OnScreenCaptureStart and OnCastingSessionStartedOrStopped | |
87 // get invoked. OnCastingSessionStartedOrStopped currently gets | |
88 // called first. | |
89 // | |
90 // TODO(jdufault): Does this break casting and capturing the screen at the | |
achuithb
2015/05/06 20:02:32
Remove TODO?
jdufault
2015/05/06 21:17:33
Done.
| |
91 // same time? | |
92 if (is_casting_) | |
93 return; | |
94 | |
82 Start(stop_callback); | 95 Start(stop_callback); |
83 } | 96 } |
84 | 97 |
85 void ScreenCaptureTrayItem::OnScreenCaptureStop() { | 98 void ScreenCaptureTrayItem::OnScreenCaptureStop() { |
86 // We do not need to run the stop callback when | 99 // We do not need to run the stop callback when |
87 // screen capture is stopped externally. | 100 // screen capture is stopped externally. |
88 set_is_started(false); | 101 set_is_started(false); |
89 Update(); | 102 Update(); |
90 } | 103 } |
91 | 104 |
105 void ScreenCaptureTrayItem::OnCastingSessionStartedOrStopped(bool started) { | |
106 is_casting_ = started; | |
107 } | |
108 | |
92 } // namespace ash | 109 } // namespace ash |
OLD | NEW |