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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 393 } |
393 | 394 |
394 void TrayDetailsView::HandleButtonPressed(views::Button* sender, | 395 void TrayDetailsView::HandleButtonPressed(views::Button* sender, |
395 const ui::Event& event) { | 396 const ui::Event& event) { |
396 NOTREACHED(); | 397 NOTREACHED(); |
397 } | 398 } |
398 | 399 |
399 void TrayDetailsView::CreateExtraTitleRowButtons() {} | 400 void TrayDetailsView::CreateExtraTitleRowButtons() {} |
400 | 401 |
401 void TrayDetailsView::TransitionToDefaultView() { | 402 void TrayDetailsView::TransitionToDefaultView() { |
| 403 if (UseMd()) { |
| 404 if (back_button_ && back_button_->HasFocus()) |
| 405 owner_->set_restore_focus(true); |
| 406 } else { |
| 407 if (title_row_ && title_row_->content() && |
| 408 title_row_->content()->HasFocus()) { |
| 409 owner_->set_restore_focus(true); |
| 410 } |
| 411 DoTransitionToDefaultView(); |
| 412 return; |
| 413 } |
| 414 |
| 415 const int transition_delay = |
| 416 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY); |
| 417 if (transition_delay <= 0) { |
| 418 DoTransitionToDefaultView(); |
| 419 return; |
| 420 } |
| 421 |
| 422 transition_delay_timer_.reset(new base::OneShotTimer()); |
| 423 transition_delay_timer_->Start( |
| 424 FROM_HERE, base::TimeDelta::FromMilliseconds(transition_delay), this, |
| 425 &TrayDetailsView::DoTransitionToDefaultView); |
| 426 } |
| 427 |
| 428 void TrayDetailsView::DoTransitionToDefaultView() { |
| 429 transition_delay_timer_.reset(); |
| 430 |
402 // Cache pointer to owner in this function scope. TrayDetailsView will be | 431 // Cache pointer to owner in this function scope. TrayDetailsView will be |
403 // deleted after called ShowDefaultView. | 432 // deleted after called ShowDefaultView. |
404 SystemTrayItem* owner = owner_; | 433 SystemTrayItem* owner = owner_; |
405 if (UseMd()) { | |
406 if (back_button_ && back_button_->HasFocus()) | |
407 owner->set_restore_focus(true); | |
408 } else { | |
409 if (title_row_ && title_row_->content() && | |
410 title_row_->content()->HasFocus()) { | |
411 owner->set_restore_focus(true); | |
412 } | |
413 } | |
414 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 434 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
415 owner->set_restore_focus(false); | 435 owner->set_restore_focus(false); |
416 } | 436 } |
417 | 437 |
418 void TrayDetailsView::Layout() { | 438 void TrayDetailsView::Layout() { |
419 if (UseMd()) { | 439 if (UseMd()) { |
420 views::View::Layout(); | 440 views::View::Layout(); |
421 if (scroller_ && !scroller_->is_bounded()) | 441 if (scroller_ && !scroller_->is_bounded()) |
422 scroller_->ClipHeightTo(0, scroller_->height()); | 442 scroller_->ClipHeightTo(0, scroller_->height()); |
423 } | 443 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 if (index < child_count() - 1 && child_at(index + 1) != title_row_) | 486 if (index < child_count() - 1 && child_at(index + 1) != title_row_) |
467 scroll_border_->set_visible(true); | 487 scroll_border_->set_visible(true); |
468 else | 488 else |
469 scroll_border_->set_visible(false); | 489 scroll_border_->set_visible(false); |
470 } | 490 } |
471 | 491 |
472 views::View::OnPaintBorder(canvas); | 492 views::View::OnPaintBorder(canvas); |
473 } | 493 } |
474 | 494 |
475 } // namespace ash | 495 } // namespace ash |
OLD | NEW |