summaryrefslogtreecommitdiffstats
path: root/ash/system/chromeos/drive
diff options
context:
space:
mode:
Diffstat (limited to 'ash/system/chromeos/drive')
-rw-r--r--ash/system/chromeos/drive/tray_drive_notice.cc193
-rw-r--r--ash/system/chromeos/drive/tray_drive_notice.h63
-rw-r--r--ash/system/chromeos/drive/tray_drive_unittest.cc81
3 files changed, 0 insertions, 337 deletions
diff --git a/ash/system/chromeos/drive/tray_drive_notice.cc b/ash/system/chromeos/drive/tray_drive_notice.cc
deleted file mode 100644
index a48b11b..0000000
--- a/ash/system/chromeos/drive/tray_drive_notice.cc
+++ /dev/null
@@ -1,193 +0,0 @@
-// 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) {
- 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;
-
- 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
deleted file mode 100644
index cbc717d..0000000
--- a/ash/system/chromeos/drive/tray_drive_notice.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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
deleted file mode 100644
index 439458a..0000000
--- a/ash/system/chromeos/drive/tray_drive_unittest.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// 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