OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/common/system/tray/tray_details_view.h" | 5 #include "ash/common/system/tray/tray_details_view.h" |
6 | 6 |
7 #include "ash/common/ash_view_ids.h" | 7 #include "ash/common/ash_view_ids.h" |
8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
10 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
11 #include "ash/common/system/tray/system_tray_item.h" | 11 #include "ash/common/system/tray/system_tray_item.h" |
12 #include "ash/common/system/tray/tray_constants.h" | 12 #include "ash/common/system/tray/tray_constants.h" |
13 #include "base/containers/adapters.h" | 13 #include "base/containers/adapters.h" |
| 14 #include "base/timer/timer.h" |
14 #include "third_party/skia/include/core/SkDrawLooper.h" | 15 #include "third_party/skia/include/core/SkDrawLooper.h" |
15 #include "ui/compositor/paint_context.h" | 16 #include "ui/compositor/paint_context.h" |
16 #include "ui/compositor/paint_recorder.h" | 17 #include "ui/compositor/paint_recorder.h" |
17 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/skia_util.h" | 19 #include "ui/gfx/skia_util.h" |
19 #include "ui/views/background.h" | 20 #include "ui/views/background.h" |
20 #include "ui/views/border.h" | 21 #include "ui/views/border.h" |
21 #include "ui/views/controls/progress_bar.h" | 22 #include "ui/views/controls/progress_bar.h" |
22 #include "ui/views/controls/scroll_view.h" | 23 #include "ui/views/controls/scroll_view.h" |
23 #include "ui/views/controls/separator.h" | 24 #include "ui/views/controls/separator.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 378 } |
378 | 379 |
379 void TrayDetailsView::HandleButtonPressed(views::Button* sender, | 380 void TrayDetailsView::HandleButtonPressed(views::Button* sender, |
380 const ui::Event& event) { | 381 const ui::Event& event) { |
381 NOTREACHED(); | 382 NOTREACHED(); |
382 } | 383 } |
383 | 384 |
384 void TrayDetailsView::CreateExtraTitleRowButtons() {} | 385 void TrayDetailsView::CreateExtraTitleRowButtons() {} |
385 | 386 |
386 void TrayDetailsView::TransitionToDefaultView() { | 387 void TrayDetailsView::TransitionToDefaultView() { |
| 388 if (UseMd()) { |
| 389 if (back_button_ && back_button_->HasFocus()) |
| 390 owner_->set_restore_focus(true); |
| 391 } else { |
| 392 if (title_row_ && title_row_->content() && |
| 393 title_row_->content()->HasFocus()) { |
| 394 owner_->set_restore_focus(true); |
| 395 } |
| 396 DoTransitionToDefaultView(); |
| 397 return; |
| 398 } |
| 399 |
| 400 const int transition_delay = |
| 401 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY); |
| 402 if (transition_delay <= 0) { |
| 403 DoTransitionToDefaultView(); |
| 404 return; |
| 405 } |
| 406 |
| 407 transition_delay_timer_.reset(new base::OneShotTimer()); |
| 408 transition_delay_timer_->Start( |
| 409 FROM_HERE, base::TimeDelta::FromMilliseconds(transition_delay), this, |
| 410 &TrayDetailsView::DoTransitionToDefaultView); |
| 411 } |
| 412 |
| 413 void TrayDetailsView::DoTransitionToDefaultView() { |
| 414 transition_delay_timer_.reset(); |
| 415 |
387 // Cache pointer to owner in this function scope. TrayDetailsView will be | 416 // Cache pointer to owner in this function scope. TrayDetailsView will be |
388 // deleted after called ShowDefaultView. | 417 // deleted after called ShowDefaultView. |
389 SystemTrayItem* owner = owner_; | 418 SystemTrayItem* owner = owner_; |
390 if (UseMd()) { | |
391 if (back_button_ && back_button_->HasFocus()) | |
392 owner->set_restore_focus(true); | |
393 } else { | |
394 if (title_row_ && title_row_->content() && | |
395 title_row_->content()->HasFocus()) { | |
396 owner->set_restore_focus(true); | |
397 } | |
398 } | |
399 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 419 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
400 owner->set_restore_focus(false); | 420 owner->set_restore_focus(false); |
401 } | 421 } |
402 | 422 |
403 void TrayDetailsView::Layout() { | 423 void TrayDetailsView::Layout() { |
404 if (UseMd()) { | 424 if (UseMd()) { |
405 views::View::Layout(); | 425 views::View::Layout(); |
406 if (scroller_ && !scroller_->is_bounded()) | 426 if (scroller_ && !scroller_->is_bounded()) |
407 scroller_->ClipHeightTo(0, scroller_->height()); | 427 scroller_->ClipHeightTo(0, scroller_->height()); |
408 } | 428 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 if (index < child_count() - 1 && child_at(index + 1) != title_row_) | 471 if (index < child_count() - 1 && child_at(index + 1) != title_row_) |
452 scroll_border_->set_visible(true); | 472 scroll_border_->set_visible(true); |
453 else | 473 else |
454 scroll_border_->set_visible(false); | 474 scroll_border_->set_visible(false); |
455 } | 475 } |
456 | 476 |
457 views::View::OnPaintBorder(canvas); | 477 views::View::OnPaintBorder(canvas); |
458 } | 478 } |
459 | 479 |
460 } // namespace ash | 480 } // namespace ash |
OLD | NEW |