OLD | NEW |
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_notification_content_view.h" | 5 #include "ui/arc/notification/arc_notification_content_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 "ui/accessibility/ax_action_data.h" | 12 #include "ui/accessibility/ax_action_data.h" |
13 #include "ui/accessibility/ax_node_data.h" | 13 #include "ui/accessibility/ax_node_data.h" |
| 14 #include "ui/arc/notification/arc_notification_surface.h" |
14 #include "ui/arc/notification/arc_notification_view.h" | 15 #include "ui/arc/notification/arc_notification_view.h" |
15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/compositor/layer_animation_observer.h" | 18 #include "ui/compositor/layer_animation_observer.h" |
18 #include "ui/events/event_handler.h" | 19 #include "ui/events/event_handler.h" |
19 #include "ui/gfx/animation/linear_animation.h" | 20 #include "ui/gfx/animation/linear_animation.h" |
20 #include "ui/gfx/animation/tween.h" | 21 #include "ui/gfx/animation/tween.h" |
21 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
22 #include "ui/gfx/geometry/insets.h" | 23 #include "ui/gfx/geometry/insets.h" |
23 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 112 |
112 class ArcNotificationContentView::SlideHelper | 113 class ArcNotificationContentView::SlideHelper |
113 : public ui::LayerAnimationObserver { | 114 : public ui::LayerAnimationObserver { |
114 public: | 115 public: |
115 explicit SlideHelper(ArcNotificationContentView* owner) : owner_(owner) { | 116 explicit SlideHelper(ArcNotificationContentView* owner) : owner_(owner) { |
116 GetSlideOutLayer()->GetAnimator()->AddObserver(this); | 117 GetSlideOutLayer()->GetAnimator()->AddObserver(this); |
117 | 118 |
118 // Reset opacity to 1 to handle to case when the surface is sliding before | 119 // Reset opacity to 1 to handle to case when the surface is sliding before |
119 // getting managed by this class, e.g. sliding in a popup before showing | 120 // getting managed by this class, e.g. sliding in a popup before showing |
120 // in a message center view. | 121 // in a message center view. |
121 if (owner_->surface_ && owner_->surface_->window()) | 122 if (owner_->surface_ && owner_->surface_->GetWindow()) |
122 owner_->surface_->window()->layer()->SetOpacity(1.0f); | 123 owner_->surface_->GetWindow()->layer()->SetOpacity(1.0f); |
123 } | 124 } |
124 ~SlideHelper() override { | 125 ~SlideHelper() override { |
125 if (GetSlideOutLayer()) | 126 if (GetSlideOutLayer()) |
126 GetSlideOutLayer()->GetAnimator()->RemoveObserver(this); | 127 GetSlideOutLayer()->GetAnimator()->RemoveObserver(this); |
127 } | 128 } |
128 | 129 |
129 void Update() { | 130 void Update() { |
130 const bool has_animation = | 131 const bool has_animation = |
131 GetSlideOutLayer()->GetAnimator()->is_animating(); | 132 GetSlideOutLayer()->GetAnimator()->is_animating(); |
132 const bool has_transform = !GetSlideOutLayer()->transform().IsIdentity(); | 133 const bool has_transform = !GetSlideOutLayer()->transform().IsIdentity(); |
(...skipping 10 matching lines...) Expand all Loading... |
143 } | 144 } |
144 | 145 |
145 private: | 146 private: |
146 // This is a temporary hack to address crbug.com/718965 | 147 // This is a temporary hack to address crbug.com/718965 |
147 ui::Layer* GetSlideOutLayer() { | 148 ui::Layer* GetSlideOutLayer() { |
148 ui::Layer* layer = owner_->parent()->layer(); | 149 ui::Layer* layer = owner_->parent()->layer(); |
149 return layer ? layer : owner_->GetWidget()->GetLayer(); | 150 return layer ? layer : owner_->GetWidget()->GetLayer(); |
150 } | 151 } |
151 | 152 |
152 void OnSlideStart() { | 153 void OnSlideStart() { |
153 if (!owner_->surface_ || !owner_->surface_->window()) | 154 if (!owner_->surface_ || !owner_->surface_->GetWindow()) |
154 return; | 155 return; |
155 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->window()); | 156 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->GetWindow()); |
156 // |surface_copy_| is at (0, 0) in owner_->layer(). | 157 // |surface_copy_| is at (0, 0) in owner_->layer(). |
157 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size())); | 158 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size())); |
158 owner_->layer()->Add(surface_copy_->root()); | 159 owner_->layer()->Add(surface_copy_->root()); |
159 owner_->surface_->window()->layer()->SetOpacity(0.0f); | 160 owner_->surface_->GetWindow()->layer()->SetOpacity(0.0f); |
160 } | 161 } |
161 | 162 |
162 void OnSlideEnd() { | 163 void OnSlideEnd() { |
163 if (!owner_->surface_ || !owner_->surface_->window()) | 164 if (!owner_->surface_ || !owner_->surface_->GetWindow()) |
164 return; | 165 return; |
165 owner_->surface_->window()->layer()->SetOpacity(1.0f); | 166 owner_->surface_->GetWindow()->layer()->SetOpacity(1.0f); |
166 owner_->Layout(); | 167 owner_->Layout(); |
167 surface_copy_.reset(); | 168 surface_copy_.reset(); |
168 } | 169 } |
169 | 170 |
170 // ui::LayerAnimationObserver | 171 // ui::LayerAnimationObserver |
171 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override { | 172 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override { |
172 Update(); | 173 Update(); |
173 } | 174 } |
174 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override { | 175 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override { |
175 Update(); | 176 Update(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 void ArcNotificationContentView::ControlButton::OnFocus() { | 232 void ArcNotificationContentView::ControlButton::OnFocus() { |
232 message_center::PaddedButton::OnFocus(); | 233 message_center::PaddedButton::OnFocus(); |
233 owner_->UpdateControlButtonsVisibility(); | 234 owner_->UpdateControlButtonsVisibility(); |
234 } | 235 } |
235 | 236 |
236 void ArcNotificationContentView::ControlButton::OnBlur() { | 237 void ArcNotificationContentView::ControlButton::OnBlur() { |
237 message_center::PaddedButton::OnBlur(); | 238 message_center::PaddedButton::OnBlur(); |
238 owner_->UpdateControlButtonsVisibility(); | 239 owner_->UpdateControlButtonsVisibility(); |
239 } | 240 } |
240 | 241 |
| 242 // static, for ArcNotificationContentView::GetClassName(). |
| 243 const char ArcNotificationContentView::kViewClassName[] = |
| 244 "ArcNotificationContentView"; |
| 245 |
241 ArcNotificationContentView::ArcNotificationContentView( | 246 ArcNotificationContentView::ArcNotificationContentView( |
242 ArcNotificationItem* item) | 247 ArcNotificationItem* item) |
243 : item_(item), | 248 : item_(item), |
244 notification_key_(item->GetNotificationKey()), | 249 notification_key_(item->GetNotificationKey()), |
245 event_forwarder_(new EventForwarder(this)) { | 250 event_forwarder_(new EventForwarder(this)) { |
246 SetFocusBehavior(FocusBehavior::ALWAYS); | 251 SetFocusBehavior(FocusBehavior::ALWAYS); |
247 set_notify_enter_exit_on_child(true); | 252 set_notify_enter_exit_on_child(true); |
248 | 253 |
249 item_->IncrementWindowRefCount(); | 254 item_->IncrementWindowRefCount(); |
250 item_->AddObserver(this); | 255 item_->AddObserver(this); |
251 | 256 |
252 auto* surface_manager = ArcNotificationSurfaceManager::Get(); | 257 auto* surface_manager = GetSurfaceManager(); |
253 if (surface_manager) { | 258 if (surface_manager) { |
254 surface_manager->AddObserver(this); | 259 surface_manager->AddObserver(this); |
255 exo::NotificationSurface* surface = | 260 ArcNotificationSurface* surface = |
256 surface_manager->GetSurface(notification_key_); | 261 surface_manager->GetArcSurface(notification_key_); |
257 if (surface) | 262 if (surface) |
258 OnNotificationSurfaceAdded(surface); | 263 OnNotificationSurfaceAdded(surface); |
259 } | 264 } |
260 | 265 |
261 // Create a layer as an anchor to insert surface copy during a slide. | 266 // Create a layer as an anchor to insert surface copy during a slide. |
262 SetPaintToLayer(); | 267 SetPaintToLayer(); |
263 UpdatePreferredSize(); | 268 UpdatePreferredSize(); |
264 UpdateAccessibleName(); | 269 UpdateAccessibleName(); |
265 } | 270 } |
266 | 271 |
267 ArcNotificationContentView::~ArcNotificationContentView() { | 272 ArcNotificationContentView::~ArcNotificationContentView() { |
268 SetSurface(nullptr); | 273 SetSurface(nullptr); |
269 | 274 |
270 auto* surface_manager = ArcNotificationSurfaceManager::Get(); | 275 auto* surface_manager = GetSurfaceManager(); |
271 if (surface_manager) | 276 if (surface_manager) |
272 surface_manager->RemoveObserver(this); | 277 surface_manager->RemoveObserver(this); |
273 if (item_) { | 278 if (item_) { |
274 item_->RemoveObserver(this); | 279 item_->RemoveObserver(this); |
275 item_->DecrementWindowRefCount(); | 280 item_->DecrementWindowRefCount(); |
276 } | 281 } |
277 } | 282 } |
278 | 283 |
| 284 const char* ArcNotificationContentView::GetClassName() const { |
| 285 return kViewClassName; |
| 286 } |
| 287 |
279 std::unique_ptr<ArcNotificationContentViewDelegate> | 288 std::unique_ptr<ArcNotificationContentViewDelegate> |
280 ArcNotificationContentView::CreateContentViewDelegate() { | 289 ArcNotificationContentView::CreateContentViewDelegate() { |
281 return base::MakeUnique<ArcNotificationContentView::ContentViewDelegate>( | 290 return base::MakeUnique<ArcNotificationContentView::ContentViewDelegate>( |
282 this); | 291 this); |
283 } | 292 } |
284 | 293 |
| 294 ArcNotificationSurfaceManager* ArcNotificationContentView::GetSurfaceManager() |
| 295 const { |
| 296 return ArcNotificationSurfaceManager::Get(); |
| 297 } |
| 298 |
285 void ArcNotificationContentView::CreateCloseButton() { | 299 void ArcNotificationContentView::CreateCloseButton() { |
286 DCHECK(control_buttons_view_); | 300 DCHECK(control_buttons_view_); |
287 DCHECK(item_); | 301 DCHECK(item_); |
288 | 302 |
289 close_button_ = base::MakeUnique<ControlButton>(this); | 303 close_button_ = base::MakeUnique<ControlButton>(this); |
290 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 304 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
291 message_center::GetCloseIcon()); | 305 message_center::GetCloseIcon()); |
292 close_button_->SetAccessibleName(l10n_util::GetStringUTF16( | 306 close_button_->SetAccessibleName(l10n_util::GetStringUTF16( |
293 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); | 307 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); |
294 close_button_->SetTooltipText(l10n_util::GetStringUTF16( | 308 close_button_->SetTooltipText(l10n_util::GetStringUTF16( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 new views::BoxLayout(views::BoxLayout::kHorizontal)); | 340 new views::BoxLayout(views::BoxLayout::kHorizontal)); |
327 | 341 |
328 if (item_->IsOpeningSettingsSupported()) | 342 if (item_->IsOpeningSettingsSupported()) |
329 CreateSettingsButton(); | 343 CreateSettingsButton(); |
330 if (!item_->GetPinned()) | 344 if (!item_->GetPinned()) |
331 CreateCloseButton(); | 345 CreateCloseButton(); |
332 | 346 |
333 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 347 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
334 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 348 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
335 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 349 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
336 params.parent = surface_->window(); | 350 params.parent = surface_->GetWindow(); |
337 | 351 |
338 floating_control_buttons_widget_.reset(new views::Widget); | 352 floating_control_buttons_widget_.reset(new views::Widget); |
339 floating_control_buttons_widget_->Init(params); | 353 floating_control_buttons_widget_->Init(params); |
340 floating_control_buttons_widget_->SetContentsView(control_buttons_view_); | 354 floating_control_buttons_widget_->SetContentsView(control_buttons_view_); |
341 | 355 |
342 // Put the close button into the focus chain. | 356 // Put the close button into the focus chain. |
343 floating_control_buttons_widget_->SetFocusTraversableParent( | 357 floating_control_buttons_widget_->SetFocusTraversableParent( |
344 GetWidget()->GetFocusTraversable()); | 358 GetWidget()->GetFocusTraversable()); |
345 floating_control_buttons_widget_->SetFocusTraversableParentView(this); | 359 floating_control_buttons_widget_->SetFocusTraversableParentView(this); |
346 | 360 |
347 Layout(); | 361 Layout(); |
348 } | 362 } |
349 | 363 |
350 void ArcNotificationContentView::SetSurface(exo::NotificationSurface* surface) { | 364 void ArcNotificationContentView::SetSurface(ArcNotificationSurface* surface) { |
351 if (surface_ == surface) | 365 if (surface_ == surface) |
352 return; | 366 return; |
353 | 367 |
354 // Reset |floating_control_buttons_widget_| when |surface_| is changed. | 368 // Reset |floating_control_buttons_widget_| when |surface_| is changed. |
355 floating_control_buttons_widget_.reset(); | 369 floating_control_buttons_widget_.reset(); |
356 control_buttons_view_ = nullptr; | 370 control_buttons_view_ = nullptr; |
357 settings_button_ = nullptr; | 371 settings_button_ = nullptr; |
358 close_button_.reset(); | 372 close_button_.reset(); |
359 | 373 |
360 if (surface_ && surface_->window()) { | 374 if (surface_ && surface_->GetWindow()) { |
361 surface_->window()->RemoveObserver(this); | 375 surface_->GetWindow()->RemoveObserver(this); |
362 surface_->window()->RemovePreTargetHandler(event_forwarder_.get()); | 376 surface_->GetWindow()->RemovePreTargetHandler(event_forwarder_.get()); |
363 | 377 |
364 if (GetWidget()) | 378 if (GetWidget()) |
365 Detach(); | 379 surface_->Detach(); |
366 } | 380 } |
367 | 381 |
368 surface_ = surface; | 382 surface_ = surface; |
369 | 383 |
370 if (surface_ && surface_->window()) { | 384 if (surface_ && surface_->GetWindow()) { |
371 surface_->window()->AddObserver(this); | 385 surface_->GetWindow()->AddObserver(this); |
372 surface_->window()->AddPreTargetHandler(event_forwarder_.get()); | 386 surface_->GetWindow()->AddPreTargetHandler(event_forwarder_.get()); |
373 | 387 |
374 if (GetWidget()) | 388 if (GetWidget()) |
375 AttachSurface(); | 389 AttachSurface(); |
376 } | 390 } |
377 } | 391 } |
378 | 392 |
379 void ArcNotificationContentView::UpdatePreferredSize() { | 393 void ArcNotificationContentView::UpdatePreferredSize() { |
380 gfx::Size preferred_size; | 394 gfx::Size preferred_size; |
381 if (surface_) | 395 if (surface_) |
382 preferred_size = surface_->GetSize(); | 396 preferred_size = surface_->GetSize(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 SchedulePaint(); | 453 SchedulePaint(); |
440 } | 454 } |
441 | 455 |
442 void ArcNotificationContentView::AttachSurface() { | 456 void ArcNotificationContentView::AttachSurface() { |
443 DCHECK(!native_view()); | 457 DCHECK(!native_view()); |
444 | 458 |
445 if (!GetWidget()) | 459 if (!GetWidget()) |
446 return; | 460 return; |
447 | 461 |
448 UpdatePreferredSize(); | 462 UpdatePreferredSize(); |
449 Attach(surface_->window()); | 463 surface_->Attach(this); |
450 | 464 |
451 // The texture for this window can be placed at subpixel position | 465 // The texture for this window can be placed at subpixel position |
452 // with fractional scale factor. Force to align it at the pixel | 466 // with fractional scale factor. Force to align it at the pixel |
453 // boundary here, and when layout is updated in Layout(). | 467 // boundary here, and when layout is updated in Layout(). |
454 ash::wm::SnapWindowToPixelBoundary(surface_->window()); | 468 ash::wm::SnapWindowToPixelBoundary(surface_->GetWindow()); |
455 | 469 |
456 // Creates slide helper after this view is added to its parent. | 470 // Creates slide helper after this view is added to its parent. |
457 slide_helper_.reset(new SlideHelper(this)); | 471 slide_helper_.reset(new SlideHelper(this)); |
458 | 472 |
459 // Invokes Update() in case surface is attached during a slide. | 473 // Invokes Update() in case surface is attached during a slide. |
460 slide_helper_->Update(); | 474 slide_helper_->Update(); |
461 | 475 |
462 // (Re-)create the floating buttons after |surface_| is attached to a widget. | 476 // (Re-)create the floating buttons after |surface_| is attached to a widget. |
463 MaybeCreateFloatingControlButtons(); | 477 MaybeCreateFloatingControlButtons(); |
464 } | 478 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 native_view()) != widget)) { | 524 native_view()) != widget)) { |
511 return; | 525 return; |
512 } | 526 } |
513 } | 527 } |
514 | 528 |
515 views::NativeViewHost::ViewHierarchyChanged(details); | 529 views::NativeViewHost::ViewHierarchyChanged(details); |
516 | 530 |
517 if (!widget || !surface_ || !details.is_add) | 531 if (!widget || !surface_ || !details.is_add) |
518 return; | 532 return; |
519 | 533 |
520 if (native_view()) | 534 if (surface_->IsAttached()) |
521 Detach(); | 535 surface_->Detach(); |
522 AttachSurface(); | 536 AttachSurface(); |
523 } | 537 } |
524 | 538 |
525 void ArcNotificationContentView::Layout() { | 539 void ArcNotificationContentView::Layout() { |
526 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 540 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
527 | 541 |
528 views::NativeViewHost::Layout(); | 542 views::NativeViewHost::Layout(); |
529 | 543 |
530 if (!surface_ || !GetWidget()) | 544 if (!surface_ || !GetWidget()) |
531 return; | 545 return; |
532 | 546 |
533 const gfx::Rect contents_bounds = GetContentsBounds(); | 547 const gfx::Rect contents_bounds = GetContentsBounds(); |
534 | 548 |
535 // Scale notification surface if necessary. | 549 // Scale notification surface if necessary. |
536 gfx::Transform transform; | 550 gfx::Transform transform; |
537 const gfx::Size surface_size = surface_->GetSize(); | 551 const gfx::Size surface_size = surface_->GetSize(); |
538 const gfx::Size contents_size = contents_bounds.size(); | 552 const gfx::Size contents_size = contents_bounds.size(); |
539 if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) { | 553 if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) { |
540 transform.Scale( | 554 transform.Scale( |
541 static_cast<float>(contents_size.width()) / surface_size.width(), | 555 static_cast<float>(contents_size.width()) / surface_size.width(), |
542 static_cast<float>(contents_size.height()) / surface_size.height()); | 556 static_cast<float>(contents_size.height()) / surface_size.height()); |
543 } | 557 } |
544 | 558 |
545 // Apply the transform to the surface content so that close button can | 559 // Apply the transform to the surface content so that close button can |
546 // be positioned without the need to consider the transform. | 560 // be positioned without the need to consider the transform. |
547 surface_->window()->children()[0]->SetTransform(transform); | 561 surface_->GetContentWindow()->SetTransform(transform); |
548 | 562 |
549 if (!floating_control_buttons_widget_) | 563 if (!floating_control_buttons_widget_) |
550 return; | 564 return; |
551 | 565 |
552 gfx::Rect control_buttons_bounds(contents_bounds); | 566 gfx::Rect control_buttons_bounds(contents_bounds); |
553 int buttons_width = 0; | 567 int buttons_width = 0; |
554 int buttons_height = 0; | 568 int buttons_height = 0; |
555 if (close_button_) { | 569 if (close_button_) { |
556 buttons_width += close_button_->GetPreferredSize().width(); | 570 buttons_width += close_button_->GetPreferredSize().width(); |
557 buttons_height = close_button_->GetPreferredSize().height(); | 571 buttons_height = close_button_->GetPreferredSize().height(); |
558 } | 572 } |
559 if (settings_button_) { | 573 if (settings_button_) { |
560 buttons_width += settings_button_->GetPreferredSize().width(); | 574 buttons_width += settings_button_->GetPreferredSize().width(); |
561 buttons_height = settings_button_->GetPreferredSize().height(); | 575 buttons_height = settings_button_->GetPreferredSize().height(); |
562 } | 576 } |
563 control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width - | 577 control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width - |
564 message_center::kControlButtonPadding); | 578 message_center::kControlButtonPadding); |
565 control_buttons_bounds.set_y(control_buttons_bounds.y() + | 579 control_buttons_bounds.set_y(control_buttons_bounds.y() + |
566 message_center::kControlButtonPadding); | 580 message_center::kControlButtonPadding); |
567 control_buttons_bounds.set_width(buttons_width); | 581 control_buttons_bounds.set_width(buttons_width); |
568 control_buttons_bounds.set_height(buttons_height); | 582 control_buttons_bounds.set_height(buttons_height); |
569 floating_control_buttons_widget_->SetBounds(control_buttons_bounds); | 583 floating_control_buttons_widget_->SetBounds(control_buttons_bounds); |
570 | 584 |
571 UpdateControlButtonsVisibility(); | 585 UpdateControlButtonsVisibility(); |
572 | 586 |
573 ash::wm::SnapWindowToPixelBoundary(surface_->window()); | 587 ash::wm::SnapWindowToPixelBoundary(surface_->GetWindow()); |
574 } | 588 } |
575 | 589 |
576 void ArcNotificationContentView::OnPaint(gfx::Canvas* canvas) { | 590 void ArcNotificationContentView::OnPaint(gfx::Canvas* canvas) { |
577 views::NativeViewHost::OnPaint(canvas); | 591 views::NativeViewHost::OnPaint(canvas); |
578 | 592 |
579 // Bail if there is a |surface_| or no item or no snapshot image. | 593 // Bail if there is a |surface_| or no item or no snapshot image. |
580 if (surface_ || !item_ || item_->GetSnapshot().isNull()) | 594 if (surface_ || !item_ || item_->GetSnapshot().isNull()) |
581 return; | 595 return; |
582 const gfx::Rect contents_bounds = GetContentsBounds(); | 596 const gfx::Rect contents_bounds = GetContentsBounds(); |
583 canvas->DrawImageInt(item_->GetSnapshot(), 0, 0, item_->GetSnapshot().width(), | 597 canvas->DrawImageInt(item_->GetSnapshot(), 0, 0, item_->GetSnapshot().width(), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 | 694 |
681 void ArcNotificationContentView::OnItemUpdated() { | 695 void ArcNotificationContentView::OnItemUpdated() { |
682 UpdateAccessibleName(); | 696 UpdateAccessibleName(); |
683 UpdatePinnedState(); | 697 UpdatePinnedState(); |
684 UpdateSnapshot(); | 698 UpdateSnapshot(); |
685 if (ShouldUpdateControlButtonsColor()) | 699 if (ShouldUpdateControlButtonsColor()) |
686 StartControlButtonsColorAnimation(); | 700 StartControlButtonsColorAnimation(); |
687 } | 701 } |
688 | 702 |
689 void ArcNotificationContentView::OnNotificationSurfaceAdded( | 703 void ArcNotificationContentView::OnNotificationSurfaceAdded( |
690 exo::NotificationSurface* surface) { | 704 ArcNotificationSurface* surface) { |
691 if (surface->notification_key() != notification_key_) | 705 if (surface->GetNotificationKey() != notification_key_) |
692 return; | 706 return; |
693 | 707 |
694 SetSurface(surface); | 708 SetSurface(surface); |
695 } | 709 } |
696 | 710 |
697 void ArcNotificationContentView::OnNotificationSurfaceRemoved( | 711 void ArcNotificationContentView::OnNotificationSurfaceRemoved( |
698 exo::NotificationSurface* surface) { | 712 ArcNotificationSurface* surface) { |
699 if (surface->notification_key() != notification_key_) | 713 if (surface->GetNotificationKey() != notification_key_) |
700 return; | 714 return; |
701 | 715 |
702 SetSurface(nullptr); | 716 SetSurface(nullptr); |
703 } | 717 } |
704 | 718 |
705 void ArcNotificationContentView::AnimationEnded( | 719 void ArcNotificationContentView::AnimationEnded( |
706 const gfx::Animation* animation) { | 720 const gfx::Animation* animation) { |
707 DCHECK_EQ(animation, control_button_color_animation_.get()); | 721 DCHECK_EQ(animation, control_button_color_animation_.get()); |
708 control_button_color_animation_.reset(); | 722 control_button_color_animation_.reset(); |
709 } | 723 } |
(...skipping 17 matching lines...) Expand all Loading... |
727 settings_button_->SchedulePaint(); | 741 settings_button_->SchedulePaint(); |
728 } | 742 } |
729 if (close_button_) { | 743 if (close_button_) { |
730 close_button_->SetBackground(views::CreateSolidBackground(current_color)); | 744 close_button_->SetBackground(views::CreateSolidBackground(current_color)); |
731 close_button_->SchedulePaint(); | 745 close_button_->SchedulePaint(); |
732 } | 746 } |
733 } | 747 } |
734 } | 748 } |
735 | 749 |
736 } // namespace arc | 750 } // namespace arc |
OLD | NEW |