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

Unified Diff: ui/arc/notification/arc_notification_view.cc

Issue 2870283002: Move message_center::CustomNotificationView to arc::ArcNotificationView (Closed)
Patch Set: Fixed test Created 3 years, 7 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
Index: ui/arc/notification/arc_notification_view.cc
diff --git a/ui/message_center/views/custom_notification_view.cc b/ui/arc/notification/arc_notification_view.cc
similarity index 58%
rename from ui/message_center/views/custom_notification_view.cc
rename to ui/arc/notification/arc_notification_view.cc
index c20104bf5e764329a415ef0056137ea7b8e46679..5a7a756789e8e0cc3723d725ce0e452aae1ed4fe 100644
--- a/ui/message_center/views/custom_notification_view.cc
+++ b/ui/arc/notification/arc_notification_view.cc
@@ -1,11 +1,13 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright 2017 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 "ui/message_center/views/custom_notification_view.h"
+#include "ui/arc/notification/arc_notification_view.h"
#include <algorithm>
+#include "ui/arc/notification/arc_custom_notification_view.h"
+#include "ui/arc/notification/arc_notification_item.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/base/ime/text_input_type.h"
@@ -17,24 +19,24 @@
#include "ui/views/controls/image_view.h"
#include "ui/views/painter.h"
-namespace message_center {
+namespace arc {
// static
-const char CustomNotificationView::kViewClassName[] = "CustomNotificationView";
+const char ArcNotificationView::kViewClassName[] = "ArcNotificationView";
-CustomNotificationView::CustomNotificationView(
- MessageCenterController* controller,
- const Notification& notification)
- : MessageView(controller, notification) {
- DCHECK_EQ(NOTIFICATION_TYPE_CUSTOM, notification.type());
+ArcNotificationView::ArcNotificationView(
+ std::unique_ptr<views::View> contents_view,
+ std::unique_ptr<ArcNotificationContentViewDelegate> contents_view_delegate,
+ message_center::MessageCenterController* controller,
+ const message_center::Notification& notification)
+ : message_center::MessageView(controller, notification) {
+ DCHECK_EQ(message_center::NOTIFICATION_TYPE_CUSTOM, notification.type());
- auto custom_content = notification.delegate()->CreateCustomContent();
-
- contents_view_ = custom_content->view.release();
+ contents_view_ = contents_view.release();
hidehiko 2017/05/11 14:22:47 Could you initialize this in the initializer list
yoshiki 2017/05/12 08:42:37 Done.
DCHECK(contents_view_);
AddChildView(contents_view_);
- contents_view_delegate_ = std::move(custom_content->delegate);
+ contents_view_delegate_ = std::move(contents_view_delegate);
hidehiko 2017/05/11 14:22:47 Ditto.
yoshiki 2017/05/12 08:42:37 Done.
DCHECK(contents_view_delegate_);
if (contents_view_->background()) {
@@ -43,56 +45,58 @@ CustomNotificationView::CustomNotificationView(
}
focus_painter_ = views::Painter::CreateSolidFocusPainter(
- kFocusBorderColor, gfx::Insets(0, 1, 3, 2));
+ message_center::kFocusBorderColor, gfx::Insets(0, 1, 3, 2));
}
-CustomNotificationView::~CustomNotificationView() {}
+ArcNotificationView::~ArcNotificationView() {}
hidehiko 2017/05/11 14:22:47 As you're here, could you s/{}/= default/?
yoshiki 2017/05/12 08:42:37 Done.
-void CustomNotificationView::OnContentFocused() {
+void ArcNotificationView::OnContentFocused() {
SchedulePaint();
}
-void CustomNotificationView::OnContentBlured() {
+void ArcNotificationView::OnContentBlured() {
SchedulePaint();
}
-void CustomNotificationView::SetDrawBackgroundAsActive(bool active) {
+void ArcNotificationView::SetDrawBackgroundAsActive(bool active) {
// Do nothing if |contents_view_| has a background.
if (contents_view_->background())
return;
- MessageView::SetDrawBackgroundAsActive(active);
+ message_center::MessageView::SetDrawBackgroundAsActive(active);
}
-bool CustomNotificationView::IsCloseButtonFocused() const {
+bool ArcNotificationView::IsCloseButtonFocused() const {
if (!contents_view_delegate_)
return false;
return contents_view_delegate_->IsCloseButtonFocused();
}
-void CustomNotificationView::RequestFocusOnCloseButton() {
+void ArcNotificationView::RequestFocusOnCloseButton() {
if (contents_view_delegate_)
contents_view_delegate_->RequestFocusOnCloseButton();
}
-const char* CustomNotificationView::GetClassName() const {
+const char* ArcNotificationView::GetClassName() const {
return kViewClassName;
}
-void CustomNotificationView::UpdateControlButtonsVisibility() {
+void ArcNotificationView::UpdateControlButtonsVisibility() {
if (contents_view_delegate_)
contents_view_delegate_->UpdateControlButtonsVisibility();
}
-gfx::Size CustomNotificationView::GetPreferredSize() const {
+gfx::Size ArcNotificationView::GetPreferredSize() const {
const gfx::Insets insets = GetInsets();
- const int contents_width = kNotificationWidth - insets.width();
+ const int contents_width =
+ message_center::kNotificationWidth - insets.width();
const int contents_height = contents_view_->GetHeightForWidth(contents_width);
- return gfx::Size(kNotificationWidth, contents_height + insets.height());
+ return gfx::Size(message_center::kNotificationWidth,
+ contents_height + insets.height());
}
-void CustomNotificationView::Layout() {
- MessageView::Layout();
+void ArcNotificationView::Layout() {
+ message_center::MessageView::Layout();
contents_view_->SetBoundsRect(GetContentsBounds());
@@ -101,30 +105,30 @@ void CustomNotificationView::Layout() {
SetFocusBehavior(FocusBehavior::NEVER);
}
-bool CustomNotificationView::HasFocus() const {
+bool ArcNotificationView::HasFocus() const {
// In case that focus handling is defered to the content view, asking the
// content view about focus.
if (contents_view_ && contents_view_->IsFocusable())
return contents_view_->HasFocus();
else
- return MessageView::HasFocus();
+ return message_center::MessageView::HasFocus();
}
-void CustomNotificationView::RequestFocus() {
+void ArcNotificationView::RequestFocus() {
if (contents_view_ && contents_view_->IsFocusable())
contents_view_->RequestFocus();
else
- MessageView::RequestFocus();
+ message_center::MessageView::RequestFocus();
}
-void CustomNotificationView::OnPaint(gfx::Canvas* canvas) {
+void ArcNotificationView::OnPaint(gfx::Canvas* canvas) {
MessageView::OnPaint(canvas);
if (contents_view_ && contents_view_->IsFocusable())
views::Painter::PaintFocusPainter(contents_view_, canvas,
focus_painter_.get());
}
-bool CustomNotificationView::OnKeyPressed(const ui::KeyEvent& event) {
+bool ArcNotificationView::OnKeyPressed(const ui::KeyEvent& event) {
if (contents_view_) {
ui::InputMethod* input_method = contents_view_->GetInputMethod();
if (input_method) {
@@ -140,17 +144,17 @@ bool CustomNotificationView::OnKeyPressed(const ui::KeyEvent& event) {
}
}
- return MessageView::OnKeyPressed(event);
+ return message_center::MessageView::OnKeyPressed(event);
}
-void CustomNotificationView::ChildPreferredSizeChanged(View* child) {
+void ArcNotificationView::ChildPreferredSizeChanged(View* child) {
// Notify MessageCenterController when the custom content changes size,
// as it may need to relayout.
if (controller())
controller()->UpdateNotificationSize(notification_id());
}
-bool CustomNotificationView::HandleAccessibleAction(
+bool ArcNotificationView::HandleAccessibleAction(
const ui::AXActionData& action) {
if (contents_view_)
return contents_view_->HandleAccessibleAction(action);

Powered by Google App Engine
This is Rietveld 408576698