summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-28 04:05:53 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-28 04:05:53 +0000
commit024a03b4bacbfee6d68e807aeb71146906369ff1 (patch)
treeff64b0b391f4f7b6bad4ff19fc6aecdd3be11507
parent95f177a2874ccc0cc296366a0f3fb62b5698e8f0 (diff)
downloadchromium_src-024a03b4bacbfee6d68e807aeb71146906369ff1.zip
chromium_src-024a03b4bacbfee6d68e807aeb71146906369ff1.tar.gz
chromium_src-024a03b4bacbfee6d68e807aeb71146906369ff1.tar.bz2
ash: Move the update notifier into its own row in the popup.
BUG=120195,115357 TEST=none Review URL: https://chromiumcodereview.appspot.com/9844012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129363 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/shell.cc7
-rw-r--r--ash/system/tray/system_tray_delegate.h3
-rw-r--r--ash/system/tray_caps_lock.h2
-rw-r--r--ash/system/tray_update.cc82
-rw-r--r--ash/system/tray_update.h49
-rw-r--r--ash/system/user/tray_user.cc44
-rw-r--r--ash/system/user/tray_user.h5
-rw-r--r--chrome/browser/chromeos/system/ash_system_tray_delegate.cc4
-rw-r--r--ui/resources/aura/status_update.pngbin0 -> 457 bytes
-rw-r--r--ui/resources/aura/status_update_dark.pngbin0 -> 509 bytes
-rw-r--r--ui/resources/ui_resources.grd2
12 files changed, 148 insertions, 52 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index e046b6e..26b4a88 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -167,6 +167,8 @@
'system/tray_accessibility.h',
'system/tray_caps_lock.cc',
'system/tray_caps_lock.h',
+ 'system/tray_update.cc',
+ 'system/tray_update.h',
'system/user/login_status.h',
'system/user/tray_user.cc',
'system/user/tray_user.h',
diff --git a/ash/shell.cc b/ash/shell.cc
index fb24006..3188cc2 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -36,6 +36,7 @@
#include "ash/system/tray/tray_empty.h"
#include "ash/system/tray_accessibility.h"
#include "ash/system/tray_caps_lock.h"
+#include "ash/system/tray_update.h"
#include "ash/system/user/tray_user.h"
#include "ash/tooltips/tooltip_controller.h"
#include "ash/wm/activation_controller.h"
@@ -354,6 +355,8 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
virtual void RequestLockScreen() OVERRIDE {}
+ virtual void RequestRestart() OVERRIDE {}
+
virtual void GetAvailableBluetoothDevices(
BluetoothDeviceList* list) OVERRIDE {
}
@@ -690,6 +693,7 @@ void Shell::Init() {
new internal::TrayAccessibility;
internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock;
internal::TrayIME* tray_ime = new internal::TrayIME;
+ internal::TrayUpdate* tray_update = new internal::TrayUpdate;
tray_->accessibility_observer_ = tray_accessibility;
tray_->audio_observer_ = tray_volume;
@@ -700,7 +704,7 @@ void Shell::Init() {
tray_->ime_observer_ = tray_ime;
tray_->network_observer_ = tray_network;
tray_->power_status_observer_ = tray_power;
- tray_->update_observer_ = tray_user;
+ tray_->update_observer_ = tray_update;
tray_->user_observer_ = tray_user;
tray_->AddTrayItem(tray_user);
@@ -711,6 +715,7 @@ void Shell::Init() {
tray_->AddTrayItem(tray_ime);
tray_->AddTrayItem(tray_volume);
tray_->AddTrayItem(tray_brightness);
+ tray_->AddTrayItem(tray_update);
tray_->AddTrayItem(new internal::TraySettings());
tray_->AddTrayItem(tray_accessibility);
tray_->AddTrayItem(tray_caps_lock);
diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h
index 5d4c8ba..92cd195 100644
--- a/ash/system/tray/system_tray_delegate.h
+++ b/ash/system/tray/system_tray_delegate.h
@@ -137,6 +137,9 @@ class SystemTrayDelegate {
// Attempts to lock the screen.
virtual void RequestLockScreen() = 0;
+ // Attempts to restart the system.
+ virtual void RequestRestart() = 0;
+
// Returns a list of available bluetooth devices.
virtual void GetAvailableBluetoothDevices(BluetoothDeviceList* devices) = 0;
diff --git a/ash/system/tray_caps_lock.h b/ash/system/tray_caps_lock.h
index eba50c6..b1ad1f6 100644
--- a/ash/system/tray_caps_lock.h
+++ b/ash/system/tray_caps_lock.h
@@ -51,5 +51,3 @@ class TrayCapsLock : public TrayImageItem,
} // namespace ash
#endif // ASH_SYSTEM_TRAY_CAPS_LOCK_H_
-
-
diff --git a/ash/system/tray_update.cc b/ash/system/tray_update.cc
new file mode 100644
index 0000000..315f1ce
--- /dev/null
+++ b/ash/system/tray_update.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 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_update.h"
+
+#include "ash/shell.h"
+#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/system/tray/tray_constants.h"
+#include "ash/system/tray/tray_views.h"
+#include "grit/ash_strings.h"
+#include "grit/ui_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image.h"
+#include "ui/views/controls/image_view.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/widget/widget.h"
+
+namespace {
+
+class UpdateView : public views::View {
+ public:
+ UpdateView() {
+ set_focusable(true);
+ SetLayoutManager(new
+ views::BoxLayout(views::BoxLayout::kHorizontal,
+ ash::kTrayPopupPaddingHorizontal, 0,
+ ash::kTrayPopupPaddingBetweenItems));
+
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ views::ImageView* image =
+ new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
+ image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_UPDATE_DARK).
+ ToSkBitmap());
+
+ AddChildView(image);
+ AddChildView(new views::Label(
+ bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE)));
+ }
+
+ virtual ~UpdateView() {}
+
+ private:
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
+ ash::Shell::GetInstance()->tray_delegate()->RequestRestart();
+ return true;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(UpdateView);
+};
+
+}
+
+namespace ash {
+namespace internal {
+
+TrayUpdate::TrayUpdate()
+ : TrayImageItem(IDR_AURA_UBER_TRAY_UPDATE) {
+}
+
+TrayUpdate::~TrayUpdate() {}
+
+bool TrayUpdate::GetInitialVisibility() {
+ return Shell::GetInstance()->tray_delegate()->SystemShouldUpgrade();
+}
+
+views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) {
+ default_.reset(new UpdateView);
+ return default_.get();
+}
+
+void TrayUpdate::DestroyDefaultView() {
+ default_.reset();
+}
+
+void TrayUpdate::OnUpdateRecommended() {
+ image_view()->SetVisible(true);
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/tray_update.h b/ash/system/tray_update.h
new file mode 100644
index 0000000..a2cac2e
--- /dev/null
+++ b/ash/system/tray_update.h
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 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_TRAY_UPDATE_H_
+#define ASH_SYSTEM_TRAY_UPDATE_H_
+#pragma once
+
+#include "ash/system/tray/tray_image_item.h"
+
+namespace views {
+class View;
+}
+
+namespace ash {
+
+class ASH_EXPORT UpdateObserver {
+ public:
+ virtual ~UpdateObserver() {}
+
+ virtual void OnUpdateRecommended() = 0;
+};
+
+namespace internal {
+
+class TrayUpdate : public TrayImageItem,
+ public UpdateObserver {
+ public:
+ TrayUpdate();
+ virtual ~TrayUpdate();
+
+ private:
+ // Overridden from TrayImageItem.
+ virtual bool GetInitialVisibility() OVERRIDE;
+ virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
+ virtual void DestroyDefaultView() OVERRIDE;
+
+ // Overridden from UpdateObserver.
+ virtual void OnUpdateRecommended() OVERRIDE;
+
+ scoped_ptr<views::View> default_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayUpdate);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SYSTEM_TRAY_UPDATE_H_
diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc
index 5759bef..9b6af82 100644
--- a/ash/system/user/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -124,9 +124,6 @@ class UserView : public views::View,
if (!guest && !kiosk)
AddUserInfo();
- if (!guest && !kiosk && !locked)
- RefreshForUpdate();
-
// A user should not be able to modify logged in state when screen is
// locked.
if (!locked)
@@ -182,42 +179,6 @@ class UserView : public views::View,
AddChildView(button_container);
}
- // Shows update notification if available.
- void RefreshForUpdate() {
- ash::SystemTrayDelegate* tray = ash::Shell::GetInstance()->tray_delegate();
- if (tray->SystemShouldUpgrade()) {
- if (update_)
- return;
- update_ = new views::View;
- update_->SetLayoutManager(new
- views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 3));
-
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- views::Label *label = new views::Label(bundle.GetLocalizedString(
- IDS_ASH_STATUS_TRAY_UPDATE));
- label->SetFont(label->font().DeriveFont(-1));
- update_->AddChildView(label);
-
- views::ImageView* icon = new views::ImageView;
- icon->SetImage(bundle.GetImageNamed(tray->GetSystemUpdateIconResource()).
- ToSkBitmap());
- update_->AddChildView(icon);
-
- update_->set_border(views::Border::CreateEmptyBorder(
- kUserInfoVerticalPadding,
- kUserInfoHorizontalPadding,
- kUserInfoVerticalPadding,
- kUserInfoHorizontalPadding));
-
- user_info_->AddChildView(update_);
- } else if (update_) {
- delete update_;
- update_ = NULL;
- }
- user_info_->InvalidateLayout();
- user_info_->SchedulePaint();
- }
-
private:
void AddUserInfo() {
user_info_ = new views::View;
@@ -394,11 +355,6 @@ void TrayUser::DestroyDefaultView() {
void TrayUser::DestroyDetailedView() {
}
-void TrayUser::OnUpdateRecommended() {
- if (user_.get())
- user_->RefreshForUpdate();
-}
-
void TrayUser::OnUserUpdate() {
avatar_->SetImage(
ash::Shell::GetInstance()->tray_delegate()->GetUserImage(),
diff --git a/ash/system/user/tray_user.h b/ash/system/user/tray_user.h
index 0a3afbc..a61dd09 100644
--- a/ash/system/user/tray_user.h
+++ b/ash/system/user/tray_user.h
@@ -7,7 +7,6 @@
#pragma once
#include "ash/system/tray/system_tray_item.h"
-#include "ash/system/user/update_observer.h"
#include "ash/system/user/user_observer.h"
namespace views {
@@ -23,7 +22,6 @@ class RoundedImageView;
}
class TrayUser : public SystemTrayItem,
- public UpdateObserver,
public UserObserver {
public:
TrayUser();
@@ -38,9 +36,6 @@ class TrayUser : public SystemTrayItem,
virtual void DestroyDefaultView() OVERRIDE;
virtual void DestroyDetailedView() OVERRIDE;
- // Overridden from UpdateObserver.
- virtual void OnUpdateRecommended() OVERRIDE;
-
// Overridden from UserObserver.
virtual void OnUserUpdate() OVERRIDE;
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
index 12a09ab..3491431 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -308,6 +308,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
NotifyScreenLockRequested();
}
+ virtual void RequestRestart() OVERRIDE {
+ DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
+ }
+
virtual void GetAvailableBluetoothDevices(
ash::BluetoothDeviceList* list) OVERRIDE {
BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices();
diff --git a/ui/resources/aura/status_update.png b/ui/resources/aura/status_update.png
new file mode 100644
index 0000000..6f40b69
--- /dev/null
+++ b/ui/resources/aura/status_update.png
Binary files differ
diff --git a/ui/resources/aura/status_update_dark.png b/ui/resources/aura/status_update_dark.png
new file mode 100644
index 0000000..b54bf86
--- /dev/null
+++ b/ui/resources/aura/status_update_dark.png
Binary files differ
diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd
index 68c9f85..6509120 100644
--- a/ui/resources/ui_resources.grd
+++ b/ui/resources/ui_resources.grd
@@ -319,6 +319,8 @@
<include name="IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK" file="aura/status_capslock_dark.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_BLUETOOTH" file="aura/status_bluetooth.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_IME" file="aura/status_ime.png" type="BINDATA" />
+ <include name="IDR_AURA_UBER_TRAY_UPDATE" file="aura/status_update.png" type="BINDATA" />
+ <include name="IDR_AURA_UBER_TRAY_UPDATE_DARK" file="aura/status_update_dark.png" type="BINDATA" />
<include name="IDR_AURA_SWITCH_MONITOR" file="aura/switch_monitor.png" type="BINDATA" />
<include name="IDR_OAK" file="oak.png" type="BINDATA"/>