Commit ba5bc092 authored by jdufault's avatar jdufault Committed by Commit bot

Add UI for cast system tray integration

- TrayCast is the central injection point for the UI code
- TrayCast itself just delegates between two other views, of which only one is active at a time depending on if the device is currently casting
- ScreenCaptureTrayItem is disabled so it will not be active when the device is casting (otherwise there would be two very similar tray items that have the same functionality but slightly different appearance)

BUG=433140

Review URL: https://codereview.chromium.org/1118613003

Cr-Commit-Position: refs/heads/master@{#330398}
parent 0cb19571
...@@ -278,6 +278,8 @@ ...@@ -278,6 +278,8 @@
'system/bluetooth/tray_bluetooth.cc', 'system/bluetooth/tray_bluetooth.cc',
'system/bluetooth/tray_bluetooth.h', 'system/bluetooth/tray_bluetooth.h',
'system/brightness_control_delegate.h', 'system/brightness_control_delegate.h',
'system/cast/tray_cast.cc',
'system/cast/tray_cast.h',
'system/chromeos/audio/audio_detailed_view.cc', 'system/chromeos/audio/audio_detailed_view.cc',
'system/chromeos/audio/audio_detailed_view.h', 'system/chromeos/audio/audio_detailed_view.h',
'system/chromeos/audio/tray_audio_chromeos.cc', 'system/chromeos/audio/tray_audio_chromeos.cc',
......
This diff is collapsed.
// Copyright 2015 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.
#ifndef ASH_SYSTEM_CAST_TRAY_CAST_H_
#define ASH_SYSTEM_CAST_TRAY_CAST_H_
#include "ash/shell_observer.h"
#include "ash/system/tray/system_tray_item.h"
namespace ash {
namespace tray {
class CastTrayView;
class CastSelectDefaultView;
class CastDetailedView;
class CastDuplexView;
} // namespace tray
class CastConfigDelegate;
class TrayCast : public SystemTrayItem, public ShellObserver {
public:
explicit TrayCast(SystemTray* system_tray);
~TrayCast() override;
private:
bool HasCastExtension();
// Overridden from SystemTrayItem.
views::View* CreateTrayView(user::LoginStatus status) override;
views::View* CreateDefaultView(user::LoginStatus status) override;
views::View* CreateDetailedView(user::LoginStatus status) override;
void DestroyTrayView() override;
void DestroyDefaultView() override;
void DestroyDetailedView() override;
void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override;
// Overridden from ShellObserver.
void OnCastingSessionStartedOrStopped(bool started) override;
// This makes sure that the current view displayed in the tray is the correct
// one, depending on if we are currently casting. If we're casting, then a
// view with a stop button is displayed; otherwise, a view that links to a
// detail view is displayed instead that allows the user to easily begin a
// casting session.
void UpdatePrimaryView();
bool is_casting_ = false;
// Not owned.
tray::CastTrayView* tray_ = nullptr;
tray::CastDuplexView* default_ = nullptr;
tray::CastDetailedView* detailed_ = nullptr;
CastConfigDelegate* cast_config_delegate_;
DISALLOW_COPY_AND_ASSIGN(TrayCast);
};
} // namespace ash
#endif // ASH_SYSTEM_CAST_TRAY_CAST_H_
...@@ -24,11 +24,13 @@ const char kScreenCaptureNotificationId[] = "chrome://screen/capture"; ...@@ -24,11 +24,13 @@ const char kScreenCaptureNotificationId[] = "chrome://screen/capture";
ScreenCaptureTrayItem::ScreenCaptureTrayItem(SystemTray* system_tray) ScreenCaptureTrayItem::ScreenCaptureTrayItem(SystemTray* system_tray)
: ScreenTrayItem(system_tray) { : ScreenTrayItem(system_tray) {
Shell::GetInstance()->AddShellObserver(this);
Shell::GetInstance()->system_tray_notifier()-> Shell::GetInstance()->system_tray_notifier()->
AddScreenCaptureObserver(this); AddScreenCaptureObserver(this);
} }
ScreenCaptureTrayItem::~ScreenCaptureTrayItem() { ScreenCaptureTrayItem::~ScreenCaptureTrayItem() {
Shell::GetInstance()->RemoveShellObserver(this);
Shell::GetInstance()->system_tray_notifier()-> Shell::GetInstance()->system_tray_notifier()->
RemoveScreenCaptureObserver(this); RemoveScreenCaptureObserver(this);
} }
...@@ -79,6 +81,17 @@ void ScreenCaptureTrayItem::OnScreenCaptureStart( ...@@ -79,6 +81,17 @@ void ScreenCaptureTrayItem::OnScreenCaptureStart(
const base::Closure& stop_callback, const base::Closure& stop_callback,
const base::string16& screen_capture_status) { const base::string16& screen_capture_status) {
screen_capture_status_ = screen_capture_status; screen_capture_status_ = screen_capture_status;
// We do not want to show the screen capture tray item and the chromecast
// casting tray item at the same time. We will hide this tray item.
//
// This suppression technique is currently dependent on the order
// that OnScreenCaptureStart and OnCastingSessionStartedOrStopped
// get invoked. OnCastingSessionStartedOrStopped currently gets
// called first.
if (is_casting_)
return;
Start(stop_callback); Start(stop_callback);
} }
...@@ -89,4 +102,8 @@ void ScreenCaptureTrayItem::OnScreenCaptureStop() { ...@@ -89,4 +102,8 @@ void ScreenCaptureTrayItem::OnScreenCaptureStop() {
Update(); Update();
} }
void ScreenCaptureTrayItem::OnCastingSessionStartedOrStopped(bool started) {
is_casting_ = started;
}
} // namespace ash } // namespace ash
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef ASH_SYSTEM_CHROMEOS_SCREEN_CAPTURE_SCREEN_CAPTURE_TRAY_ITEM_H_ #ifndef ASH_SYSTEM_CHROMEOS_SCREEN_CAPTURE_SCREEN_CAPTURE_TRAY_ITEM_H_
#define ASH_SYSTEM_CHROMEOS_SCREEN_CAPTURE_SCREEN_CAPTURE_TRAY_ITEM_H_ #define ASH_SYSTEM_CHROMEOS_SCREEN_CAPTURE_SCREEN_CAPTURE_TRAY_ITEM_H_
#include "ash/shell_observer.h"
#include "ash/system/chromeos/screen_security/screen_capture_observer.h" #include "ash/system/chromeos/screen_security/screen_capture_observer.h"
#include "ash/system/chromeos/screen_security/screen_tray_item.h" #include "ash/system/chromeos/screen_security/screen_tray_item.h"
...@@ -15,7 +16,8 @@ class View; ...@@ -15,7 +16,8 @@ class View;
namespace ash { namespace ash {
class ASH_EXPORT ScreenCaptureTrayItem : public ScreenTrayItem, class ASH_EXPORT ScreenCaptureTrayItem : public ScreenTrayItem,
public ScreenCaptureObserver { public ScreenCaptureObserver,
public ShellObserver {
public: public:
explicit ScreenCaptureTrayItem(SystemTray* system_tray); explicit ScreenCaptureTrayItem(SystemTray* system_tray);
~ScreenCaptureTrayItem() override; ~ScreenCaptureTrayItem() override;
...@@ -35,7 +37,11 @@ class ASH_EXPORT ScreenCaptureTrayItem : public ScreenTrayItem, ...@@ -35,7 +37,11 @@ class ASH_EXPORT ScreenCaptureTrayItem : public ScreenTrayItem,
const base::string16& screen_capture_status) override; const base::string16& screen_capture_status) override;
void OnScreenCaptureStop() override; void OnScreenCaptureStop() override;
// Overridden from ShellObserver.
void OnCastingSessionStartedOrStopped(bool started) override;
base::string16 screen_capture_status_; base::string16 screen_capture_status_;
bool is_casting_ = false;
DISALLOW_COPY_AND_ASSIGN(ScreenCaptureTrayItem); DISALLOW_COPY_AND_ASSIGN(ScreenCaptureTrayItem);
}; };
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/system/audio/tray_audio.h" #include "ash/system/audio/tray_audio.h"
#include "ash/system/bluetooth/tray_bluetooth.h" #include "ash/system/bluetooth/tray_bluetooth.h"
#include "ash/system/cast/tray_cast.h"
#include "ash/system/date/tray_date.h" #include "ash/system/date/tray_date.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_delegate.h"
...@@ -181,6 +182,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) { ...@@ -181,6 +182,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
AddTrayItem(new TrayVPN(this)); AddTrayItem(new TrayVPN(this));
AddTrayItem(new TraySms(this)); AddTrayItem(new TraySms(this));
AddTrayItem(new TrayBluetooth(this)); AddTrayItem(new TrayBluetooth(this));
AddTrayItem(new TrayCast(this));
AddTrayItem(new TrayDisplay(this)); AddTrayItem(new TrayDisplay(this));
screen_capture_tray_item_ = new ScreenCaptureTrayItem(this); screen_capture_tray_item_ = new ScreenCaptureTrayItem(this);
AddTrayItem(screen_capture_tray_item_); AddTrayItem(screen_capture_tray_item_);
...@@ -203,6 +205,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) { ...@@ -203,6 +205,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
AddTrayItem(tray_accessibility_); AddTrayItem(tray_accessibility_);
AddTrayItem(new TrayBluetooth(this)); AddTrayItem(new TrayBluetooth(this));
AddTrayItem(new TrayCast(this));
AddTrayItem(new TrayUpdate(this)); AddTrayItem(new TrayUpdate(this));
AddTrayItem(tray_date_); AddTrayItem(tray_date_);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment