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

Side by Side Diff: ash/system/chromeos/media_security/multi_profile_media_tray_item.cc

Issue 2098023002: mash: Migrate remaining tray observers and notify functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/tray/media_security/multi_profile_media_tray_item.h" 5 #include "ash/system/chromeos/media_security/multi_profile_media_tray_item.h"
6 6
7 #include "ash/ash_view_ids.h" 7 #include "ash/ash_view_ids.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/system/chromeos/media_security/media_capture_observer.h"
10 #include "ash/common/system/tray/system_tray_notifier.h"
9 #include "ash/common/system/tray/tray_item_view.h" 11 #include "ash/common/system/tray/tray_item_view.h"
12 #include "ash/common/wm_shell.h"
10 #include "ash/media_delegate.h" 13 #include "ash/media_delegate.h"
11 #include "ash/shell.h" 14 #include "ash/shell.h"
12 #include "ash/system/tray/media_security/media_capture_observer.h"
13 #include "ash/system/tray/system_tray_notifier.h"
14 #include "grit/ash_resources.h" 15 #include "grit/ash_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
17 #include "ui/views/layout/fill_layout.h" 18 #include "ui/views/layout/fill_layout.h"
18 19
19 namespace ash { 20 namespace ash {
20 namespace tray { 21 namespace tray {
21 22
22 class MultiProfileMediaTrayView : public TrayItemView, 23 class MultiProfileMediaTrayView : public TrayItemView,
23 public MediaCaptureObserver { 24 public MediaCaptureObserver {
24 public: 25 public:
25 explicit MultiProfileMediaTrayView(SystemTrayItem* system_tray_item) 26 explicit MultiProfileMediaTrayView(SystemTrayItem* system_tray_item)
26 : TrayItemView(system_tray_item) { 27 : TrayItemView(system_tray_item) {
27 SetLayoutManager(new views::FillLayout); 28 SetLayoutManager(new views::FillLayout);
28 views::ImageView* icon = new views::ImageView; 29 views::ImageView* icon = new views::ImageView;
29 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 30 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
30 icon->SetImage( 31 icon->SetImage(
31 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_RECORDING).ToImageSkia()); 32 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_RECORDING).ToImageSkia());
32 AddChildView(icon); 33 AddChildView(icon);
33 OnMediaCaptureChanged(); 34 OnMediaCaptureChanged();
34 Shell::GetInstance()->system_tray_notifier()->AddMediaCaptureObserver(this); 35 WmShell::Get()->system_tray_notifier()->AddMediaCaptureObserver(this);
35 set_id(VIEW_ID_MEDIA_TRAY_VIEW); 36 set_id(VIEW_ID_MEDIA_TRAY_VIEW);
36 } 37 }
37 38
38 ~MultiProfileMediaTrayView() override { 39 ~MultiProfileMediaTrayView() override {
39 Shell::GetInstance()->system_tray_notifier()->RemoveMediaCaptureObserver( 40 WmShell::Get()->system_tray_notifier()->RemoveMediaCaptureObserver(this);
40 this);
41 } 41 }
42 42
43 // MediaCaptureObserver: 43 // MediaCaptureObserver:
44 void OnMediaCaptureChanged() override { 44 void OnMediaCaptureChanged() override {
45 MediaDelegate* media_delegate = Shell::GetInstance()->media_delegate(); 45 MediaDelegate* media_delegate = Shell::GetInstance()->media_delegate();
46 SessionStateDelegate* session_state_delegate = 46 SessionStateDelegate* session_state_delegate =
47 Shell::GetInstance()->session_state_delegate(); 47 WmShell::Get()->GetSessionStateDelegate();
48 // The user at 0 is the current desktop user. 48 // The user at 0 is the current desktop user.
49 for (UserIndex index = 1; 49 for (UserIndex index = 1;
50 index < session_state_delegate->NumberOfLoggedInUsers(); ++index) { 50 index < session_state_delegate->NumberOfLoggedInUsers(); ++index) {
51 if (media_delegate->GetMediaCaptureState(index) != MEDIA_CAPTURE_NONE) { 51 if (media_delegate->GetMediaCaptureState(index) != MEDIA_CAPTURE_NONE) {
52 SetVisible(true); 52 SetVisible(true);
53 return; 53 return;
54 } 54 }
55 } 55 }
56 SetVisible(false); 56 SetVisible(false);
57 } 57 }
(...skipping 14 matching lines...) Expand all
72 views::View* MultiProfileMediaTrayItem::CreateTrayView(LoginStatus status) { 72 views::View* MultiProfileMediaTrayItem::CreateTrayView(LoginStatus status) {
73 tray_view_ = new tray::MultiProfileMediaTrayView(this); 73 tray_view_ = new tray::MultiProfileMediaTrayView(this);
74 return tray_view_; 74 return tray_view_;
75 } 75 }
76 76
77 void MultiProfileMediaTrayItem::DestroyTrayView() { 77 void MultiProfileMediaTrayItem::DestroyTrayView() {
78 tray_view_ = NULL; 78 tray_view_ = NULL;
79 } 79 }
80 80
81 } // namespace ash 81 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698