| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/power/idle_action_warning_dialog_view.h" | 5 #include "chrome/browser/chromeos/power/idle_action_warning_dialog_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/ui/browser_dialogs.h" |
| 12 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/l10n/time_format.h" | 16 #include "ui/base/l10n/time_format.h" |
| 16 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 17 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 18 #include "ui/gfx/text_constants.h" | 19 #include "ui/gfx/text_constants.h" |
| 19 #include "ui/views/border.h" | 20 #include "ui/views/border.h" |
| 20 #include "ui/views/controls/label.h" | 21 #include "ui/views/controls/label.h" |
| 21 #include "ui/views/layout/fill_layout.h" | 22 #include "ui/views/layout/fill_layout.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 UpdateLabel(); | 73 UpdateLabel(); |
| 73 | 74 |
| 74 views::DialogDelegate::CreateDialogWidget( | 75 views::DialogDelegate::CreateDialogWidget( |
| 75 this, ash::Shell::GetPrimaryRootWindow(), NULL)->Show(); | 76 this, ash::Shell::GetPrimaryRootWindow(), NULL)->Show(); |
| 76 | 77 |
| 77 update_timer_.Start( | 78 update_timer_.Start( |
| 78 FROM_HERE, | 79 FROM_HERE, |
| 79 base::TimeDelta::FromMilliseconds(kCountdownUpdateIntervalMs), | 80 base::TimeDelta::FromMilliseconds(kCountdownUpdateIntervalMs), |
| 80 this, | 81 this, |
| 81 &IdleActionWarningDialogView::UpdateLabel); | 82 &IdleActionWarningDialogView::UpdateLabel); |
| 83 chrome::RecordDialogCreation(chrome::DialogIdentifier::IDLE_ACTION_WARNING); |
| 82 } | 84 } |
| 83 | 85 |
| 84 void IdleActionWarningDialogView::CloseDialog() { | 86 void IdleActionWarningDialogView::CloseDialog() { |
| 85 update_timer_.Stop(); | 87 update_timer_.Stop(); |
| 86 GetDialogClientView()->CancelWindow(); | 88 GetDialogClientView()->CancelWindow(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 void IdleActionWarningDialogView::Update(base::TimeTicks idle_action_time) { | 91 void IdleActionWarningDialogView::Update(base::TimeTicks idle_action_time) { |
| 90 idle_action_time_ = idle_action_time; | 92 idle_action_time_ = idle_action_time; |
| 91 UpdateLabel(); | 93 UpdateLabel(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 116 base::TimeDelta()); | 118 base::TimeDelta()); |
| 117 label_->SetText(l10n_util::GetStringFUTF16( | 119 label_->SetText(l10n_util::GetStringFUTF16( |
| 118 IDS_IDLE_WARNING_LOGOUT_WARNING, | 120 IDS_IDLE_WARNING_LOGOUT_WARNING, |
| 119 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, | 121 ui::TimeFormat::Detailed(ui::TimeFormat::FORMAT_DURATION, |
| 120 ui::TimeFormat::LENGTH_LONG, | 122 ui::TimeFormat::LENGTH_LONG, |
| 121 10, | 123 10, |
| 122 time_until_idle_action))); | 124 time_until_idle_action))); |
| 123 } | 125 } |
| 124 | 126 |
| 125 } // namespace chromeos | 127 } // namespace chromeos |
| OLD | NEW |