summaryrefslogtreecommitdiffstats
path: root/ash/system/tray_update.cc
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 /ash/system/tray_update.cc
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
Diffstat (limited to 'ash/system/tray_update.cc')
-rw-r--r--ash/system/tray_update.cc82
1 files changed, 82 insertions, 0 deletions
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