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

Unified Diff: ui/message_center/views/message_view.cc

Issue 2547433002: Transfer responsibility for providing a close button for a notification to each implementation of M… (Closed)
Patch Set: WrapUnique -> MakeUnique Created 4 years 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 | « ui/message_center/views/message_view.h ('k') | ui/message_center/views/notification_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/views/message_view.cc
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc
index 4031d01ad1bf60bdbdda7dea14f64ac69e7b5af9..df23b09e2b1f2240a866c5a0703eff49b58d00c8 100644
--- a/ui/message_center/views/message_view.cc
+++ b/ui/message_center/views/message_view.cc
@@ -14,7 +14,6 @@
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/views/message_center_controller.h"
-#include "ui/message_center/views/padded_button.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
@@ -27,9 +26,6 @@
namespace {
-constexpr int kCloseIconTopPadding = 5;
-constexpr int kCloseIconRightPadding = 5;
-
constexpr int kShadowOffset = 1;
constexpr int kShadowBlur = 4;
@@ -92,7 +88,6 @@ MessageView::~MessageView() {
void MessageView::UpdateWithNotification(const Notification& notification) {
small_image_view_->SetImage(notification.small_image().AsImageSkia());
display_source_ = notification.display_source();
- CreateOrUpdateCloseButtonView(notification);
accessible_name_ = CreateAccessibleName(notification);
}
@@ -110,24 +105,6 @@ void MessageView::CreateShadowBorder() {
message_center::kShadowColor))));
}
-bool MessageView::IsCloseButtonFocused() {
- if (!close_button_)
- return false;
-
- views::FocusManager* focus_manager = GetFocusManager();
- return focus_manager &&
- focus_manager->GetFocusedView() == close_button_.get();
-}
-
-void MessageView::RequestFocusOnCloseButton() {
- if (close_button_)
- close_button_->RequestFocus();
-}
-
-bool MessageView::IsPinned() {
- return !close_button_;
-}
-
void MessageView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ui::AX_ROLE_BUTTON;
node_data->SetName(accessible_name_);
@@ -169,7 +146,6 @@ bool MessageView::OnKeyReleased(const ui::KeyEvent& event) {
void MessageView::OnPaint(gfx::Canvas* canvas) {
DCHECK_EQ(this, small_image_view_->parent());
- DCHECK_EQ(this, close_button_->parent());
SlideOutView::OnPaint(canvas);
views::Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
}
@@ -192,16 +168,6 @@ void MessageView::Layout() {
// Background.
background_view_->SetBoundsRect(content_bounds);
- // Close button.
- if (close_button_) {
- gfx::Rect content_bounds = GetContentsBounds();
- gfx::Size close_size(close_button_->GetPreferredSize());
- gfx::Rect close_rect(content_bounds.right() - close_size.width(),
- content_bounds.y(), close_size.width(),
- close_size.height());
- close_button_->SetBoundsRect(close_rect);
- }
-
gfx::Size small_image_size(small_image_view_->GetPreferredSize());
gfx::Rect small_image_rect(small_image_size);
small_image_rect.set_origin(gfx::Point(
@@ -246,13 +212,6 @@ void MessageView::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
}
-void MessageView::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- if (close_button_ && sender == close_button_.get()) {
- controller()->RemoveNotification(notification_id(), true); // By user.
- }
-}
-
void MessageView::OnSlideOut() {
controller_->RemoveNotification(notification_id_, true); // By user.
}
@@ -264,27 +223,4 @@ void MessageView::SetDrawBackgroundAsActive(bool active) {
SchedulePaint();
}
-void MessageView::CreateOrUpdateCloseButtonView(
- const Notification& notification) {
- set_slide_out_enabled(!notification.pinned());
-
- if (!notification.pinned() && !close_button_) {
- PaddedButton* close = new PaddedButton(this);
- close->SetPadding(-kCloseIconRightPadding, kCloseIconTopPadding);
- close->SetNormalImage(IDR_NOTIFICATION_CLOSE);
- close->SetHoveredImage(IDR_NOTIFICATION_CLOSE_HOVER);
- close->SetPressedImage(IDR_NOTIFICATION_CLOSE_PRESSED);
- close->set_animate_on_state_change(false);
- close->SetAccessibleName(l10n_util::GetStringUTF16(
- IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME));
- close->SetTooltipText(l10n_util::GetStringUTF16(
- IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP));
- close->set_owned_by_client();
- AddChildView(close);
- close_button_.reset(close);
- } else if (notification.pinned() && close_button_) {
- close_button_.reset();
- }
-}
-
} // namespace message_center
« no previous file with comments | « ui/message_center/views/message_view.h ('k') | ui/message_center/views/notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698