| 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_share_tray_item.h" | 5 #include "ash/system/chromeos/screen_security/screen_share_tray_item.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/system/system_notifier.h" | 9 #include "ash/common/system/system_notifier.h" |
| 10 #include "ash/common/system/tray/system_tray_notifier.h" | 10 #include "ash/common/system/tray/system_tray_notifier.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "grit/ash_resources.h" | 12 #include "grit/ash_resources.h" |
| 13 #include "grit/ash_strings.h" | 13 #include "grit/ash_strings.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/message_center/message_center.h" | 16 #include "ui/message_center/message_center.h" |
| 17 #include "ui/message_center/notification.h" | 17 #include "ui/message_center/notification.h" |
| 18 | 18 |
| 19 using message_center::Notification; | 19 using message_center::Notification; |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kScreenShareNotificationId[] = "chrome://screen/share"; | 24 const char kScreenShareNotificationId[] = "chrome://screen/share"; |
| 25 | |
| 26 } | 25 } |
| 27 | 26 |
| 28 ScreenShareTrayItem::ScreenShareTrayItem(SystemTray* system_tray) | 27 ScreenShareTrayItem::ScreenShareTrayItem(SystemTray* system_tray) |
| 29 : ScreenTrayItem(system_tray) { | 28 : ScreenTrayItem(system_tray) { |
| 30 WmShell::Get()->system_tray_notifier()->AddScreenShareObserver(this); | 29 WmShell::Get()->system_tray_notifier()->AddScreenShareObserver(this); |
| 31 } | 30 } |
| 32 | 31 |
| 33 ScreenShareTrayItem::~ScreenShareTrayItem() { | 32 ScreenShareTrayItem::~ScreenShareTrayItem() { |
| 34 WmShell::Get()->system_tray_notifier()->RemoveScreenShareObserver(this); | 33 WmShell::Get()->system_tray_notifier()->RemoveScreenShareObserver(this); |
| 35 } | 34 } |
| 36 | 35 |
| 37 views::View* ScreenShareTrayItem::CreateTrayView(LoginStatus status) { | 36 views::View* ScreenShareTrayItem::CreateTrayView(LoginStatus status) { |
| 38 set_tray_view( | 37 set_tray_view(new tray::ScreenTrayView(this, IDR_AURA_UBER_TRAY_SCREENSHARE)); |
| 39 new tray::ScreenTrayView(this, IDR_AURA_UBER_TRAY_SCREENSHARE)); | |
| 40 return tray_view(); | 38 return tray_view(); |
| 41 } | 39 } |
| 42 | 40 |
| 43 views::View* ScreenShareTrayItem::CreateDefaultView(LoginStatus status) { | 41 views::View* ScreenShareTrayItem::CreateDefaultView(LoginStatus status) { |
| 44 set_default_view(new tray::ScreenStatusView( | 42 set_default_view(new tray::ScreenStatusView( |
| 45 this, | 43 this, IDR_AURA_UBER_TRAY_SCREENSHARE_DARK, |
| 46 IDR_AURA_UBER_TRAY_SCREENSHARE_DARK, | 44 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED), |
| 47 l10n_util::GetStringUTF16( | 45 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP))); |
| 48 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED), | |
| 49 l10n_util::GetStringUTF16( | |
| 50 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP))); | |
| 51 return default_view(); | 46 return default_view(); |
| 52 } | 47 } |
| 53 | 48 |
| 54 void ScreenShareTrayItem::CreateOrUpdateNotification() { | 49 void ScreenShareTrayItem::CreateOrUpdateNotification() { |
| 55 base::string16 help_label_text; | 50 base::string16 help_label_text; |
| 56 if (!helper_name_.empty()) { | 51 if (!helper_name_.empty()) { |
| 57 help_label_text = l10n_util::GetStringFUTF16( | 52 help_label_text = l10n_util::GetStringFUTF16( |
| 58 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED_NAME, | 53 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED_NAME, helper_name_); |
| 59 helper_name_); | |
| 60 } else { | 54 } else { |
| 61 help_label_text = l10n_util::GetStringUTF16( | 55 help_label_text = l10n_util::GetStringUTF16( |
| 62 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED); | 56 IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED); |
| 63 } | 57 } |
| 64 | 58 |
| 65 message_center::RichNotificationData data; | 59 message_center::RichNotificationData data; |
| 66 data.buttons.push_back(message_center::ButtonInfo( | 60 data.buttons.push_back(message_center::ButtonInfo( |
| 67 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP))); | 61 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP))); |
| 68 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); | 62 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); |
| 69 std::unique_ptr<Notification> notification(new Notification( | 63 std::unique_ptr<Notification> notification(new Notification( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 91 } | 85 } |
| 92 | 86 |
| 93 void ScreenShareTrayItem::OnScreenShareStop() { | 87 void ScreenShareTrayItem::OnScreenShareStop() { |
| 94 // We do not need to run the stop callback | 88 // We do not need to run the stop callback |
| 95 // when screening is stopped externally. | 89 // when screening is stopped externally. |
| 96 set_is_started(false); | 90 set_is_started(false); |
| 97 Update(); | 91 Update(); |
| 98 } | 92 } |
| 99 | 93 |
| 100 } // namespace ash | 94 } // namespace ash |
| OLD | NEW |