summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-19 00:30:06 +0000
committerjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-19 00:30:06 +0000
commitd65e39748cc8cbd5e6a0a6a3faf650ff3ad2eb18 (patch)
tree24938491a54f525834ef3b99501bb0e9f8ebaae6 /ash
parentf9166481660aec9ddf53846cc5d339e661a90ec2 (diff)
downloadchromium_src-d65e39748cc8cbd5e6a0a6a3faf650ff3ad2eb18.zip
chromium_src-d65e39748cc8cbd5e6a0a6a3faf650ff3ad2eb18.tar.gz
chromium_src-d65e39748cc8cbd5e6a0a6a3faf650ff3ad2eb18.tar.bz2
New screen capture feature UI in ash tray, UI mock see in bug description. This cl only contains the UI code.
BUG=190206 TBR=jamescook Review URL: https://chromiumcodereview.appspot.com/12494025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188885 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp3
-rw-r--r--ash/ash_chromeos_strings.grdp8
-rw-r--r--ash/resources/ash_resources.grd1
-rw-r--r--ash/system/chromeos/screen_capture/tray_screen_capture.cc273
-rw-r--r--ash/system/chromeos/screen_capture/tray_screen_capture.h57
-rw-r--r--ash/system/tray/system_tray.cc4
6 files changed, 345 insertions, 1 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 87b783b..ee03219 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -209,6 +209,9 @@
'system/chromeos/network/tray_sms.h',
'system/chromeos/network/tray_vpn.cc',
'system/chromeos/network/tray_vpn.h',
+ 'system/chromeos/screen_capture/screen_capture_observer.h',
+ 'system/chromeos/screen_capture/tray_screen_capture.cc',
+ 'system/chromeos/screen_capture/tray_screen_capture.h',
'system/chromeos/tray_display.cc',
'system/chromeos/tray_display.h',
'system/date/clock_observer.h',
diff --git a/ash/ash_chromeos_strings.grdp b/ash/ash_chromeos_strings.grdp
index 221d0c2..813c9e3 100644
--- a/ash/ash_chromeos_strings.grdp
+++ b/ash/ash_chromeos_strings.grdp
@@ -218,4 +218,12 @@
Unrecognized error
</message>
+ <!-- Status Tray ScreenCapture strings -->
+ <message name="IDS_ASH_STATUS_TRAY_SCREEN_CAPTURE_STATUS" desc="label used in screen capture bubble and ash tray bubble to show the screen sharing status">
+ Sharing screen with another device
+ </message>
+ <message name="IDS_ASH_STATUS_TRAY_SCREEN_CAPTURE_STOP" desc="label used for screen sharing stop button">
+ Stop
+ </message>
+
</grit-part>
diff --git a/ash/resources/ash_resources.grd b/ash/resources/ash_resources.grd
index b9f267e..2a6621d 100644
--- a/ash/resources/ash_resources.grd
+++ b/ash/resources/ash_resources.grd
@@ -96,6 +96,7 @@
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_CELLULAR_ENABLED" file="cros/network/status_cellular_enabled.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_CELLULAR_ENABLED_HOVER" file="cros/network/status_cellular_enabled_hover.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_DISPLAY" file="cros/status/status_display_dark.png" />
+ <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_DISPLAY_LIGHT" file="cros/status/status_display.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_DRIVE" file="cros/status/status_drive.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_DRIVE_CANCEL" file="cros/status/status_drive_item_cancel.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_DRIVE_CANCEL_HOVER" file="cros/status/status_drive_item_cancel_hover.png" />
diff --git a/ash/system/chromeos/screen_capture/tray_screen_capture.cc b/ash/system/chromeos/screen_capture/tray_screen_capture.cc
new file mode 100644
index 0000000..2d88946
--- /dev/null
+++ b/ash/system/chromeos/screen_capture/tray_screen_capture.cc
@@ -0,0 +1,273 @@
+// Copyright (c) 2013 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/chromeos/screen_capture/tray_screen_capture.h"
+
+#include "ash/shell.h"
+#include "ash/system/tray/fixed_sized_image_view.h"
+#include "ash/system/tray/system_tray.h"
+#include "ash/system/tray/system_tray_notifier.h"
+#include "ash/system/tray/tray_constants.h"
+#include "ash/system/tray/tray_item_view.h"
+#include "ash/system/tray/tray_notification_view.h"
+#include "ash/system/tray/tray_views.h"
+#include "grit/ash_resources.h"
+#include "grit/ash_strings.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/controls/image_view.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace {
+const int kStopButtonRightPaddingDefaultView = 18;
+const int kStopButtonRightPaddingNotificationView = 0;
+const int kStopButtonLeftPaddingNotificationView = 4;
+const int kVerticalPaddingScreenCaptureNotitification = 12;
+} // namespace
+
+namespace ash {
+namespace internal {
+
+namespace tray {
+
+class ScreenCaptureTrayView : public TrayItemView {
+ public:
+ explicit ScreenCaptureTrayView(TrayScreenCapture* tray_screen_capture)
+ : TrayItemView(tray_screen_capture),
+ tray_screen_capture_(tray_screen_capture) {
+ CreateImageView();
+ image_view()->SetImage(ui::ResourceBundle::GetSharedInstance().
+ GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY_LIGHT).ToImageSkia());
+
+ Update();
+ }
+ virtual ~ScreenCaptureTrayView() {
+ }
+
+ void Update() {
+ SetVisible(tray_screen_capture_->IsScreenCaptureOn());
+ }
+
+ private:
+ TrayScreenCapture* tray_screen_capture_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenCaptureTrayView);
+};
+
+class ScreenCaptureStatusView : public views::View,
+ public views::ButtonListener {
+ public:
+ enum ViewType {
+ VIEW_DEFAULT,
+ VIEW_NOTIFICATION
+ };
+
+ explicit ScreenCaptureStatusView(TrayScreenCapture* tray_screen_capture,
+ ViewType view_type)
+ : icon_(NULL),
+ label_(NULL),
+ stop_button_(NULL),
+ tray_screen_capture_(tray_screen_capture),
+ view_type_(view_type) {
+ CreateItems();
+ Update();
+ }
+
+ virtual ~ScreenCaptureStatusView() {
+ }
+
+ // Overridden from views::View.
+ virtual void Layout() OVERRIDE {
+ views::View::Layout();
+
+ int stop_button_right_padding =
+ view_type_ == VIEW_DEFAULT ?
+ kStopButtonRightPaddingDefaultView :
+ kStopButtonRightPaddingNotificationView;
+ int stop_button_left_padding =
+ view_type_ == VIEW_DEFAULT ?
+ kTrayPopupPaddingBetweenItems :
+ kStopButtonLeftPaddingNotificationView;
+ // Give the stop button the space it requests.
+ gfx::Size stop_size = stop_button_->GetPreferredSize();
+ gfx::Rect stop_bounds(stop_size);
+ stop_bounds.set_x(width() - stop_size.width() - stop_button_right_padding);
+ stop_bounds.set_y((height() - stop_size.height()) / 2);
+ stop_button_->SetBoundsRect(stop_bounds);
+
+ // Adjust the label's bounds in case it got cut off by |stop_button_|.
+ if (label_->bounds().Intersects(stop_button_->bounds())) {
+ gfx::Rect label_bounds = label_->bounds();
+ label_bounds.set_width(
+ stop_button_->x() - stop_button_left_padding - label_->x());
+ label_->SetBoundsRect(label_bounds);
+ }
+ }
+
+ // Overridden from views::ButtonListener.
+ virtual void ButtonPressed(views::Button* sender,
+ const ui::Event& event) OVERRIDE {
+ DCHECK(sender == stop_button_);
+ tray_screen_capture_->SetScreenCaptureOn(false);
+ tray_screen_capture_->Update();
+ }
+
+ void CreateItems() {
+ set_background(views::Background::CreateSolidBackground(kBackgroundColor));
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ if (view_type_ == VIEW_DEFAULT) {
+ SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
+ kTrayPopupPaddingHorizontal,
+ 0,
+ kTrayPopupPaddingBetweenItems));
+ icon_ = new FixedSizedImageView(0, kTrayPopupItemHeight);
+ icon_->SetImage(
+ bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY).ToImageSkia());
+ AddChildView(icon_);
+ } else {
+ SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal,
+ 0,
+ kVerticalPaddingScreenCaptureNotitification,
+ 0));
+ }
+
+ label_ = new views::Label;
+ label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ label_->SetMultiLine(true);
+ label_->SetText(bundle.GetLocalizedString(
+ IDS_ASH_STATUS_TRAY_SCREEN_CAPTURE_STATUS));
+ AddChildView(label_);
+
+ stop_button_ = new TrayPopupLabelButton(
+ this,
+ bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_SCREEN_CAPTURE_STOP));
+ AddChildView(stop_button_);
+ }
+
+ void Update() {
+ if (view_type_ == VIEW_DEFAULT) {
+ // Hide the notification bubble when the ash tray bubble opens.
+ tray_screen_capture_->HideNotificationView();
+ SetVisible(tray_screen_capture_->IsScreenCaptureOn());
+ }
+ }
+
+ private:
+ views::ImageView* icon_;
+ views::Label* label_;
+ TrayPopupLabelButton* stop_button_;
+ TrayScreenCapture* tray_screen_capture_;
+ ViewType view_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenCaptureStatusView);
+};
+
+class ScreenCaptureNotificationView : public TrayNotificationView {
+ public:
+ explicit ScreenCaptureNotificationView(TrayScreenCapture* tray_screen_capture)
+ : TrayNotificationView(tray_screen_capture, IDR_AURA_UBER_TRAY_DISPLAY),
+ tray_screen_capture_(tray_screen_capture) {
+ screen_capture_status_view_ =
+ new ScreenCaptureStatusView(
+ tray_screen_capture, ScreenCaptureStatusView::VIEW_NOTIFICATION);
+ InitView(screen_capture_status_view_);
+ }
+
+ virtual ~ScreenCaptureNotificationView() {
+ }
+
+ void Update() {
+ if (tray_screen_capture_->IsScreenCaptureOn())
+ screen_capture_status_view_->Update();
+ else
+ tray_screen_capture_->HideNotificationView();
+ }
+
+ private:
+ TrayScreenCapture* tray_screen_capture_;
+ ScreenCaptureStatusView* screen_capture_status_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenCaptureNotificationView);
+};
+
+} // namespace tray
+
+TrayScreenCapture::TrayScreenCapture(SystemTray* system_tray)
+ : SystemTrayItem(system_tray),
+ tray_(NULL),
+ default_(NULL),
+ notification_(NULL) {
+ // TODO(jennyz): Observe the screen capture notification.
+}
+
+TrayScreenCapture::~TrayScreenCapture() {
+}
+
+void TrayScreenCapture::Update() {
+ if (tray_)
+ tray_->Update();
+ if (default_)
+ default_->Update();
+ if (notification_)
+ notification_->Update();
+}
+
+views::View* TrayScreenCapture::CreateTrayView(user::LoginStatus status) {
+ tray_ = new tray::ScreenCaptureTrayView(this);
+ return tray_;
+}
+
+views::View* TrayScreenCapture::CreateDefaultView(user::LoginStatus status) {
+ default_ = new tray::ScreenCaptureStatusView(
+ this, tray::ScreenCaptureStatusView::VIEW_DEFAULT);
+ return default_;
+}
+
+views::View* TrayScreenCapture::CreateNotificationView(
+ user::LoginStatus status) {
+ notification_ = new tray::ScreenCaptureNotificationView(this);
+ return notification_;
+}
+
+void TrayScreenCapture::DestroyTrayView() {
+ tray_ = NULL;
+}
+
+void TrayScreenCapture::DestroyDefaultView() {
+ default_ = NULL;
+}
+
+void TrayScreenCapture::DestroyNotificationView() {
+ notification_ = NULL;
+}
+
+void TrayScreenCapture::OnScreenCaptureStatusChanged() {
+ SetScreenCaptureOn(IsScreenCaptureOn());
+
+ if (tray_)
+ tray_->Update();
+
+ if (default_)
+ default_->Update();
+
+ if (!system_tray()->HasSystemBubbleType(
+ SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) {
+ ShowNotificationView();
+ }
+}
+
+// TODO(jennyz): Implement it with integration of Screen Capture API.
+bool TrayScreenCapture::IsScreenCaptureOn() {
+ return false;
+}
+
+// TODO(jennyz): Implement it with integration of Screen Capture API.
+void TrayScreenCapture::SetScreenCaptureOn(bool screen_capture_on) {
+ NOTIMPLEMENTED();
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/chromeos/screen_capture/tray_screen_capture.h b/ash/system/chromeos/screen_capture/tray_screen_capture.h
new file mode 100644
index 0000000..f96d287
--- /dev/null
+++ b/ash/system/chromeos/screen_capture/tray_screen_capture.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2013 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_CHROMEOS_SCREEN_CAPTURE_TRAY_SCREEN_CAPTURE_H_
+#define ASH_SYSTEM_CHROMEOS_SCREEN_CAPTURE_TRAY_SCREEN_CAPTURE_H_
+
+#include "ash/system/tray/system_tray_item.h"
+#include "chromeos/screen_capture/screen_capture_observer.h"
+
+namespace views {
+class View;
+}
+
+namespace ash {
+namespace internal {
+
+namespace tray{
+class ScreenCaptureTrayView;
+class ScreenCaptureStatusView;
+class ScreenCaptureNotificationView;
+} // namespace tray
+
+class TrayScreenCapture : public SystemTrayItem,
+ public chromeos::ScreenCaptureObserver {
+ public:
+ explicit TrayScreenCapture(SystemTray* system_tray);
+ virtual ~TrayScreenCapture();
+
+ void Update();
+ bool IsScreenCaptureOn();
+ void SetScreenCaptureOn(bool screen_capture_on);
+
+ private:
+ // Overridden from SystemTrayItem.
+ virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
+ virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
+ virtual views::View* CreateNotificationView(
+ user::LoginStatus status) OVERRIDE;
+ virtual void DestroyTrayView() OVERRIDE;
+ virtual void DestroyDefaultView() OVERRIDE;
+ virtual void DestroyNotificationView() OVERRIDE;
+
+ // Overridden from chromeos::ScreenCaptureObserver.
+ virtual void OnScreenCaptureStatusChanged() OVERRIDE;
+
+ tray::ScreenCaptureTrayView* tray_;
+ tray::ScreenCaptureStatusView* default_;
+ tray::ScreenCaptureNotificationView* notification_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayScreenCapture);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SYSTEM_CHROMEOS_SCREEN_CAPTURE_TRAY_SCREEN_CAPTURE_H_
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 967500f..6054c453 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -12,7 +12,6 @@
#include "ash/system/audio/tray_volume.h"
#include "ash/system/bluetooth/tray_bluetooth.h"
#include "ash/system/brightness/tray_brightness.h"
-#include "ash/system/chromeos/tray_display.h"
#include "ash/system/date/tray_date.h"
#include "ash/system/drive/tray_drive.h"
#include "ash/system/ime/tray_ime.h"
@@ -56,6 +55,8 @@
#include "ash/system/chromeos/network/tray_network.h"
#include "ash/system/chromeos/network/tray_sms.h"
#include "ash/system/chromeos/network/tray_vpn.h"
+#include "ash/system/chromeos/screen_capture/tray_screen_capture.h"
+#include "ash/system/chromeos/tray_display.h"
#endif
using views::TrayBubbleView;
@@ -151,6 +152,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
AddTrayItem(new internal::TrayLocale(this));
#if defined(OS_CHROMEOS)
AddTrayItem(new internal::TrayDisplay(this));
+ AddTrayItem(new internal::TrayScreenCapture(this));
#endif
AddTrayItem(new internal::TrayVolume(this));
AddTrayItem(new internal::TrayBrightness(this));