Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2424)

Unified Diff: ash/system/tray/tray_notification_view.cc

Issue 2066583004: mash: Move most files in //ash/system/tray to //ash/common/system/tray (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trayupdatemove
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/tray_notification_view.h ('k') | ash/system/tray/tray_popup_header_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_notification_view.cc
diff --git a/ash/system/tray/tray_notification_view.cc b/ash/system/tray/tray_notification_view.cc
deleted file mode 100644
index 12e7d8418f97ca460930de2d1fd40013364d1fcb..0000000000000000000000000000000000000000
--- a/ash/system/tray/tray_notification_view.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-// 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/tray_notification_view.h"
-
-#include "ash/common/system/tray/system_tray_item.h"
-#include "ash/common/system/tray/tray_constants.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/resources/grit/ui_resources.h"
-#include "ui/views/background.h"
-#include "ui/views/controls/button/image_button.h"
-#include "ui/views/controls/image_view.h"
-#include "ui/views/layout/grid_layout.h"
-
-namespace ash {
-
-TrayNotificationView::TrayNotificationView(SystemTrayItem* owner, int icon_id)
- : owner_(owner),
- icon_id_(icon_id),
- icon_(NULL),
- autoclose_delay_(0) {
-}
-
-TrayNotificationView::~TrayNotificationView() {
-}
-
-void TrayNotificationView::InitView(views::View* contents) {
- set_background(views::Background::CreateSolidBackground(kBackgroundColor));
-
- views::GridLayout* layout = new views::GridLayout(this);
- SetLayoutManager(layout);
-
- views::ImageButton* close_button = new views::ImageButton(this);
- close_button->SetImage(views::CustomButton::STATE_NORMAL,
- ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
- IDR_MESSAGE_CLOSE));
- close_button->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
- views::ImageButton::ALIGN_MIDDLE);
-
- icon_ = new views::ImageView;
- if (icon_id_ != 0) {
- icon_->SetImage(
- ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id_));
- }
-
- views::ColumnSet* columns = layout->AddColumnSet(0);
-
- columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2);
-
- // Icon
- columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER,
- 0, /* resize percent */
- views::GridLayout::FIXED,
- kNotificationIconWidth, kNotificationIconWidth);
-
- columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2);
-
- // Contents
- columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
- 100, /* resize percent */
- views::GridLayout::FIXED,
- kTrayNotificationContentsWidth,
- kTrayNotificationContentsWidth);
-
- columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2);
-
- // Close button
- columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING,
- 0, /* resize percent */
- views::GridLayout::FIXED,
- kNotificationButtonWidth, kNotificationButtonWidth);
-
- // Layout rows
- layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems);
- layout->StartRow(0, 0);
- layout->AddView(icon_);
- layout->AddView(contents);
- layout->AddView(close_button);
- layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems);
-}
-
-void TrayNotificationView::SetIconImage(const gfx::ImageSkia& image) {
- icon_->SetImage(image);
- SchedulePaint();
-}
-
-void TrayNotificationView::UpdateView(views::View* new_contents) {
- RemoveAllChildViews(true);
- InitView(new_contents);
- Layout();
- PreferredSizeChanged();
- SchedulePaint();
-}
-
-void TrayNotificationView::UpdateViewAndImage(views::View* new_contents,
- const gfx::ImageSkia& image) {
- RemoveAllChildViews(true);
- InitView(new_contents);
- icon_->SetImage(image);
- Layout();
- PreferredSizeChanged();
- SchedulePaint();
-}
-
-void TrayNotificationView::StartAutoCloseTimer(int seconds) {
- autoclose_.Stop();
- autoclose_delay_ = seconds;
- if (autoclose_delay_) {
- autoclose_.Start(FROM_HERE,
- base::TimeDelta::FromSeconds(autoclose_delay_),
- this, &TrayNotificationView::HandleClose);
- }
-}
-
-void TrayNotificationView::StopAutoCloseTimer() {
- autoclose_.Stop();
-}
-
-void TrayNotificationView::RestartAutoCloseTimer() {
- if (autoclose_delay_)
- StartAutoCloseTimer(autoclose_delay_);
-}
-
-void TrayNotificationView::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- HandleClose();
-}
-
-bool TrayNotificationView::OnMousePressed(const ui::MouseEvent& event) {
- HandleClickAction();
- return true;
-}
-
-void TrayNotificationView::OnGestureEvent(ui::GestureEvent* event) {
- SlideOutView::OnGestureEvent(event);
- if (event->handled())
- return;
- if (event->type() != ui::ET_GESTURE_TAP)
- return;
- HandleClickAction();
- event->SetHandled();
-}
-
-void TrayNotificationView::OnClose() {
-}
-
-void TrayNotificationView::OnClickAction() {
-}
-
-void TrayNotificationView::OnSlideOut() {
- owner_->HideNotificationView();
-}
-
-void TrayNotificationView::HandleClose() {
- OnClose();
- owner_->HideNotificationView();
-}
-
-void TrayNotificationView::HandleClickAction() {
- HandleClose();
- OnClickAction();
-}
-
-} // namespace ash
« no previous file with comments | « ash/system/tray/tray_notification_view.h ('k') | ash/system/tray/tray_popup_header_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698