Chromium Code Reviews| Index: ash/system/tray/media_security/media_tray_item.cc |
| diff --git a/ash/system/tray/media_security/media_tray_item.cc b/ash/system/tray/media_security/media_tray_item.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aecbbd5080446446d48118c47ffb527996e2173f |
| --- /dev/null |
| +++ b/ash/system/tray/media_security/media_tray_item.cc |
| @@ -0,0 +1,83 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ash/system/tray/media_security/media_tray_item.h" |
| + |
| +#include "ash/ash_view_ids.h" |
| +#include "ash/media_delegate.h" |
| +#include "ash/session/session_state_delegate.h" |
| +#include "ash/shell.h" |
| +#include "ash/system/tray/media_security/media_capture_observer.h" |
| +#include "ash/system/tray/system_tray_notifier.h" |
| +#include "ash/system/tray/tray_item_view.h" |
| +#include "grit/ash_resources.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/views/controls/image_view.h" |
| +#include "ui/views/layout/fill_layout.h" |
| + |
| +namespace ash { |
| +namespace tray { |
| + |
| +class MediaTrayView : public TrayItemView, public MediaCaptureObserver { |
| + public: |
| + explicit MediaTrayView(SystemTrayItem* system_tray_item) |
| + : TrayItemView(system_tray_item) { |
| + SetLayoutManager(new views::FillLayout); |
| + views::ImageView* icon = new views::ImageView; |
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| + icon->SetImage( |
| + bundle.GetImageNamed(IDR_AURA_UBER_TRAY_RECORDING).ToImageSkia()); |
| + AddChildView(icon); |
| + OnMediaCaptureChanged(); |
| + Shell::GetInstance()->system_tray_notifier()->AddMediaCaptureObserver(this); |
| + set_id(VIEW_ID_MEDIA_TRAY_VIEW); |
| + } |
| + |
| + virtual ~MediaTrayView() { |
| + Shell::GetInstance()->system_tray_notifier()->RemoveMediaCaptureObserver( |
| + this); |
| + } |
| + |
| + virtual void OnMediaCaptureChanged() OVERRIDE { |
|
Mr4D (OOO till 08-26)
2014/04/30 18:24:36
Please add the
// MediaCaptureObserver overrides
oshima
2014/04/30 20:40:31
Done.
|
| + MediaDelegate* media_delegate = Shell::GetInstance()->media_delegate(); |
| + SessionStateDelegate* session_state_delegate = |
| + Shell::GetInstance()->session_state_delegate(); |
| + // The user at 0 is the current desktop user. |
| + for (MultiProfileIndex index = 1; |
| + index < session_state_delegate->NumberOfLoggedInUsers(); |
| + ++index) { |
| + content::BrowserContext* context = |
| + session_state_delegate->GetBrowserContextByIndex(index); |
|
Mr4D (OOO till 08-26)
2014/04/30 18:24:36
What do we do with visiting windows? Shouldn't we
oshima
2014/04/30 20:40:31
That is handled in GetBackgroundMediaCaptureState.
|
| + if (media_delegate->GetBackgroundMediaCaptureState(context) != |
| + MEDIA_CAPTURE_NONE) { |
| + SetVisible(true); |
| + return; |
| + } |
| + } |
| + SetVisible(false); |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(MediaTrayView); |
| +}; |
| + |
| +} // namespace tray |
| + |
| +MediaTrayItem::MediaTrayItem(SystemTray* system_tray) |
| + : SystemTrayItem(system_tray), tray_view_(NULL) { |
| +} |
|
Mr4D (OOO till 08-26)
2014/04/30 18:24:36
Since this indicator does only get shown for inact
oshima
2014/04/30 20:40:31
There is no "multi user" keyword in ash so far (ex
Mr4D (OOO till 08-26)
2014/05/01 14:36:57
Only because it appears not not to be used (I thin
|
| + |
| +MediaTrayItem::~MediaTrayItem() { |
| +} |
| + |
| +views::View* MediaTrayItem::CreateTrayView(user::LoginStatus status) { |
| + tray_view_ = new tray::MediaTrayView(this); |
| + return tray_view_; |
| +} |
| + |
| +void MediaTrayItem::DestroyTrayView() { |
| + tray_view_ = NULL; |
| +} |
| + |
| +} // namespace ash |