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

Side by Side Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2704933011: Add notification settings button to ARC notifications. (Closed)
Patch Set: Add notification settings button to ARC notifications. 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/arc/notification/arc_custom_notification_view.h ('k') | ui/message_center/BUILD.gn » ('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 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/arc/notification/arc_custom_notification_view.h" 5 #include "ui/arc/notification/arc_custom_notification_view.h"
6 6
7 #include "ash/wm/window_util.h" 7 #include "ash/wm/window_util.h"
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "components/exo/notification_surface.h" 10 #include "components/exo/notification_surface.h"
11 #include "components/exo/surface.h" 11 #include "components/exo/surface.h"
12 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/display/screen.h" 16 #include "ui/display/screen.h"
17 #include "ui/events/event_handler.h" 17 #include "ui/events/event_handler.h"
18 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/image/image_skia.h" 19 #include "ui/gfx/image/image_skia.h"
20 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
21 #include "ui/message_center/message_center_style.h" 21 #include "ui/message_center/message_center_style.h"
22 #include "ui/message_center/views/custom_notification_view.h" 22 #include "ui/message_center/views/custom_notification_view.h"
23 #include "ui/resources/grit/ui_resources.h" 23 #include "ui/resources/grit/ui_resources.h"
24 #include "ui/strings/grit/ui_strings.h" 24 #include "ui/strings/grit/ui_strings.h"
25 #include "ui/views/background.h" 25 #include "ui/views/background.h"
26 #include "ui/views/border.h" 26 #include "ui/views/border.h"
27 #include "ui/views/controls/button/image_button.h" 27 #include "ui/views/controls/button/image_button.h"
28 #include "ui/views/focus/focus_manager.h" 28 #include "ui/views/focus/focus_manager.h"
29 #include "ui/views/layout/box_layout.h"
29 #include "ui/views/painter.h" 30 #include "ui/views/painter.h"
30 #include "ui/views/widget/root_view.h" 31 #include "ui/views/widget/root_view.h"
31 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
32 #include "ui/wm/core/window_util.h" 33 #include "ui/wm/core/window_util.h"
33 34
34 namespace arc { 35 namespace arc {
35 36
36 class ArcCustomNotificationView::EventForwarder : public ui::EventHandler { 37 class ArcCustomNotificationView::EventForwarder : public ui::EventHandler {
37 public: 38 public:
38 explicit EventForwarder(ArcCustomNotificationView* owner) : owner_(owner) {} 39 explicit EventForwarder(ArcCustomNotificationView* owner) : owner_(owner) {}
39 ~EventForwarder() override = default; 40 ~EventForwarder() override = default;
40 41
41 private: 42 private:
42 // ui::EventHandler 43 // ui::EventHandler
43 void OnEvent(ui::Event* event) override { 44 void OnEvent(ui::Event* event) override {
44 // Do not forward event targeted to the floating close button so that 45 // Do not forward event targeted to the floating close button so that
45 // keyboard press and tap are handled properly. 46 // keyboard press and tap are handled properly.
46 if (owner_->floating_close_button_widget_ && event->target() && 47 if (owner_->floating_control_buttons_widget_ && event->target() &&
47 owner_->floating_close_button_widget_->GetNativeWindow() == 48 owner_->floating_control_buttons_widget_->GetNativeWindow() ==
48 event->target()) { 49 event->target()) {
49 return; 50 return;
50 } 51 }
51 52
52 if (event->IsScrollEvent()) { 53 if (event->IsScrollEvent()) {
53 ForwardScrollEvent(event->AsScrollEvent()); 54 ForwardScrollEvent(event->AsScrollEvent());
54 } else if (event->IsMouseWheelEvent()) { 55 } else if (event->IsMouseWheelEvent()) {
55 ForwardMouseWheelEvent(event->AsMouseWheelEvent()); 56 ForwardMouseWheelEvent(event->AsMouseWheelEvent());
56 } else if (!event->IsTouchEvent()) { 57 } else if (!event->IsTouchEvent()) {
57 // Forward the rest events to |owner_| except touches because View 58 // Forward the rest events to |owner_| except touches because View
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 DISALLOW_COPY_AND_ASSIGN(SlideHelper); 151 DISALLOW_COPY_AND_ASSIGN(SlideHelper);
151 }; 152 };
152 153
153 class ArcCustomNotificationView::ContentViewDelegate 154 class ArcCustomNotificationView::ContentViewDelegate
154 : public message_center::CustomNotificationContentViewDelegate { 155 : public message_center::CustomNotificationContentViewDelegate {
155 public: 156 public:
156 explicit ContentViewDelegate(ArcCustomNotificationView* owner) 157 explicit ContentViewDelegate(ArcCustomNotificationView* owner)
157 : owner_(owner) {} 158 : owner_(owner) {}
158 159
159 bool IsCloseButtonFocused() const override { 160 bool IsCloseButtonFocused() const override {
160 if (owner_->floating_close_button_ == nullptr) 161 if (owner_->close_button_ == nullptr)
161 return false; 162 return false;
162 return owner_->floating_close_button_->HasFocus(); 163 return owner_->close_button_->HasFocus();
163 } 164 }
164 165
165 void RequestFocusOnCloseButton() override { 166 void RequestFocusOnCloseButton() override {
166 if (owner_->floating_close_button_) 167 if (owner_->close_button_)
167 owner_->floating_close_button_->RequestFocus(); 168 owner_->close_button_->RequestFocus();
168 owner_->UpdateCloseButtonVisiblity(); 169 owner_->UpdateControlButtonsVisiblity();
169 } 170 }
170 171
171 bool IsPinned() const override { 172 bool IsPinned() const override {
172 return owner_->item_->pinned(); 173 return owner_->item_->pinned();
173 } 174 }
174 175
175 private: 176 private:
176 ArcCustomNotificationView* const owner_; 177 ArcCustomNotificationView* const owner_;
177 178
178 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); 179 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate);
179 }; 180 };
180 181
181 class ArcCustomNotificationView::CloseButton : public views::ImageButton { 182 class ArcCustomNotificationView::ControlButton : public views::ImageButton {
182 public: 183 public:
183 explicit CloseButton(ArcCustomNotificationView* owner) 184 explicit ControlButton(ArcCustomNotificationView* owner)
184 : views::ImageButton(owner), owner_(owner) { 185 : views::ImageButton(owner), owner_(owner) {
185 set_background( 186 set_background(
186 views::Background::CreateSolidBackground(SK_ColorTRANSPARENT)); 187 views::Background::CreateSolidBackground(SK_ColorTRANSPARENT));
187 SetFocusForPlatform(); 188 SetFocusForPlatform();
188 SetFocusPainter(views::Painter::CreateSolidFocusPainter( 189 SetFocusPainter(views::Painter::CreateSolidFocusPainter(
189 message_center::kFocusBorderColor, gfx::Insets(1, 2, 2, 2))); 190 message_center::kFocusBorderColor, gfx::Insets(1, 2, 2, 2)));
190 191
191 // The sizes below are in DIPs. 192 // The sizes below are in DIPs.
192 SetBorder(views::CreateEmptyBorder( 193 SetBorder(views::CreateEmptyBorder(
193 message_center::kControlButtonPaddingFromBorder, 194 message_center::kControlButtonPaddingFromBorder,
194 message_center::kControlButtonPaddingFromBorder, 195 message_center::kControlButtonPaddingFromBorder,
195 message_center::kControlButtonPaddingFromBorder, 196 message_center::kControlButtonPaddingFromBorder,
196 message_center::kControlButtonPaddingFromBorder)); 197 message_center::kControlButtonPaddingFromBorder));
197 198
198 SetImage(views::CustomButton::STATE_NORMAL, message_center::GetCloseIcon());
199 set_animate_on_state_change(false); 199 set_animate_on_state_change(false);
200 SetAccessibleName(l10n_util::GetStringUTF16(
201 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME));
202 SetTooltipText(l10n_util::GetStringUTF16(
203 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP));
204 } 200 }
205 201
206 void OnFocus() override { 202 void OnFocus() override {
207 views::ImageButton::OnFocus(); 203 views::ImageButton::OnFocus();
208 owner_->UpdateCloseButtonVisiblity(); 204 owner_->UpdateControlButtonsVisiblity();
209 } 205 }
210 206
211 void OnBlur() override { 207 void OnBlur() override {
212 views::ImageButton::OnBlur(); 208 views::ImageButton::OnBlur();
213 owner_->UpdateCloseButtonVisiblity(); 209 owner_->UpdateControlButtonsVisiblity();
214 } 210 }
215 211
216 private: 212 private:
217 ArcCustomNotificationView* const owner_; 213 ArcCustomNotificationView* const owner_;
218 }; 214 };
219 215
220 ArcCustomNotificationView::ArcCustomNotificationView( 216 ArcCustomNotificationView::ArcCustomNotificationView(
221 ArcCustomNotificationItem* item) 217 ArcCustomNotificationItem* item)
222 : item_(item), 218 : item_(item),
223 notification_key_(item->notification_key()), 219 notification_key_(item->notification_key()),
(...skipping 23 matching lines...) Expand all
247 243
248 if (ArcNotificationSurfaceManager::Get()) 244 if (ArcNotificationSurfaceManager::Get())
249 ArcNotificationSurfaceManager::Get()->RemoveObserver(this); 245 ArcNotificationSurfaceManager::Get()->RemoveObserver(this);
250 } 246 }
251 247
252 std::unique_ptr<message_center::CustomNotificationContentViewDelegate> 248 std::unique_ptr<message_center::CustomNotificationContentViewDelegate>
253 ArcCustomNotificationView::CreateContentViewDelegate() { 249 ArcCustomNotificationView::CreateContentViewDelegate() {
254 return base::MakeUnique<ArcCustomNotificationView::ContentViewDelegate>(this); 250 return base::MakeUnique<ArcCustomNotificationView::ContentViewDelegate>(this);
255 } 251 }
256 252
257 void ArcCustomNotificationView::CreateFloatingCloseButton() { 253 void ArcCustomNotificationView::CreateFloatingControlButtons() {
258 // Floating close button is a transient child of |surface_| and also part 254 // Floating close button is a transient child of |surface_| and also part
259 // of the hosting widget's focus chain. It could only be created when both 255 // of the hosting widget's focus chain. It could only be created when both
260 // are present. 256 // are present.
261 if (!surface_ || !GetWidget()) 257 if (!surface_ || !GetWidget())
262 return; 258 return;
263 259
264 floating_close_button_ = new CloseButton(this); 260 // Creates the control_buttons_view_, which collects all control buttons into
261 // a horizontal box.
262 control_buttons_view_ = new views::View();
263 control_buttons_view_->SetLayoutManager(
264 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
265
266 settings_button_ = new ControlButton(this);
267 settings_button_->SetImage(views::CustomButton::STATE_NORMAL,
268 message_center::GetSettingsIcon());
269 settings_button_->SetAccessibleName(l10n_util::GetStringUTF16(
270 IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME));
271 settings_button_->SetTooltipText(l10n_util::GetStringUTF16(
272 IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME));
273 control_buttons_view_->AddChildView(settings_button_);
274
275 close_button_ = new ControlButton(this);
276 close_button_->SetImage(views::CustomButton::STATE_NORMAL,
277 message_center::GetCloseIcon());
278 close_button_->SetAccessibleName(l10n_util::GetStringUTF16(
279 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME));
280 close_button_->SetTooltipText(l10n_util::GetStringUTF16(
281 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP));
282 control_buttons_view_->AddChildView(close_button_);
265 283
266 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); 284 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
267 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 285 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
268 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 286 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
269 params.parent = surface_->window(); 287 params.parent = surface_->window();
270 288
271 floating_close_button_widget_.reset(new views::Widget); 289 floating_control_buttons_widget_.reset(new views::Widget);
272 floating_close_button_widget_->Init(params); 290 floating_control_buttons_widget_->Init(params);
273 floating_close_button_widget_->SetContentsView(floating_close_button_); 291 floating_control_buttons_widget_->SetContentsView(control_buttons_view_);
274 292
275 // Put the close button into the focus chain. 293 // Put the close button into the focus chain.
276 floating_close_button_widget_->SetFocusTraversableParent( 294 floating_control_buttons_widget_->SetFocusTraversableParent(
277 GetWidget()->GetFocusTraversable()); 295 GetWidget()->GetFocusTraversable());
278 floating_close_button_widget_->SetFocusTraversableParentView(this); 296 floating_control_buttons_widget_->SetFocusTraversableParentView(this);
279 297
280 Layout(); 298 Layout();
281 } 299 }
282 300
283 void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) { 301 void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) {
284 if (surface_ == surface) 302 if (surface_ == surface)
285 return; 303 return;
286 304
287 // Reset |floating_close_button_widget_| when |surface_| is changed. 305 // Reset |floating_control_buttons_widget_| when |surface_| is changed.
288 floating_close_button_widget_.reset(); 306 floating_control_buttons_widget_.reset();
289 307
290 if (surface_ && surface_->window()) { 308 if (surface_ && surface_->window()) {
291 surface_->window()->RemoveObserver(this); 309 surface_->window()->RemoveObserver(this);
292 surface_->window()->RemovePreTargetHandler(event_forwarder_.get()); 310 surface_->window()->RemovePreTargetHandler(event_forwarder_.get());
293 } 311 }
294 312
295 surface_ = surface; 313 surface_ = surface;
296 314
297 if (surface_ && surface_->window()) { 315 if (surface_ && surface_->window()) {
298 surface_->window()->AddObserver(this); 316 surface_->window()->AddObserver(this);
(...skipping 14 matching lines...) Expand all
313 if (preferred_size.width() != message_center::kNotificationWidth) { 331 if (preferred_size.width() != message_center::kNotificationWidth) {
314 const float scale = static_cast<float>(message_center::kNotificationWidth) / 332 const float scale = static_cast<float>(message_center::kNotificationWidth) /
315 preferred_size.width(); 333 preferred_size.width();
316 preferred_size.SetSize(message_center::kNotificationWidth, 334 preferred_size.SetSize(message_center::kNotificationWidth,
317 preferred_size.height() * scale); 335 preferred_size.height() * scale);
318 } 336 }
319 337
320 SetPreferredSize(preferred_size); 338 SetPreferredSize(preferred_size);
321 } 339 }
322 340
323 void ArcCustomNotificationView::UpdateCloseButtonVisiblity() { 341 void ArcCustomNotificationView::UpdateControlButtonsVisiblity() {
324 if (!surface_ || !floating_close_button_widget_) 342 if (!surface_ || !floating_control_buttons_widget_)
325 return; 343 return;
326 344
327 const bool target_visiblity = 345 const bool target_visiblity =
328 surface_->window()->GetBoundsInScreen().Contains( 346 surface_->window()->GetBoundsInScreen().Contains(
329 display::Screen::GetScreen()->GetCursorScreenPoint()) || 347 display::Screen::GetScreen()->GetCursorScreenPoint()) ||
330 floating_close_button_->HasFocus(); 348 close_button_->HasFocus() || settings_button_->HasFocus();
331 if (target_visiblity == floating_close_button_widget_->IsVisible()) 349 if (target_visiblity == floating_control_buttons_widget_->IsVisible())
332 return; 350 return;
333 351
334 if (target_visiblity) 352 if (target_visiblity)
335 floating_close_button_widget_->Show(); 353 floating_control_buttons_widget_->Show();
336 else 354 else
337 floating_close_button_widget_->Hide(); 355 floating_control_buttons_widget_->Hide();
338 } 356 }
339 357
340 void ArcCustomNotificationView::UpdatePinnedState() { 358 void ArcCustomNotificationView::UpdatePinnedState() {
341 DCHECK(item_); 359 DCHECK(item_);
342 360
343 if (item_->pinned() && floating_close_button_widget_) { 361 if (item_->pinned() && floating_control_buttons_widget_) {
344 floating_close_button_widget_.reset(); 362 floating_control_buttons_widget_.reset();
345 } else if (!item_->pinned() && !floating_close_button_widget_) { 363 } else if (!item_->pinned() && !floating_control_buttons_widget_) {
346 CreateFloatingCloseButton(); 364 CreateFloatingControlButtons();
347 } 365 }
348 } 366 }
349 367
350 void ArcCustomNotificationView::UpdateSnapshot() { 368 void ArcCustomNotificationView::UpdateSnapshot() {
351 // Bail if we have a |surface_| because it controls the sizes and paints UI. 369 // Bail if we have a |surface_| because it controls the sizes and paints UI.
352 if (surface_) 370 if (surface_)
353 return; 371 return;
354 372
355 UpdatePreferredSize(); 373 UpdatePreferredSize();
356 SchedulePaint(); 374 SchedulePaint();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) { 440 if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) {
423 transform.Scale( 441 transform.Scale(
424 static_cast<float>(contents_size.width()) / surface_size.width(), 442 static_cast<float>(contents_size.width()) / surface_size.width(),
425 static_cast<float>(contents_size.height()) / surface_size.height()); 443 static_cast<float>(contents_size.height()) / surface_size.height());
426 } 444 }
427 445
428 // Apply the transform to the surface content so that close button can 446 // Apply the transform to the surface content so that close button can
429 // be positioned without the need to consider the transform. 447 // be positioned without the need to consider the transform.
430 surface_->window()->children()[0]->SetTransform(transform); 448 surface_->window()->children()[0]->SetTransform(transform);
431 449
432 if (!floating_close_button_widget_) 450 if (!floating_control_buttons_widget_)
433 return; 451 return;
434 452
435 gfx::Rect close_button_bounds(floating_close_button_->GetPreferredSize()); 453 gfx::Rect control_buttons_bounds(contents_bounds);
436 close_button_bounds.set_x(contents_bounds.right() - 454 const int buttons_width = close_button_->GetPreferredSize().width() +
437 close_button_bounds.width()); 455 settings_button_->GetPreferredSize().width();
438 close_button_bounds.set_y(contents_bounds.y()); 456 control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width);
439 floating_close_button_widget_->SetBounds(close_button_bounds); 457 control_buttons_bounds.set_height(close_button_->GetPreferredSize().height());
458 control_buttons_bounds.set_width(buttons_width);
459 floating_control_buttons_widget_->SetBounds(control_buttons_bounds);
440 460
441 UpdateCloseButtonVisiblity(); 461 UpdateControlButtonsVisiblity();
442 462
443 ash::wm::SnapWindowToPixelBoundary(surface_->window()); 463 ash::wm::SnapWindowToPixelBoundary(surface_->window());
444 } 464 }
445 465
446 void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) { 466 void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) {
447 views::NativeViewHost::OnPaint(canvas); 467 views::NativeViewHost::OnPaint(canvas);
448 468
449 // Bail if there is a |surface_| or no item or no snapshot image. 469 // Bail if there is a |surface_| or no item or no snapshot image.
450 if (surface_ || !item_ || item_->snapshot().isNull()) 470 if (surface_ || !item_ || item_->snapshot().isNull())
451 return; 471 return;
(...skipping 12 matching lines...) Expand all
464 void ArcCustomNotificationView::OnGestureEvent(ui::GestureEvent* event) { 484 void ArcCustomNotificationView::OnGestureEvent(ui::GestureEvent* event) {
465 // Forward to parent CustomNotificationView to handle sliding out. 485 // Forward to parent CustomNotificationView to handle sliding out.
466 parent()->OnGestureEvent(event); 486 parent()->OnGestureEvent(event);
467 487
468 // |slide_helper_| could be null before |surface_| is attached. 488 // |slide_helper_| could be null before |surface_| is attached.
469 if (slide_helper_) 489 if (slide_helper_)
470 slide_helper_->Update(); 490 slide_helper_->Update();
471 } 491 }
472 492
473 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) { 493 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) {
474 UpdateCloseButtonVisiblity(); 494 UpdateControlButtonsVisiblity();
475 } 495 }
476 496
477 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) { 497 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) {
478 UpdateCloseButtonVisiblity(); 498 UpdateControlButtonsVisiblity();
479 } 499 }
480 500
481 void ArcCustomNotificationView::OnFocus() { 501 void ArcCustomNotificationView::OnFocus() {
482 NativeViewHost::OnFocus(); 502 NativeViewHost::OnFocus();
483 static_cast<message_center::CustomNotificationView*>(parent()) 503 static_cast<message_center::CustomNotificationView*>(parent())
484 ->OnContentFocused(); 504 ->OnContentFocused();
485 } 505 }
486 506
487 void ArcCustomNotificationView::OnBlur() { 507 void ArcCustomNotificationView::OnBlur() {
488 NativeViewHost::OnBlur(); 508 NativeViewHost::OnBlur();
489 static_cast<message_center::CustomNotificationView*>(parent()) 509 static_cast<message_center::CustomNotificationView*>(parent())
490 ->OnContentBlured(); 510 ->OnContentBlured();
491 } 511 }
492 512
493 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { 513 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() {
494 if (floating_close_button_widget_) 514 if (floating_control_buttons_widget_)
495 return static_cast<views::internal::RootView*>( 515 return static_cast<views::internal::RootView*>(
496 floating_close_button_widget_->GetRootView()); 516 floating_control_buttons_widget_->GetRootView());
497 return nullptr; 517 return nullptr;
498 } 518 }
499 519
500 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, 520 void ArcCustomNotificationView::ButtonPressed(views::Button* sender,
501 const ui::Event& event) { 521 const ui::Event& event) {
502 if (item_ && !item_->pinned() && sender == floating_close_button_) { 522 if (item_ && !item_->pinned() && sender == close_button_) {
503 item_->CloseFromCloseButton(); 523 item_->CloseFromCloseButton();
504 } 524 }
525 if (item_ && settings_button_ && sender == settings_button_) {
526 item_->OpenSettings();
527 }
505 } 528 }
506 529
507 void ArcCustomNotificationView::OnWindowBoundsChanged( 530 void ArcCustomNotificationView::OnWindowBoundsChanged(
508 aura::Window* window, 531 aura::Window* window,
509 const gfx::Rect& old_bounds, 532 const gfx::Rect& old_bounds,
510 const gfx::Rect& new_bounds) { 533 const gfx::Rect& new_bounds) {
511 if (in_layout_) 534 if (in_layout_)
512 return; 535 return;
513 536
514 UpdatePreferredSize(); 537 UpdatePreferredSize();
(...skipping 28 matching lines...) Expand all
543 566
544 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( 567 void ArcCustomNotificationView::OnNotificationSurfaceRemoved(
545 exo::NotificationSurface* surface) { 568 exo::NotificationSurface* surface) {
546 if (surface->notification_id() != notification_key_) 569 if (surface->notification_id() != notification_key_)
547 return; 570 return;
548 571
549 SetSurface(nullptr); 572 SetSurface(nullptr);
550 } 573 }
551 574
552 } // namespace arc 575 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_custom_notification_view.h ('k') | ui/message_center/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698