cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / system / tray / media_security / multi_profile_media_tray_item.cc
blob870d4cd46fd8a81a252afdbf6445ebdc841fcbac
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
3 // found in the LICENSE file.
5 #include "ash/system/tray/media_security/multi_profile_media_tray_item.h"
7 #include "ash/ash_view_ids.h"
8 #include "ash/media_delegate.h"
9 #include "ash/session/session_state_delegate.h"
10 #include "ash/shell.h"
11 #include "ash/system/tray/media_security/media_capture_observer.h"
12 #include "ash/system/tray/system_tray_notifier.h"
13 #include "ash/system/tray/tray_item_view.h"
14 #include "grit/ash_resources.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/views/controls/image_view.h"
17 #include "ui/views/layout/fill_layout.h"
19 namespace ash {
20 namespace tray {
22 class MultiProfileMediaTrayView : public TrayItemView,
23 public MediaCaptureObserver {
24 public:
25 explicit MultiProfileMediaTrayView(SystemTrayItem* system_tray_item)
26 : TrayItemView(system_tray_item) {
27 SetLayoutManager(new views::FillLayout);
28 views::ImageView* icon = new views::ImageView;
29 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
30 icon->SetImage(
31 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_RECORDING).ToImageSkia());
32 AddChildView(icon);
33 OnMediaCaptureChanged();
34 Shell::GetInstance()->system_tray_notifier()->AddMediaCaptureObserver(this);
35 set_id(VIEW_ID_MEDIA_TRAY_VIEW);
38 ~MultiProfileMediaTrayView() override {
39 Shell::GetInstance()->system_tray_notifier()->RemoveMediaCaptureObserver(
40 this);
43 // MediaCaptureObserver:
44 void OnMediaCaptureChanged() override {
45 MediaDelegate* media_delegate = Shell::GetInstance()->media_delegate();
46 SessionStateDelegate* session_state_delegate =
47 Shell::GetInstance()->session_state_delegate();
48 // The user at 0 is the current desktop user.
49 for (MultiProfileIndex index = 1;
50 index < session_state_delegate->NumberOfLoggedInUsers();
51 ++index) {
52 content::BrowserContext* context =
53 session_state_delegate->GetBrowserContextByIndex(index);
54 if (media_delegate->GetMediaCaptureState(context) != MEDIA_CAPTURE_NONE) {
55 SetVisible(true);
56 return;
59 SetVisible(false);
62 private:
63 DISALLOW_COPY_AND_ASSIGN(MultiProfileMediaTrayView);
66 } // namespace tray
68 MultiProfileMediaTrayItem::MultiProfileMediaTrayItem(SystemTray* system_tray)
69 : SystemTrayItem(system_tray), tray_view_(NULL) {
72 MultiProfileMediaTrayItem::~MultiProfileMediaTrayItem() {
75 views::View* MultiProfileMediaTrayItem::CreateTrayView(
76 user::LoginStatus status) {
77 tray_view_ = new tray::MultiProfileMediaTrayView(this);
78 return tray_view_;
81 void MultiProfileMediaTrayItem::DestroyTrayView() {
82 tray_view_ = NULL;
85 } // namespace ash