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

Side by Side Diff: ui/message_center/views/custom_notification_view.cc

Issue 2668583005: Not Remove Non-Closable Arc Popup When Close Button is Pressed (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/message_center/views/custom_notification_view.h" 5 #include "ui/message_center/views/custom_notification_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/base/ime/input_method.h" 9 #include "ui/base/ime/input_method.h"
10 #include "ui/base/ime/text_input_client.h" 10 #include "ui/base/ime/text_input_client.h"
11 #include "ui/base/ime/text_input_type.h" 11 #include "ui/base/ime/text_input_type.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
13 #include "ui/message_center/message_center_style.h" 13 #include "ui/message_center/message_center_style.h"
14 #include "ui/message_center/views/message_center_controller.h" 14 #include "ui/message_center/views/message_center_controller.h"
15 #include "ui/views/background.h" 15 #include "ui/views/background.h"
16 #include "ui/views/controls/button/image_button.h" 16 #include "ui/views/controls/button/image_button.h"
17 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
18 #include "ui/views/painter.h" 18 #include "ui/views/painter.h"
19 19
20 namespace message_center { 20 namespace message_center {
21 21
22 // static
23 const char CustomNotificationView::kViewClassName[] = "CustomNotificationView";
24
22 CustomNotificationView::CustomNotificationView( 25 CustomNotificationView::CustomNotificationView(
23 MessageCenterController* controller, 26 MessageCenterController* controller,
24 const Notification& notification) 27 const Notification& notification)
25 : MessageView(controller, notification) { 28 : MessageView(controller, notification) {
26 DCHECK_EQ(NOTIFICATION_TYPE_CUSTOM, notification.type()); 29 DCHECK_EQ(NOTIFICATION_TYPE_CUSTOM, notification.type());
27 30
28 auto custom_content = notification.delegate()->CreateCustomContent(); 31 auto custom_content = notification.delegate()->CreateCustomContent();
29 32
30 contents_view_ = custom_content->view.release(); 33 contents_view_ = custom_content->view.release();
31 DCHECK(contents_view_); 34 DCHECK(contents_view_);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (contents_view_delegate_) 76 if (contents_view_delegate_)
74 contents_view_delegate_->RequestFocusOnCloseButton(); 77 contents_view_delegate_->RequestFocusOnCloseButton();
75 } 78 }
76 79
77 bool CustomNotificationView::IsPinned() const { 80 bool CustomNotificationView::IsPinned() const {
78 if (!contents_view_delegate_) 81 if (!contents_view_delegate_)
79 return false; 82 return false;
80 return contents_view_delegate_->IsPinned(); 83 return contents_view_delegate_->IsPinned();
81 } 84 }
82 85
86 const char* CustomNotificationView::GetClassName() const {
87 return kViewClassName;
88 }
89
83 gfx::Size CustomNotificationView::GetPreferredSize() const { 90 gfx::Size CustomNotificationView::GetPreferredSize() const {
84 const gfx::Insets insets = GetInsets(); 91 const gfx::Insets insets = GetInsets();
85 const int contents_width = kNotificationWidth - insets.width(); 92 const int contents_width = kNotificationWidth - insets.width();
86 const int contents_height = contents_view_->GetHeightForWidth(contents_width); 93 const int contents_height = contents_view_->GetHeightForWidth(contents_width);
87 94
88 // This is union of max/min height for M (256-64) and N (284-92). 95 // This is union of max/min height for M (256-64) and N (284-92).
89 constexpr int kMaxContentHeight = 284; 96 constexpr int kMaxContentHeight = 284;
90 constexpr int kMinContentHeight = 64; 97 constexpr int kMinContentHeight = 64;
91 return gfx::Size(kNotificationWidth, 98 return gfx::Size(kNotificationWidth,
92 std::max(kMinContentHeight + insets.height(), 99 std::max(kMinContentHeight + insets.height(),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return MessageView::OnKeyPressed(event); 153 return MessageView::OnKeyPressed(event);
147 } 154 }
148 155
149 void CustomNotificationView::ChildPreferredSizeChanged(View* child) { 156 void CustomNotificationView::ChildPreferredSizeChanged(View* child) {
150 // Notify MessageCenterController when the custom content changes size, 157 // Notify MessageCenterController when the custom content changes size,
151 // as it may need to relayout. 158 // as it may need to relayout.
152 controller()->UpdateNotificationSize(notification_id()); 159 controller()->UpdateNotificationSize(notification_id());
153 } 160 }
154 161
155 } // namespace message_center 162 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698