1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ash/system/chromeos/screen_security/screen_share_tray_item.h" 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ash/shell.h" 8424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "ash/system/system_notifier.h" 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "grit/ash_resources.h" 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "grit/ash_strings.h" 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h" 12bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "ui/base/resource/resource_bundle.h" 13bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "ui/message_center/message_center.h" 14bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "ui/message_center/notification.h" 15bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 16bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdochusing message_center::Notification; 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace ash { 19bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdochnamespace { 20bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 21bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdochconst char kScreenShareNotificationId[] = "chrome://screen/share"; 22bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 23bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch} 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)ScreenShareTrayItem::ScreenShareTrayItem(SystemTray* system_tray) 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) : ScreenTrayItem(system_tray) { 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Shell::GetInstance()->system_tray_notifier()-> 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) AddScreenShareObserver(this); 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)ScreenShareTrayItem::~ScreenShareTrayItem() { 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Shell::GetInstance()->system_tray_notifier()-> 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) RemoveScreenShareObserver(this); 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)views::View* ScreenShareTrayItem::CreateTrayView(user::LoginStatus status) { 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) set_tray_view( 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new tray::ScreenTrayView(this, IDR_AURA_UBER_TRAY_SCREENSHARE)); 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return tray_view(); 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)views::View* ScreenShareTrayItem::CreateDefaultView(user::LoginStatus status) { 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) set_default_view(new tray::ScreenStatusView( 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) this, 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) IDR_AURA_UBER_TRAY_SCREENSHARE_DARK, 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) l10n_util::GetStringUTF16( 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED), 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) l10n_util::GetStringUTF16( 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP))); 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return default_view(); 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 53bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdochvoid ScreenShareTrayItem::CreateOrUpdateNotification() { 54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::string16 help_label_text; 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) if (!helper_name_.empty()) { 56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) help_label_text = l10n_util::GetStringFUTF16( 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED_NAME, 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) helper_name_); 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } else { 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) help_label_text = l10n_util::GetStringUTF16( 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IDS_ASH_STATUS_TRAY_SCREEN_SHARE_BEING_HELPED); 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 64bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch message_center::RichNotificationData data; 65bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch data.buttons.push_back(message_center::ButtonInfo( 66bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SCREEN_SHARE_STOP))); 67bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); 68bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_ptr<Notification> notification(new Notification( 69bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch message_center::NOTIFICATION_TYPE_SIMPLE, 70bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch kScreenShareNotificationId, 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) help_label_text, 72bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch base::string16() /* body is blank */, 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) resource_bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK), 74bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch base::string16() /* display_source */, 75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) message_center::NotifierId( 76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) message_center::NotifierId::SYSTEM_COMPONENT, 77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) system_notifier::kNotifierScreenShare), 78bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch data, 79bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch new tray::ScreenNotificationDelegate(this))); 80bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch notification->SetSystemPriority(); 81bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch message_center::MessageCenter::Get()->AddNotification(notification.Pass()); 82bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch} 83bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 84bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdochstd::string ScreenShareTrayItem::GetNotificationId() { 85bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch return kScreenShareNotificationId; 86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void ScreenShareTrayItem::OnScreenShareStart( 89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::Closure& stop_callback, 90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::string16& helper_name) { 91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) helper_name_ = helper_name; 92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Start(stop_callback); 93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void ScreenShareTrayItem::OnScreenShareStop() { 96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // We do not need to run the stop callback 97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // when screening is stopped externally. 98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) set_is_started(false); 99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Update(); 100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace ash 103