summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authortengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 08:36:25 +0000
committertengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 08:36:25 +0000
commit9bbe6f546d22fa0e879be02877e266b16b6212e1 (patch)
treea87074dcc8827c5e380d5577420917de69de5973 /ash
parent2c0d3354650082b002389520d9f6e684db3a9fff (diff)
downloadchromium_src-9bbe6f546d22fa0e879be02877e266b16b6212e1.zip
chromium_src-9bbe6f546d22fa0e879be02877e266b16b6212e1.tar.gz
chromium_src-9bbe6f546d22fa0e879be02877e266b16b6212e1.tar.bz2
Introduce enable Google Drive offline mode notice to ash system tray.
BUG=311452 TEST=added unit tests Review URL: https://codereview.chromium.org/47463006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234458 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp3
-rw-r--r--ash/ash_strings.grd9
-rw-r--r--ash/system/chromeos/drive/tray_drive_notice.cc196
-rw-r--r--ash/system/chromeos/drive/tray_drive_notice.h63
-rw-r--r--ash/system/chromeos/drive/tray_drive_unittest.cc81
-rw-r--r--ash/system/drive/drive_observer.h1
-rw-r--r--ash/system/drive/tray_drive.cc3
-rw-r--r--ash/system/drive/tray_drive.h1
-rw-r--r--ash/system/drive/tray_drive_notice.cc196
-rw-r--r--ash/system/tray/system_tray.cc2
-rw-r--r--ash/system/tray/system_tray_notifier.cc6
-rw-r--r--ash/system/tray/system_tray_notifier.h1
12 files changed, 562 insertions, 0 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index b1022ae..af36f40 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -242,6 +242,8 @@
'system/chromeos/brightness/brightness_controller_chromeos.h',
'system/chromeos/brightness/tray_brightness.cc',
'system/chromeos/brightness/tray_brightness.h',
+ 'system/chromeos/drive/tray_drive_notice.cc',
+ 'system/chromeos/drive/tray_drive_notice.h',
'system/chromeos/enterprise/tray_enterprise.h',
'system/chromeos/enterprise/tray_enterprise.cc',
'system/chromeos/keyboard_brightness_controller.cc',
@@ -792,6 +794,7 @@
'shell/window_watcher_launcher_item_delegate.h',
'shell/window_watcher_unittest.cc',
'shell_unittest.cc',
+ 'system/chromeos/drive/tray_drive_unittest.cc',
'system/chromeos/managed/tray_locally_managed_user_unittest.cc',
'system/chromeos/network/network_state_notifier_unittest.cc',
'system/chromeos/power/power_event_observer_unittest.cc',
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd
index 289c8b1..3580e7b 100644
--- a/ash/ash_strings.grd
+++ b/ash/ash_strings.grd
@@ -363,6 +363,15 @@ Press Ctrl+Alt+Z to disable.
<message name="IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270" desc="The value of display orientation option item: 270-degree rotated">
270&#x00B0;
</message>
+ <message name="IDS_ASH_STATUS_TRAY_DRIVE_OFFLINE_NOTICE" desc="The label in the tray notifying a first-time logged in user that they are being opted-in to Google Drive offline.">
+ Preparing Google Drive for offline...
+ </message>
+ <message name="IDS_ASH_STATUS_TRAY_DRIVE_DISABLE_OFFLINE" desc="The label in the detailed drive offline opt-in notice tray item explaining how to disable Google Drive offline.">
+ To disable Google Drive offline on this device, adjust your settings at drive.google.com.
+ </message>
+ <message name="IDS_ASH_STATUS_TRAY_DRIVE_OFFLINE_FOOTER" desc="The label for the footer of the detailed drive offline opt-in notice tray item.">
+ Google Drive
+ </message>
<message name="IDS_ASH_STATUS_TRAY_DRIVE_SYNCING" desc="The label in the tray to indicate onoing file sync operations.">
Syncing <ph name="count">$1<ex>3</ex></ph> file(s)
</message>
diff --git a/ash/system/chromeos/drive/tray_drive_notice.cc b/ash/system/chromeos/drive/tray_drive_notice.cc
new file mode 100644
index 0000000..27d63ea
--- /dev/null
+++ b/ash/system/chromeos/drive/tray_drive_notice.cc
@@ -0,0 +1,196 @@
+// Copyright 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/drive/tray_drive_notice.h"
+
+#include "ash/shell.h"
+#include "ash/system/tray/actionable_view.h"
+#include "ash/system/tray/hover_highlight_view.h"
+#include "ash/system/tray/system_tray.h"
+#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/system/tray/system_tray_notifier.h"
+#include "ash/system/tray/tray_constants.h"
+#include "base/strings/utf_string_conversions.h"
+#include "grit/ash_resources.h"
+#include "grit/ash_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace ash {
+namespace internal {
+
+namespace {
+
+// Vertical spacing between notice label and the detailed view container.
+const int kNoticeLabelVerticalSpacing = 3;
+
+// Bottom spacing inside border for notice label in detailed view.
+const int kNoticeLabelBorderBottomSpacing = 5;
+
+// The time to show the tray item notice.
+const int kTimeVisibleSeconds = 30;
+
+} // namespace
+
+class DriveNoticeDefaultView : public TrayItemMore {
+ public:
+ DriveNoticeDefaultView(SystemTrayItem* owner) :
+ TrayItemMore(owner, true) {
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DRIVE).ToImageSkia());
+ SetLabel(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DRIVE_OFFLINE_NOTICE));
+ }
+
+ virtual ~DriveNoticeDefaultView() {}
+};
+
+class DriveNoticeDetailedView : public TrayDetailsView,
+ public ViewClickListener {
+ public:
+ DriveNoticeDetailedView(SystemTrayItem* owner)
+ : TrayDetailsView(owner),
+ settings_button_(NULL) {
+ Reset();
+
+ CreateScrollableList();
+ CreateNoticeLabel();
+ CreateSettingsButton();
+ CreateSpecialRow(IDS_ASH_STATUS_TRAY_DRIVE_OFFLINE_FOOTER, this);
+
+ Layout();
+ }
+
+ virtual ~DriveNoticeDetailedView() {}
+
+ private:
+ void CreateNoticeLabel() {
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ views::Label* notice_label = new views::Label(
+ rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_DRIVE_DISABLE_OFFLINE));
+ notice_label->SetLayoutManager(new views::BoxLayout(
+ views::BoxLayout::kHorizontal,
+ 0,
+ kNoticeLabelVerticalSpacing,
+ kTrayPopupPaddingBetweenItems));
+ notice_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ notice_label->SetMultiLine(true);
+ notice_label->SetFont(
+ notice_label->font().DeriveFont(0, gfx::Font::NORMAL));
+
+ int margin = kTrayPopupPaddingHorizontal +
+ kTrayPopupDetailsLabelExtraLeftMargin;
+ int left_margin = base::i18n::IsRTL() ? 0 : margin;
+ int right_margin = base::i18n::IsRTL() ? margin : 0;
+ notice_label->set_border(
+ views::Border::CreateEmptyBorder(
+ kTrayPopupPaddingBetweenItems,
+ left_margin,
+ kNoticeLabelBorderBottomSpacing,
+ right_margin));
+
+ scroll_content()->AddChildView(notice_label);
+ }
+
+ void CreateSettingsButton() {
+ HoverHighlightView* redirect_button = new HoverHighlightView(this);
+ redirect_button->AddLabel(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DRIVE_SETTINGS),
+ gfx::Font::NORMAL);
+ AddChildView(redirect_button);
+ settings_button_ = redirect_button;
+ }
+
+ // Overridden from ViewClickListener.
+ virtual void OnViewClicked(views::View* sender) OVERRIDE {
+ SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
+ if (sender == footer()->content()) {
+ owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
+ } else if (sender == settings_button_) {
+ delegate->ShowDriveSettings();
+ }
+ }
+
+ views::View* settings_button_;
+
+ DISALLOW_COPY_AND_ASSIGN(DriveNoticeDetailedView);
+};
+
+TrayDriveNotice::TrayDriveNotice(SystemTray* system_tray)
+ : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_DRIVE_LIGHT),
+ default_view_(NULL),
+ detailed_view_(NULL),
+ showing_item_(false),
+ time_visible_secs_(kTimeVisibleSeconds) {
+ Shell::GetInstance()->system_tray_notifier()->AddDriveObserver(this);
+}
+
+TrayDriveNotice::~TrayDriveNotice() {
+ Shell::GetInstance()->system_tray_notifier()->RemoveDriveObserver(this);
+}
+
+views::View* TrayDriveNotice::GetTrayView() {
+ return TrayImageItem::tray_view();
+}
+
+void TrayDriveNotice::SetTimeVisibleForTest(int time_visible_secs) {
+ time_visible_secs_ = time_visible_secs;
+}
+
+bool TrayDriveNotice::GetInitialVisibility() {
+ return false;
+}
+
+views::View* TrayDriveNotice::CreateDefaultView(user::LoginStatus status) {
+ DCHECK(status == user::LOGGED_IN_USER);
+ CHECK(default_view_ == NULL);
+
+ if (!showing_item_)
+ return NULL;
+
+ default_view_ = new DriveNoticeDefaultView(this);
+ return default_view_;
+}
+
+views::View* TrayDriveNotice::CreateDetailedView(user::LoginStatus status) {
+ if (!showing_item_)
+ return NULL;
+
+ DCHECK(status == user::LOGGED_IN_USER);
+ detailed_view_ = new DriveNoticeDetailedView(this);
+ return detailed_view_;
+}
+
+void TrayDriveNotice::DestroyDefaultView() {
+ default_view_ = NULL;
+}
+
+void TrayDriveNotice::DestroyDetailedView() {
+ detailed_view_ = NULL;
+}
+
+void TrayDriveNotice::UpdateAfterLoginStatusChange(user::LoginStatus status) {
+}
+
+void TrayDriveNotice::OnDriveJobUpdated(const DriveOperationStatus& status) {
+}
+
+void TrayDriveNotice::OnDriveOfflineEnabled() {
+ showing_item_ = true;
+ tray_view()->SetVisible(true);
+ visibility_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(time_visible_secs_),
+ this,
+ &TrayDriveNotice::HideNotice);
+}
+
+void TrayDriveNotice::HideNotice() {
+ showing_item_ = false;
+ tray_view()->SetVisible(false);
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/chromeos/drive/tray_drive_notice.h b/ash/system/chromeos/drive/tray_drive_notice.h
new file mode 100644
index 0000000..cbc717d
--- /dev/null
+++ b/ash/system/chromeos/drive/tray_drive_notice.h
@@ -0,0 +1,63 @@
+// Copyright 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_DRIVE_TRAY_DRIVE_NOTICE_H_
+#define ASH_SYSTEM_DRIVE_TRAY_DRIVE_NOTICE_H_
+
+#include "ash/system/drive/drive_observer.h"
+#include "ash/system/tray/tray_image_item.h"
+#include "ash/system/tray/tray_item_more.h"
+#include "base/timer/timer.h"
+
+namespace ash {
+namespace internal {
+
+class DriveNoticeDetailedView;
+
+// A tray item shown to the user as a notice that Google Drive offline mode has
+// been enabled automatically. This tray item is mainly informational and is
+// automatically dismissed after a short period of time.
+class ASH_EXPORT TrayDriveNotice : public TrayImageItem,
+ public DriveObserver {
+ public:
+ explicit TrayDriveNotice(SystemTray* system_tray);
+ virtual ~TrayDriveNotice();
+
+ views::View* GetTrayView();
+ views::View* default_view() { return default_view_; }
+ views::View* detailed_view() { return detailed_view_; }
+
+ // Set the time the tray item is visible after opting-in for testing.
+ void SetTimeVisibleForTest(int time_visible_secs);
+
+ private:
+ void HideNotice();
+
+ // Overridden from TrayImageItem.
+ virtual bool GetInitialVisibility() OVERRIDE;
+
+ // Overridden from SystemTrayItem.
+ virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
+ virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE;
+ virtual void DestroyDefaultView() OVERRIDE;
+ virtual void DestroyDetailedView() OVERRIDE;
+ virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
+
+ // Overridden from DriveObserver.
+ virtual void OnDriveJobUpdated(const DriveOperationStatus& status) OVERRIDE;
+ virtual void OnDriveOfflineEnabled() OVERRIDE;
+
+ views::View* default_view_;
+ views::View* detailed_view_;
+ base::OneShotTimer<TrayDriveNotice> visibility_timer_;
+ bool showing_item_;
+ int time_visible_secs_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayDriveNotice);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SYSTEM_DRIVE_TRAY_DRIVE_NOTICE_H_
diff --git a/ash/system/chromeos/drive/tray_drive_unittest.cc b/ash/system/chromeos/drive/tray_drive_unittest.cc
new file mode 100644
index 0000000..439458a
--- /dev/null
+++ b/ash/system/chromeos/drive/tray_drive_unittest.cc
@@ -0,0 +1,81 @@
+// Copyright 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/shell.h"
+#include "ash/system/chromeos/drive/tray_drive_notice.h"
+#include "ash/system/tray/system_tray.h"
+#include "ash/system/tray/system_tray_notifier.h"
+#include "ash/system/tray/tray_item_view.h"
+#include "ash/test/ash_test_base.h"
+
+namespace ash {
+namespace internal {
+
+class DriveNoticeTest : public ash::test::AshTestBase {
+ public:
+ DriveNoticeTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ test::AshTestBase::SetUp();
+ TrayItemView::DisableAnimationsForTest();
+
+ // Ownership of |notice_tray_item_| passed to system tray.
+ notice_tray_item_ = new TrayDriveNotice(GetSystemTray());
+ notice_tray_item_->SetTimeVisibleForTest(0);
+ GetSystemTray()->AddTrayItem(notice_tray_item_);
+ }
+
+ TrayDriveNotice* notice_tray_item() { return notice_tray_item_; }
+
+ SystemTray* GetSystemTray() {
+ return Shell::GetInstance()->GetPrimarySystemTray();
+ }
+
+ void NotifyOfflineEnabled() {
+ Shell::GetInstance()->system_tray_notifier()->NotifyDriveOfflineEnabled();
+ }
+
+ private:
+ // |notice_tray_item_| is owned by system tray.
+ TrayDriveNotice* notice_tray_item_;
+};
+
+TEST_F(DriveNoticeTest, NotifyEnabled) {
+ // Tray item views should not be visible initially.
+ EXPECT_FALSE(notice_tray_item()->GetTrayView()->visible());
+ EXPECT_FALSE(notice_tray_item()->default_view());
+ EXPECT_FALSE(notice_tray_item()->detailed_view());
+
+ // Tray item view should appear after notifying offline enabled.
+ NotifyOfflineEnabled();
+ EXPECT_TRUE(notice_tray_item()->GetTrayView()->visible());
+
+ // Open system bubble and check default view is visible.
+ GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
+ EXPECT_TRUE(GetSystemTray()->HasSystemBubble());
+ EXPECT_TRUE(notice_tray_item()->default_view());
+
+ // Open detailed view and check detailed view is visible.
+ GetSystemTray()->ShowDetailedView(
+ notice_tray_item(), 0, false, BUBBLE_USE_EXISTING);
+ EXPECT_TRUE(notice_tray_item()->detailed_view());
+
+ GetSystemTray()->CloseSystemBubble();
+}
+
+TEST_F(DriveNoticeTest, AutomaticallyHidden) {
+ // The tray item should automatically be hidden after a period of time.
+ EXPECT_FALSE(notice_tray_item()->GetTrayView()->visible());
+ NotifyOfflineEnabled();
+ EXPECT_TRUE(notice_tray_item()->GetTrayView()->visible());
+
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(notice_tray_item()->GetTrayView()->visible());
+
+ GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
+ EXPECT_FALSE(notice_tray_item()->default_view());
+}
+
+} // internal
+} // ash
diff --git a/ash/system/drive/drive_observer.h b/ash/system/drive/drive_observer.h
index a721dd4..b2e7fd8 100644
--- a/ash/system/drive/drive_observer.h
+++ b/ash/system/drive/drive_observer.h
@@ -12,6 +12,7 @@ namespace ash {
class DriveObserver {
public:
virtual void OnDriveJobUpdated(const DriveOperationStatus& status) = 0;
+ virtual void OnDriveOfflineEnabled() = 0;
protected:
virtual ~DriveObserver() {}
diff --git a/ash/system/drive/tray_drive.cc b/ash/system/drive/tray_drive.cc
index 028aa29..7eefa05 100644
--- a/ash/system/drive/tray_drive.cc
+++ b/ash/system/drive/tray_drive.cc
@@ -508,5 +508,8 @@ void TrayDrive::HideIfNoOperations() {
detailed_->Update(&empty_list);
}
+void TrayDrive::OnDriveOfflineEnabled() {
+}
+
} // namespace internal
} // namespace ash
diff --git a/ash/system/drive/tray_drive.h b/ash/system/drive/tray_drive.h
index 6550fde..6f5f626 100644
--- a/ash/system/drive/tray_drive.h
+++ b/ash/system/drive/tray_drive.h
@@ -41,6 +41,7 @@ class TrayDrive : public TrayImageItem,
// Overridden from DriveObserver.
virtual void OnDriveJobUpdated(const DriveOperationStatus& status) OVERRIDE;
+ virtual void OnDriveOfflineEnabled() OVERRIDE;
// Delayed hiding of the tray item after encountering an empty operation list.
void HideIfNoOperations();
diff --git a/ash/system/drive/tray_drive_notice.cc b/ash/system/drive/tray_drive_notice.cc
new file mode 100644
index 0000000..27d63ea
--- /dev/null
+++ b/ash/system/drive/tray_drive_notice.cc
@@ -0,0 +1,196 @@
+// Copyright 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/drive/tray_drive_notice.h"
+
+#include "ash/shell.h"
+#include "ash/system/tray/actionable_view.h"
+#include "ash/system/tray/hover_highlight_view.h"
+#include "ash/system/tray/system_tray.h"
+#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/system/tray/system_tray_notifier.h"
+#include "ash/system/tray/tray_constants.h"
+#include "base/strings/utf_string_conversions.h"
+#include "grit/ash_resources.h"
+#include "grit/ash_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace ash {
+namespace internal {
+
+namespace {
+
+// Vertical spacing between notice label and the detailed view container.
+const int kNoticeLabelVerticalSpacing = 3;
+
+// Bottom spacing inside border for notice label in detailed view.
+const int kNoticeLabelBorderBottomSpacing = 5;
+
+// The time to show the tray item notice.
+const int kTimeVisibleSeconds = 30;
+
+} // namespace
+
+class DriveNoticeDefaultView : public TrayItemMore {
+ public:
+ DriveNoticeDefaultView(SystemTrayItem* owner) :
+ TrayItemMore(owner, true) {
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DRIVE).ToImageSkia());
+ SetLabel(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DRIVE_OFFLINE_NOTICE));
+ }
+
+ virtual ~DriveNoticeDefaultView() {}
+};
+
+class DriveNoticeDetailedView : public TrayDetailsView,
+ public ViewClickListener {
+ public:
+ DriveNoticeDetailedView(SystemTrayItem* owner)
+ : TrayDetailsView(owner),
+ settings_button_(NULL) {
+ Reset();
+
+ CreateScrollableList();
+ CreateNoticeLabel();
+ CreateSettingsButton();
+ CreateSpecialRow(IDS_ASH_STATUS_TRAY_DRIVE_OFFLINE_FOOTER, this);
+
+ Layout();
+ }
+
+ virtual ~DriveNoticeDetailedView() {}
+
+ private:
+ void CreateNoticeLabel() {
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ views::Label* notice_label = new views::Label(
+ rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_DRIVE_DISABLE_OFFLINE));
+ notice_label->SetLayoutManager(new views::BoxLayout(
+ views::BoxLayout::kHorizontal,
+ 0,
+ kNoticeLabelVerticalSpacing,
+ kTrayPopupPaddingBetweenItems));
+ notice_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ notice_label->SetMultiLine(true);
+ notice_label->SetFont(
+ notice_label->font().DeriveFont(0, gfx::Font::NORMAL));
+
+ int margin = kTrayPopupPaddingHorizontal +
+ kTrayPopupDetailsLabelExtraLeftMargin;
+ int left_margin = base::i18n::IsRTL() ? 0 : margin;
+ int right_margin = base::i18n::IsRTL() ? margin : 0;
+ notice_label->set_border(
+ views::Border::CreateEmptyBorder(
+ kTrayPopupPaddingBetweenItems,
+ left_margin,
+ kNoticeLabelBorderBottomSpacing,
+ right_margin));
+
+ scroll_content()->AddChildView(notice_label);
+ }
+
+ void CreateSettingsButton() {
+ HoverHighlightView* redirect_button = new HoverHighlightView(this);
+ redirect_button->AddLabel(
+ l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DRIVE_SETTINGS),
+ gfx::Font::NORMAL);
+ AddChildView(redirect_button);
+ settings_button_ = redirect_button;
+ }
+
+ // Overridden from ViewClickListener.
+ virtual void OnViewClicked(views::View* sender) OVERRIDE {
+ SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
+ if (sender == footer()->content()) {
+ owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
+ } else if (sender == settings_button_) {
+ delegate->ShowDriveSettings();
+ }
+ }
+
+ views::View* settings_button_;
+
+ DISALLOW_COPY_AND_ASSIGN(DriveNoticeDetailedView);
+};
+
+TrayDriveNotice::TrayDriveNotice(SystemTray* system_tray)
+ : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_DRIVE_LIGHT),
+ default_view_(NULL),
+ detailed_view_(NULL),
+ showing_item_(false),
+ time_visible_secs_(kTimeVisibleSeconds) {
+ Shell::GetInstance()->system_tray_notifier()->AddDriveObserver(this);
+}
+
+TrayDriveNotice::~TrayDriveNotice() {
+ Shell::GetInstance()->system_tray_notifier()->RemoveDriveObserver(this);
+}
+
+views::View* TrayDriveNotice::GetTrayView() {
+ return TrayImageItem::tray_view();
+}
+
+void TrayDriveNotice::SetTimeVisibleForTest(int time_visible_secs) {
+ time_visible_secs_ = time_visible_secs;
+}
+
+bool TrayDriveNotice::GetInitialVisibility() {
+ return false;
+}
+
+views::View* TrayDriveNotice::CreateDefaultView(user::LoginStatus status) {
+ DCHECK(status == user::LOGGED_IN_USER);
+ CHECK(default_view_ == NULL);
+
+ if (!showing_item_)
+ return NULL;
+
+ default_view_ = new DriveNoticeDefaultView(this);
+ return default_view_;
+}
+
+views::View* TrayDriveNotice::CreateDetailedView(user::LoginStatus status) {
+ if (!showing_item_)
+ return NULL;
+
+ DCHECK(status == user::LOGGED_IN_USER);
+ detailed_view_ = new DriveNoticeDetailedView(this);
+ return detailed_view_;
+}
+
+void TrayDriveNotice::DestroyDefaultView() {
+ default_view_ = NULL;
+}
+
+void TrayDriveNotice::DestroyDetailedView() {
+ detailed_view_ = NULL;
+}
+
+void TrayDriveNotice::UpdateAfterLoginStatusChange(user::LoginStatus status) {
+}
+
+void TrayDriveNotice::OnDriveJobUpdated(const DriveOperationStatus& status) {
+}
+
+void TrayDriveNotice::OnDriveOfflineEnabled() {
+ showing_item_ = true;
+ tray_view()->SetVisible(true);
+ visibility_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(time_visible_secs_),
+ this,
+ &TrayDriveNotice::HideNotice);
+}
+
+void TrayDriveNotice::HideNotice() {
+ showing_item_ = false;
+ tray_view()->SetVisible(false);
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 387c2da..e3c962a 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -49,6 +49,7 @@
#if defined(OS_CHROMEOS)
#include "ash/system/chromeos/audio/tray_audio.h"
#include "ash/system/chromeos/brightness/tray_brightness.h"
+#include "ash/system/chromeos/drive/tray_drive_notice.h"
#include "ash/system/chromeos/enterprise/tray_enterprise.h"
#include "ash/system/chromeos/managed/tray_locally_managed_user.h"
#include "ash/system/chromeos/network/tray_network.h"
@@ -183,6 +184,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
#if defined(OS_CHROMEOS)
AddTrayItem(new internal::TrayEnterprise(this));
+ AddTrayItem(new internal::TrayDriveNotice(this));
AddTrayItem(new internal::TrayLocallyManagedUser(this));
AddTrayItem(new internal::TrayIME(this));
AddTrayItem(tray_accessibility_);
diff --git a/ash/system/tray/system_tray_notifier.cc b/ash/system/tray/system_tray_notifier.cc
index e2035ad..f3bc793 100644
--- a/ash/system/tray/system_tray_notifier.cc
+++ b/ash/system/tray/system_tray_notifier.cc
@@ -220,6 +220,12 @@ void SystemTrayNotifier::NotifyDriveJobUpdated(
OnDriveJobUpdated(status));
}
+void SystemTrayNotifier::NotifyDriveOfflineEnabled() {
+ FOR_EACH_OBSERVER(DriveObserver,
+ drive_observers_,
+ OnDriveOfflineEnabled());
+}
+
void SystemTrayNotifier::NotifyRefreshIME(bool show_message) {
FOR_EACH_OBSERVER(IMEObserver,
ime_observers_,
diff --git a/ash/system/tray/system_tray_notifier.h b/ash/system/tray/system_tray_notifier.h
index 3d7fb0e..3b028bb 100644
--- a/ash/system/tray/system_tray_notifier.h
+++ b/ash/system/tray/system_tray_notifier.h
@@ -101,6 +101,7 @@ public:
void NotifyDateFormatChanged();
void NotifySystemClockTimeUpdated();
void NotifyDriveJobUpdated(const DriveOperationStatus& status);
+ void NotifyDriveOfflineEnabled();
void NotifyRefreshIME(bool show_message);
void NotifyShowLoginButtonChanged(bool show_login_button);
void NotifyLocaleChanged(LocaleObserver::Delegate* delegate,