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_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" | |
13 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/compositor/layer_animation_observer.h" | 14 #include "ui/compositor/layer_animation_observer.h" |
16 #include "ui/display/screen.h" | |
17 #include "ui/events/event_handler.h" | 15 #include "ui/events/event_handler.h" |
18 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/image/image_skia.h" | |
20 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
21 #include "ui/message_center/message_center_style.h" | 18 #include "ui/message_center/message_center_style.h" |
22 #include "ui/message_center/views/custom_notification_view.h" | 19 #include "ui/message_center/views/custom_notification_view.h" |
23 #include "ui/message_center/views/padded_button.h" | |
24 #include "ui/message_center/views/toast_contents_view.h" | 20 #include "ui/message_center/views/toast_contents_view.h" |
25 #include "ui/resources/grit/ui_resources.h" | |
26 #include "ui/strings/grit/ui_strings.h" | 21 #include "ui/strings/grit/ui_strings.h" |
27 #include "ui/views/background.h" | |
28 #include "ui/views/border.h" | |
29 #include "ui/views/controls/button/image_button.h" | |
30 #include "ui/views/focus/focus_manager.h" | 22 #include "ui/views/focus/focus_manager.h" |
31 #include "ui/views/layout/box_layout.h" | 23 #include "ui/views/layout/box_layout.h" |
32 #include "ui/views/painter.h" | 24 #include "ui/views/painter.h" |
33 #include "ui/views/widget/root_view.h" | 25 #include "ui/views/widget/root_view.h" |
34 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
35 #include "ui/wm/core/window_util.h" | 27 #include "ui/wm/core/window_util.h" |
36 | 28 |
37 namespace arc { | 29 namespace arc { |
38 | 30 |
39 class ArcCustomNotificationView::EventForwarder : public ui::EventHandler { | 31 class ArcCustomNotificationView::EventForwarder : public ui::EventHandler { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 143 } |
152 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} | 144 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} |
153 | 145 |
154 ArcCustomNotificationView* const owner_; | 146 ArcCustomNotificationView* const owner_; |
155 bool sliding_ = false; | 147 bool sliding_ = false; |
156 std::unique_ptr<ui::LayerTreeOwner> surface_copy_; | 148 std::unique_ptr<ui::LayerTreeOwner> surface_copy_; |
157 | 149 |
158 DISALLOW_COPY_AND_ASSIGN(SlideHelper); | 150 DISALLOW_COPY_AND_ASSIGN(SlideHelper); |
159 }; | 151 }; |
160 | 152 |
161 class ArcCustomNotificationView::ControlButton | |
162 : public message_center::PaddedButton { | |
163 public: | |
164 explicit ControlButton(ArcCustomNotificationView* owner) | |
165 : message_center::PaddedButton(owner), owner_(owner) {} | |
166 | |
167 void OnFocus() override { | |
168 message_center::PaddedButton::OnFocus(); | |
169 owner_->UpdateControlButtonsVisibility(); | |
170 } | |
171 | |
172 void OnBlur() override { | |
173 message_center::PaddedButton::OnBlur(); | |
174 owner_->UpdateControlButtonsVisibility(); | |
175 } | |
176 | |
177 void HideInkDrop() { AnimateInkDrop(views::InkDropState::HIDDEN, nullptr); } | |
178 | |
179 private: | |
180 ArcCustomNotificationView* const owner_; | |
181 | |
182 DISALLOW_COPY_AND_ASSIGN(ControlButton); | |
183 }; | |
184 | |
185 class ArcCustomNotificationView::ContentViewDelegate | 153 class ArcCustomNotificationView::ContentViewDelegate |
186 : public message_center::CustomNotificationContentViewDelegate { | 154 : public message_center::CustomNotificationContentViewDelegate { |
187 public: | 155 public: |
188 explicit ContentViewDelegate(ArcCustomNotificationView* owner) | 156 explicit ContentViewDelegate(ArcCustomNotificationView* owner) |
189 : owner_(owner) {} | 157 : owner_(owner) {} |
190 | 158 |
191 bool IsCloseButtonFocused() const override { | 159 bool IsCloseButtonFocused() const override { |
192 if (owner_->close_button_ == nullptr) | 160 if (!owner_->close_button_) |
193 return false; | 161 return false; |
194 return owner_->close_button_->HasFocus(); | 162 return owner_->close_button_->HasFocus(); |
195 } | 163 } |
196 | 164 |
197 void RequestFocusOnCloseButton() override { | 165 void RequestFocusOnCloseButton() override { |
198 if (owner_->close_button_) | 166 if (owner_->close_button_) |
199 owner_->close_button_->RequestFocus(); | 167 owner_->close_button_->RequestFocus(); |
200 owner_->UpdateControlButtonsVisibility(); | 168 owner_->UpdateControlButtonsVisibility(); |
201 } | 169 } |
202 | 170 |
203 bool IsPinned() const override { | 171 bool IsPinned() const override { |
204 return owner_->item_->pinned(); | 172 return owner_->item_->pinned(); |
205 } | 173 } |
206 | 174 |
207 void UpdateControlButtonsVisibility() override { | 175 void UpdateControlButtonsVisibility() override { |
208 owner_->UpdateControlButtonsVisibility(); | 176 owner_->UpdateControlButtonsVisibility(); |
209 } | 177 } |
210 | 178 |
211 private: | 179 private: |
212 ArcCustomNotificationView* const owner_; | 180 ArcCustomNotificationView* const owner_; |
213 | 181 |
214 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); | 182 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); |
215 }; | 183 }; |
216 | 184 |
| 185 ArcCustomNotificationView::ControlButton::ControlButton( |
| 186 ArcCustomNotificationView* owner) |
| 187 : message_center::PaddedButton(owner), owner_(owner) {} |
| 188 |
| 189 void ArcCustomNotificationView::ControlButton::OnFocus() { |
| 190 message_center::PaddedButton::OnFocus(); |
| 191 owner_->UpdateControlButtonsVisibility(); |
| 192 } |
| 193 |
| 194 void ArcCustomNotificationView::ControlButton::OnBlur() { |
| 195 message_center::PaddedButton::OnBlur(); |
| 196 owner_->UpdateControlButtonsVisibility(); |
| 197 } |
| 198 |
217 ArcCustomNotificationView::ArcCustomNotificationView( | 199 ArcCustomNotificationView::ArcCustomNotificationView( |
218 ArcCustomNotificationItem* item) | 200 ArcCustomNotificationItem* item) |
219 : item_(item), | 201 : item_(item), |
220 notification_key_(item->notification_key()), | 202 notification_key_(item->notification_key()), |
221 event_forwarder_(new EventForwarder(this)) { | 203 event_forwarder_(new EventForwarder(this)) { |
222 SetFocusBehavior(FocusBehavior::ALWAYS); | 204 SetFocusBehavior(FocusBehavior::ALWAYS); |
223 | 205 |
224 item_->IncrementWindowRefCount(); | 206 item_->IncrementWindowRefCount(); |
225 item_->AddObserver(this); | 207 item_->AddObserver(this); |
226 | 208 |
(...skipping 17 matching lines...) Expand all Loading... |
244 | 226 |
245 if (ArcNotificationSurfaceManager::Get()) | 227 if (ArcNotificationSurfaceManager::Get()) |
246 ArcNotificationSurfaceManager::Get()->RemoveObserver(this); | 228 ArcNotificationSurfaceManager::Get()->RemoveObserver(this); |
247 } | 229 } |
248 | 230 |
249 std::unique_ptr<message_center::CustomNotificationContentViewDelegate> | 231 std::unique_ptr<message_center::CustomNotificationContentViewDelegate> |
250 ArcCustomNotificationView::CreateContentViewDelegate() { | 232 ArcCustomNotificationView::CreateContentViewDelegate() { |
251 return base::MakeUnique<ArcCustomNotificationView::ContentViewDelegate>(this); | 233 return base::MakeUnique<ArcCustomNotificationView::ContentViewDelegate>(this); |
252 } | 234 } |
253 | 235 |
| 236 void ArcCustomNotificationView::CreateCloseButton() { |
| 237 DCHECK(control_buttons_view_); |
| 238 |
| 239 close_button_ = base::MakeUnique<ControlButton>(this); |
| 240 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
| 241 message_center::GetCloseIcon()); |
| 242 close_button_->SetAccessibleName(l10n_util::GetStringUTF16( |
| 243 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); |
| 244 close_button_->SetTooltipText(l10n_util::GetStringUTF16( |
| 245 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP)); |
| 246 close_button_->set_owned_by_client(); |
| 247 control_buttons_view_->AddChildView(close_button_.get()); |
| 248 } |
| 249 |
254 void ArcCustomNotificationView::CreateFloatingControlButtons() { | 250 void ArcCustomNotificationView::CreateFloatingControlButtons() { |
255 // Floating close button is a transient child of |surface_| and also part | 251 // Floating close button is a transient child of |surface_| and also part |
256 // of the hosting widget's focus chain. It could only be created when both | 252 // of the hosting widget's focus chain. It could only be created when both |
257 // are present. | 253 // are present. |
258 if (!surface_ || !GetWidget()) | 254 if (!surface_ || !GetWidget()) |
259 return; | 255 return; |
260 | 256 |
261 // Creates the control_buttons_view_, which collects all control buttons into | 257 // Creates the control_buttons_view_, which collects all control buttons into |
262 // a horizontal box. | 258 // a horizontal box. |
263 control_buttons_view_ = new views::View(); | 259 control_buttons_view_ = new views::View(); |
264 control_buttons_view_->SetLayoutManager( | 260 control_buttons_view_->SetLayoutManager( |
265 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 261 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
266 | 262 |
267 settings_button_ = new ControlButton(this); | 263 settings_button_ = new ControlButton(this); |
268 settings_button_->SetImage(views::CustomButton::STATE_NORMAL, | 264 settings_button_->SetImage(views::CustomButton::STATE_NORMAL, |
269 message_center::GetSettingsIcon()); | 265 message_center::GetSettingsIcon()); |
270 settings_button_->SetAccessibleName(l10n_util::GetStringUTF16( | 266 settings_button_->SetAccessibleName(l10n_util::GetStringUTF16( |
271 IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); | 267 IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); |
272 settings_button_->SetTooltipText(l10n_util::GetStringUTF16( | 268 settings_button_->SetTooltipText(l10n_util::GetStringUTF16( |
273 IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); | 269 IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); |
274 control_buttons_view_->AddChildView(settings_button_); | 270 control_buttons_view_->AddChildView(settings_button_); |
275 | 271 |
276 close_button_ = new ControlButton(this); | 272 CreateCloseButton(); |
277 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | |
278 message_center::GetCloseIcon()); | |
279 close_button_->SetAccessibleName(l10n_util::GetStringUTF16( | |
280 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); | |
281 close_button_->SetTooltipText(l10n_util::GetStringUTF16( | |
282 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP)); | |
283 control_buttons_view_->AddChildView(close_button_); | |
284 | 273 |
285 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 274 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
286 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 275 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
287 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 276 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
288 params.parent = surface_->window(); | 277 params.parent = surface_->window(); |
289 | 278 |
290 floating_control_buttons_widget_.reset(new views::Widget); | 279 floating_control_buttons_widget_.reset(new views::Widget); |
291 floating_control_buttons_widget_->Init(params); | 280 floating_control_buttons_widget_->Init(params); |
292 floating_control_buttons_widget_->SetContentsView(control_buttons_view_); | 281 floating_control_buttons_widget_->SetContentsView(control_buttons_view_); |
293 | 282 |
294 // Put the close button into the focus chain. | 283 // Put the close button into the focus chain. |
295 floating_control_buttons_widget_->SetFocusTraversableParent( | 284 floating_control_buttons_widget_->SetFocusTraversableParent( |
296 GetWidget()->GetFocusTraversable()); | 285 GetWidget()->GetFocusTraversable()); |
297 floating_control_buttons_widget_->SetFocusTraversableParentView(this); | 286 floating_control_buttons_widget_->SetFocusTraversableParentView(this); |
298 | 287 |
299 Layout(); | 288 Layout(); |
300 } | 289 } |
301 | 290 |
302 void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) { | 291 void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) { |
303 if (surface_ == surface) | 292 if (surface_ == surface) |
304 return; | 293 return; |
305 | 294 |
306 // Reset |floating_control_buttons_widget_| when |surface_| is changed. | 295 // Reset |floating_control_buttons_widget_| when |surface_| is changed. |
307 floating_control_buttons_widget_.reset(); | 296 floating_control_buttons_widget_.reset(); |
| 297 control_buttons_view_ = nullptr; |
| 298 settings_button_ = nullptr; |
| 299 close_button_.reset(); |
308 | 300 |
309 if (surface_ && surface_->window()) { | 301 if (surface_ && surface_->window()) { |
310 surface_->window()->RemoveObserver(this); | 302 surface_->window()->RemoveObserver(this); |
311 surface_->window()->RemovePreTargetHandler(event_forwarder_.get()); | 303 surface_->window()->RemovePreTargetHandler(event_forwarder_.get()); |
312 } | 304 } |
313 | 305 |
314 surface_ = surface; | 306 surface_ = surface; |
315 | 307 |
316 if (surface_ && surface_->window()) { | 308 if (surface_ && surface_->window()) { |
317 surface_->window()->AddObserver(this); | 309 surface_->window()->AddObserver(this); |
318 surface_->window()->AddPreTargetHandler(event_forwarder_.get()); | 310 surface_->window()->AddPreTargetHandler(event_forwarder_.get()); |
319 | 311 |
| 312 CreateFloatingControlButtons(); |
| 313 |
320 if (GetWidget()) | 314 if (GetWidget()) |
321 AttachSurface(); | 315 AttachSurface(); |
322 } | 316 } |
323 } | 317 } |
324 | 318 |
325 void ArcCustomNotificationView::UpdatePreferredSize() { | 319 void ArcCustomNotificationView::UpdatePreferredSize() { |
326 gfx::Size preferred_size = | 320 gfx::Size preferred_size = |
327 surface_ ? surface_->GetSize() : item_ ? item_->snapshot().size() | 321 surface_ ? surface_->GetSize() : item_ ? item_->snapshot().size() |
328 : gfx::Size(); | 322 : gfx::Size(); |
329 if (preferred_size.IsEmpty()) | 323 if (preferred_size.IsEmpty()) |
330 return; | 324 return; |
331 | 325 |
332 if (preferred_size.width() != message_center::kNotificationWidth) { | 326 if (preferred_size.width() != message_center::kNotificationWidth) { |
333 const float scale = static_cast<float>(message_center::kNotificationWidth) / | 327 const float scale = static_cast<float>(message_center::kNotificationWidth) / |
334 preferred_size.width(); | 328 preferred_size.width(); |
335 preferred_size.SetSize(message_center::kNotificationWidth, | 329 preferred_size.SetSize(message_center::kNotificationWidth, |
336 preferred_size.height() * scale); | 330 preferred_size.height() * scale); |
337 } | 331 } |
338 | 332 |
339 SetPreferredSize(preferred_size); | 333 SetPreferredSize(preferred_size); |
340 } | 334 } |
341 | 335 |
342 void ArcCustomNotificationView::UpdateControlButtonsVisibility() { | 336 void ArcCustomNotificationView::UpdateControlButtonsVisibility() { |
343 if (!surface_ || !floating_control_buttons_widget_) | 337 if (!surface_ || !floating_control_buttons_widget_) |
344 return; | 338 return; |
345 | 339 |
346 const bool target_visiblity = | 340 const bool target_visiblity = IsMouseHovered() || |
347 surface_->window()->GetBoundsInScreen().Contains( | 341 (close_button_ && close_button_->HasFocus()) || |
348 display::Screen::GetScreen()->GetCursorScreenPoint()) || | 342 settings_button_->HasFocus(); |
349 close_button_->HasFocus() || settings_button_->HasFocus(); | |
350 if (target_visiblity == floating_control_buttons_widget_->IsVisible()) | 343 if (target_visiblity == floating_control_buttons_widget_->IsVisible()) |
351 return; | 344 return; |
352 | 345 |
353 if (target_visiblity) | 346 if (target_visiblity) |
354 floating_control_buttons_widget_->Show(); | 347 floating_control_buttons_widget_->Show(); |
355 else | 348 else |
356 floating_control_buttons_widget_->Hide(); | 349 floating_control_buttons_widget_->Hide(); |
357 } | 350 } |
358 | 351 |
359 void ArcCustomNotificationView::UpdatePinnedState() { | 352 void ArcCustomNotificationView::UpdatePinnedState() { |
360 DCHECK(item_); | 353 DCHECK(item_); |
361 | 354 |
362 if (item_->pinned() && floating_control_buttons_widget_) { | 355 if (item_->pinned() && close_button_) { |
363 floating_control_buttons_widget_.reset(); | 356 control_buttons_view_->RemoveChildView(close_button_.get()); |
364 } else if (!item_->pinned() && !floating_control_buttons_widget_) { | 357 close_button_.reset(); |
365 CreateFloatingControlButtons(); | 358 Layout(); |
| 359 } else if (!item_->pinned() && !close_button_) { |
| 360 CreateCloseButton(); |
| 361 Layout(); |
366 } | 362 } |
367 } | 363 } |
368 | 364 |
369 void ArcCustomNotificationView::UpdateSnapshot() { | 365 void ArcCustomNotificationView::UpdateSnapshot() { |
370 // Bail if we have a |surface_| because it controls the sizes and paints UI. | 366 // Bail if we have a |surface_| because it controls the sizes and paints UI. |
371 if (surface_) | 367 if (surface_) |
372 return; | 368 return; |
373 | 369 |
374 UpdatePreferredSize(); | 370 UpdatePreferredSize(); |
375 SchedulePaint(); | 371 SchedulePaint(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 } | 441 } |
446 | 442 |
447 // Apply the transform to the surface content so that close button can | 443 // Apply the transform to the surface content so that close button can |
448 // be positioned without the need to consider the transform. | 444 // be positioned without the need to consider the transform. |
449 surface_->window()->children()[0]->SetTransform(transform); | 445 surface_->window()->children()[0]->SetTransform(transform); |
450 | 446 |
451 if (!floating_control_buttons_widget_) | 447 if (!floating_control_buttons_widget_) |
452 return; | 448 return; |
453 | 449 |
454 gfx::Rect control_buttons_bounds(contents_bounds); | 450 gfx::Rect control_buttons_bounds(contents_bounds); |
455 const int buttons_width = close_button_->GetPreferredSize().width() + | 451 int buttons_width = 0; |
456 settings_button_->GetPreferredSize().width(); | 452 if (close_button_) |
| 453 buttons_width += close_button_->GetPreferredSize().width(); |
| 454 if (settings_button_) |
| 455 buttons_width += settings_button_->GetPreferredSize().width(); |
457 control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width - | 456 control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width - |
458 message_center::kControlButtonPadding); | 457 message_center::kControlButtonPadding); |
459 control_buttons_bounds.set_y(control_buttons_bounds.y() + | 458 control_buttons_bounds.set_y(control_buttons_bounds.y() + |
460 message_center::kControlButtonPadding); | 459 message_center::kControlButtonPadding); |
461 control_buttons_bounds.set_height(close_button_->GetPreferredSize().height()); | 460 control_buttons_bounds.set_height( |
| 461 settings_button_->GetPreferredSize().height()); |
462 control_buttons_bounds.set_width(buttons_width); | 462 control_buttons_bounds.set_width(buttons_width); |
463 floating_control_buttons_widget_->SetBounds(control_buttons_bounds); | 463 floating_control_buttons_widget_->SetBounds(control_buttons_bounds); |
464 | 464 |
465 UpdateControlButtonsVisibility(); | 465 UpdateControlButtonsVisibility(); |
466 | 466 |
467 ash::wm::SnapWindowToPixelBoundary(surface_->window()); | 467 ash::wm::SnapWindowToPixelBoundary(surface_->window()); |
468 } | 468 } |
469 | 469 |
470 void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) { | 470 void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) { |
471 views::NativeViewHost::OnPaint(canvas); | 471 views::NativeViewHost::OnPaint(canvas); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 530 |
531 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { | 531 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { |
532 if (floating_control_buttons_widget_) | 532 if (floating_control_buttons_widget_) |
533 return static_cast<views::internal::RootView*>( | 533 return static_cast<views::internal::RootView*>( |
534 floating_control_buttons_widget_->GetRootView()); | 534 floating_control_buttons_widget_->GetRootView()); |
535 return nullptr; | 535 return nullptr; |
536 } | 536 } |
537 | 537 |
538 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, | 538 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, |
539 const ui::Event& event) { | 539 const ui::Event& event) { |
540 if (item_ && !item_->pinned() && sender == close_button_) { | 540 if (item_ && !item_->pinned() && sender == close_button_.get()) { |
541 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, | 541 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, |
542 parent()->GetClassName()); | 542 parent()->GetClassName()); |
543 static_cast<message_center::CustomNotificationView*>(parent()) | 543 static_cast<message_center::CustomNotificationView*>(parent()) |
544 ->OnCloseButtonPressed(); | 544 ->OnCloseButtonPressed(); |
545 } | 545 } |
546 if (item_ && settings_button_ && sender == settings_button_) { | 546 if (item_ && settings_button_ && sender == settings_button_) { |
547 settings_button_->HideInkDrop(); | |
548 item_->OpenSettings(); | 547 item_->OpenSettings(); |
549 } | 548 } |
550 } | 549 } |
551 | 550 |
552 void ArcCustomNotificationView::OnWindowBoundsChanged( | 551 void ArcCustomNotificationView::OnWindowBoundsChanged( |
553 aura::Window* window, | 552 aura::Window* window, |
554 const gfx::Rect& old_bounds, | 553 const gfx::Rect& old_bounds, |
555 const gfx::Rect& new_bounds) { | 554 const gfx::Rect& new_bounds) { |
556 if (in_layout_) | 555 if (in_layout_) |
557 return; | 556 return; |
(...skipping 30 matching lines...) Expand all Loading... |
588 | 587 |
589 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( | 588 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( |
590 exo::NotificationSurface* surface) { | 589 exo::NotificationSurface* surface) { |
591 if (surface->notification_id() != notification_key_) | 590 if (surface->notification_id() != notification_key_) |
592 return; | 591 return; |
593 | 592 |
594 SetSurface(nullptr); | 593 SetSurface(nullptr); |
595 } | 594 } |
596 | 595 |
597 } // namespace arc | 596 } // namespace arc |
OLD | NEW |