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

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

Issue 2729533002: Adjust behavior of control buttons of notifications. (Closed)
Patch Set: Add unimplemented method to TestContentViewDelegate Created 3 years, 9 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
« no previous file with comments | « ui/message_center/views/message_center_view.h ('k') | ui/message_center/views/message_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/message_center_view.h" 5 #include "ui/message_center/views/message_center_view.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 button_bar_(NULL), 70 button_bar_(NULL),
71 settings_visible_(initially_settings_visible), 71 settings_visible_(initially_settings_visible),
72 source_view_(NULL), 72 source_view_(NULL),
73 source_height_(0), 73 source_height_(0),
74 target_view_(NULL), 74 target_view_(NULL),
75 target_height_(0), 75 target_height_(0),
76 is_closing_(false), 76 is_closing_(false),
77 is_locked_(message_center_->IsLockedState()), 77 is_locked_(message_center_->IsLockedState()),
78 mode_((!initially_settings_visible || is_locked_) ? Mode::BUTTONS_ONLY 78 mode_((!initially_settings_visible || is_locked_) ? Mode::BUTTONS_ONLY
79 : Mode::SETTINGS), 79 : Mode::SETTINGS),
80 context_menu_controller_(new MessageViewContextMenuController(this)) { 80 context_menu_controller_(new MessageViewContextMenuController(this)),
81 focus_manager_(nullptr) {
81 message_center_->AddObserver(this); 82 message_center_->AddObserver(this);
82 set_notify_enter_exit_on_child(true); 83 set_notify_enter_exit_on_child(true);
83 set_background(views::Background::CreateSolidBackground( 84 set_background(views::Background::CreateSolidBackground(
84 kMessageCenterBackgroundColor)); 85 kMessageCenterBackgroundColor));
85 86
86 NotifierSettingsProvider* notifier_settings_provider = 87 NotifierSettingsProvider* notifier_settings_provider =
87 message_center_->GetNotifierSettingsProvider(); 88 message_center_->GetNotifierSettingsProvider();
88 button_bar_ = new MessageCenterButtonBar( 89 button_bar_ = new MessageCenterButtonBar(
89 this, message_center, notifier_settings_provider, 90 this, message_center, notifier_settings_provider,
90 initially_settings_visible, GetButtonBarTitle()); 91 initially_settings_visible, GetButtonBarTitle());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 AddChildView(scroller_); 127 AddChildView(scroller_);
127 AddChildView(settings_view_); 128 AddChildView(settings_view_);
128 AddChildView(button_bar_); 129 AddChildView(button_bar_);
129 } 130 }
130 131
131 MessageCenterView::~MessageCenterView() { 132 MessageCenterView::~MessageCenterView() {
132 message_list_view_->RemoveObserver(this); 133 message_list_view_->RemoveObserver(this);
133 134
134 if (!is_closing_) 135 if (!is_closing_)
135 message_center_->RemoveObserver(this); 136 message_center_->RemoveObserver(this);
137
138 if (focus_manager_)
139 focus_manager_->RemoveFocusChangeListener(this);
140 }
141
142 void MessageCenterView::Init() {
143 focus_manager_ = GetFocusManager();
144 if (focus_manager_)
145 focus_manager_->AddFocusChangeListener(this);
136 } 146 }
137 147
138 void MessageCenterView::SetNotifications( 148 void MessageCenterView::SetNotifications(
139 const NotificationList::Notifications& notifications) { 149 const NotificationList::Notifications& notifications) {
140 if (is_closing_) 150 if (is_closing_)
141 return; 151 return;
142 152
143 notification_views_.clear(); 153 notification_views_.clear();
144 154
145 int index = 0; 155 int index = 0;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 207 }
198 208
199 void MessageCenterView::SetIsClosing(bool is_closing) { 209 void MessageCenterView::SetIsClosing(bool is_closing) {
200 is_closing_ = is_closing; 210 is_closing_ = is_closing;
201 if (is_closing) 211 if (is_closing)
202 message_center_->RemoveObserver(this); 212 message_center_->RemoveObserver(this);
203 else 213 else
204 message_center_->AddObserver(this); 214 message_center_->AddObserver(this);
205 } 215 }
206 216
217 void MessageCenterView::OnDidChangeFocus(views::View* before,
218 views::View* now) {
219 if (message_list_view_ && (message_list_view_->Contains(before) ||
220 message_list_view_->Contains(now))) {
221 // Focus state of a children of message view center is changed.
222 for (auto pair : notification_views_) {
223 if (pair.second->Contains(before) || pair.second->Contains(now))
224 pair.second->UpdateControlButtonsVisibility();
225 }
226 }
227 }
228
207 void MessageCenterView::Layout() { 229 void MessageCenterView::Layout() {
208 if (is_closing_) 230 if (is_closing_)
209 return; 231 return;
210 232
211 int button_height = button_bar_->GetHeightForWidth(width()) + 233 int button_height = button_bar_->GetHeightForWidth(width()) +
212 button_bar_->GetInsets().height(); 234 button_bar_->GetInsets().height();
213 // Skip unnecessary re-layout of contents during the resize animation. 235 // Skip unnecessary re-layout of contents during the resize animation.
214 bool animating = settings_transition_animation_ && 236 bool animating = settings_transition_animation_ &&
215 settings_transition_animation_->is_animating(); 237 settings_transition_animation_->is_animating();
216 if (animating && settings_transition_animation_->current_part_index() == 0) { 238 if (animating && settings_transition_animation_->current_part_index() == 0) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // Disable the close-all button since no notification is visible. 665 // Disable the close-all button since no notification is visible.
644 button_bar_->SetCloseAllButtonEnabled(false); 666 button_bar_->SetCloseAllButtonEnabled(false);
645 } 667 }
646 } 668 }
647 669
648 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { 670 void MessageCenterView::SetNotificationViewForTest(MessageView* view) {
649 message_list_view_->AddNotificationAt(view, 0); 671 message_list_view_->AddNotificationAt(view, 0);
650 } 672 }
651 673
652 } // namespace message_center 674 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_center_view.h ('k') | ui/message_center/views/message_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698