| Index: ash/system/cast/tray_cast.cc
|
| diff --git a/ash/system/cast/tray_cast.cc b/ash/system/cast/tray_cast.cc
|
| index 7d5dd57ec560cef5327e00beafd38491c39a6847..220e259510ce8b96add07d2c69c039a40dae4fa7 100644
|
| --- a/ash/system/cast/tray_cast.cc
|
| +++ b/ash/system/cast/tray_cast.cc
|
| @@ -60,6 +60,7 @@ class CastSelectDefaultView : public TrayItemMore {
|
| const CastConfigDelegate::ReceiversAndActivites& receivers_activities);
|
|
|
| CastConfigDelegate* cast_config_delegate_;
|
| + base::WeakPtrFactory<CastSelectDefaultView> weak_ptr_factory_;
|
| DISALLOW_COPY_AND_ASSIGN(CastSelectDefaultView);
|
| };
|
|
|
| @@ -68,7 +69,8 @@ CastSelectDefaultView::CastSelectDefaultView(
|
| CastConfigDelegate* cast_config_delegate,
|
| bool show_more)
|
| : TrayItemMore(owner, show_more),
|
| - cast_config_delegate_(cast_config_delegate) {
|
| + cast_config_delegate_(cast_config_delegate),
|
| + weak_ptr_factory_(this) {
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| SetImage(rb.GetImageNamed(IDR_AURA_UBER_TRAY_CAST).ToImageSkia());
|
|
|
| @@ -99,8 +101,9 @@ void CastSelectDefaultView::UpdateLabel() {
|
| cast_config_delegate_->HasCastExtension() == false)
|
| return;
|
|
|
| - cast_config_delegate_->GetReceiversAndActivities(base::Bind(
|
| - &CastSelectDefaultView::UpdateLabelCallback, base::Unretained(this)));
|
| + cast_config_delegate_->GetReceiversAndActivities(
|
| + base::Bind(&CastSelectDefaultView::UpdateLabelCallback,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| // This view is displayed when the screen is actively being casted; it allows
|
| @@ -130,12 +133,13 @@ class CastCastView : public views::View, public views::ButtonListener {
|
| views::Label* title_;
|
| views::Label* details_;
|
| TrayPopupLabelButton* stop_button_;
|
| + base::WeakPtrFactory<CastCastView> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CastCastView);
|
| };
|
|
|
| CastCastView::CastCastView(CastConfigDelegate* cast_config_delegate)
|
| - : cast_config_delegate_(cast_config_delegate) {
|
| + : cast_config_delegate_(cast_config_delegate), weak_ptr_factory_(this) {
|
| // We will initialize the primary tray view which shows a stop button here.
|
|
|
| set_background(views::Background::CreateSolidBackground(kBackgroundColor));
|
| @@ -216,8 +220,8 @@ void CastCastView::UpdateLabel() {
|
| cast_config_delegate_->HasCastExtension() == false)
|
| return;
|
|
|
| - cast_config_delegate_->GetReceiversAndActivities(
|
| - base::Bind(&CastCastView::UpdateLabelCallback, base::Unretained(this)));
|
| + cast_config_delegate_->GetReceiversAndActivities(base::Bind(
|
| + &CastCastView::UpdateLabelCallback, weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| void CastCastView::UpdateLabelCallback(
|
| @@ -405,10 +409,11 @@ class CastDetailedView : public TrayDetailsView, public ViewClickListener {
|
|
|
| CastConfigDelegate* cast_config_delegate_;
|
| user::LoginStatus login_;
|
| - views::View* options_;
|
| + views::View* options_ = nullptr;
|
| CastConfigDelegate::ReceiversAndActivites receivers_and_activities_;
|
| // A mapping from the view pointer to the associated activity id
|
| std::map<views::View*, std::string> receiver_activity_map_;
|
| + base::WeakPtrFactory<CastDetailedView> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CastDetailedView);
|
| };
|
| @@ -419,7 +424,7 @@ CastDetailedView::CastDetailedView(SystemTrayItem* owner,
|
| : TrayDetailsView(owner),
|
| cast_config_delegate_(cast_config_delegate),
|
| login_(login),
|
| - options_(nullptr) {
|
| + weak_ptr_factory_(this) {
|
| CreateItems();
|
| UpdateReceiverList();
|
| }
|
| @@ -434,8 +439,9 @@ void CastDetailedView::CreateItems() {
|
| }
|
|
|
| void CastDetailedView::UpdateReceiverList() {
|
| - cast_config_delegate_->GetReceiversAndActivities(base::Bind(
|
| - &CastDetailedView::UpdateReceiverListCallback, base::Unretained(this)));
|
| + cast_config_delegate_->GetReceiversAndActivities(
|
| + base::Bind(&CastDetailedView::UpdateReceiverListCallback,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| void CastDetailedView::UpdateReceiverListCallback(
|
|
|