Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: ash/accelerators/exit_warning_handler.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/accelerators/exit_warning_handler.h ('k') | ash/accelerators/key_hold_detector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/accelerators/exit_warning_handler.h" 5 #include "ash/accelerators/exit_warning_handler.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int text_width_; 91 int text_width_;
92 int width_; 92 int width_;
93 int height_; 93 int height_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(ExitWarningWidgetDelegateView); 95 DISALLOW_COPY_AND_ASSIGN(ExitWarningWidgetDelegateView);
96 }; 96 };
97 97
98 } // namespace 98 } // namespace
99 99
100 ExitWarningHandler::ExitWarningHandler() 100 ExitWarningHandler::ExitWarningHandler()
101 : state_(IDLE), 101 : state_(IDLE), stub_timer_for_test_(false) {}
102 stub_timer_for_test_(false) {
103 }
104 102
105 ExitWarningHandler::~ExitWarningHandler() { 103 ExitWarningHandler::~ExitWarningHandler() {
106 // Note: If a timer is outstanding, it is stopped in its destructor. 104 // Note: If a timer is outstanding, it is stopped in its destructor.
107 Hide(); 105 Hide();
108 } 106 }
109 107
110 void ExitWarningHandler::HandleAccelerator() { 108 void ExitWarningHandler::HandleAccelerator() {
111 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); 109 ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
112 switch (state_) { 110 switch (state_) {
113 case IDLE: 111 case IDLE:
(...skipping 20 matching lines...) Expand all
134 void ExitWarningHandler::TimerAction() { 132 void ExitWarningHandler::TimerAction() {
135 Hide(); 133 Hide();
136 if (state_ == WAIT_FOR_DOUBLE_PRESS) 134 if (state_ == WAIT_FOR_DOUBLE_PRESS)
137 state_ = IDLE; 135 state_ = IDLE;
138 } 136 }
139 137
140 void ExitWarningHandler::StartTimer() { 138 void ExitWarningHandler::StartTimer() {
141 if (stub_timer_for_test_) 139 if (stub_timer_for_test_)
142 return; 140 return;
143 timer_.Start(FROM_HERE, 141 timer_.Start(FROM_HERE,
144 base::TimeDelta::FromMilliseconds(kTimeOutMilliseconds), 142 base::TimeDelta::FromMilliseconds(kTimeOutMilliseconds), this,
145 this,
146 &ExitWarningHandler::TimerAction); 143 &ExitWarningHandler::TimerAction);
147 } 144 }
148 145
149 void ExitWarningHandler::CancelTimer() { 146 void ExitWarningHandler::CancelTimer() {
150 timer_.Stop(); 147 timer_.Stop();
151 } 148 }
152 149
153 void ExitWarningHandler::Show() { 150 void ExitWarningHandler::Show() {
154 if (widget_) 151 if (widget_)
155 return; 152 return;
156 aura::Window* root_window = Shell::GetTargetRootWindow(); 153 aura::Window* root_window = Shell::GetTargetRootWindow();
157 ExitWarningWidgetDelegateView* delegate = new ExitWarningWidgetDelegateView; 154 ExitWarningWidgetDelegateView* delegate = new ExitWarningWidgetDelegateView;
158 gfx::Size rs = root_window->bounds().size(); 155 gfx::Size rs = root_window->bounds().size();
159 gfx::Size ps = delegate->GetPreferredSize(); 156 gfx::Size ps = delegate->GetPreferredSize();
160 gfx::Rect bounds((rs.width() - ps.width()) / 2, 157 gfx::Rect bounds((rs.width() - ps.width()) / 2,
161 (rs.height() - ps.height()) / 3, 158 (rs.height() - ps.height()) / 3, ps.width(), ps.height());
162 ps.width(), ps.height());
163 views::Widget::InitParams params; 159 views::Widget::InitParams params;
164 params.type = views::Widget::InitParams::TYPE_POPUP; 160 params.type = views::Widget::InitParams::TYPE_POPUP;
165 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 161 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
166 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 162 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
167 params.accept_events = false; 163 params.accept_events = false;
168 params.keep_on_top = true; 164 params.keep_on_top = true;
169 params.remove_standard_frame = true; 165 params.remove_standard_frame = true;
170 params.delegate = delegate; 166 params.delegate = delegate;
171 params.bounds = bounds; 167 params.bounds = bounds;
172 params.parent = 168 params.parent =
173 Shell::GetContainer(root_window, kShellWindowId_SettingBubbleContainer); 169 Shell::GetContainer(root_window, kShellWindowId_SettingBubbleContainer);
174 widget_.reset(new views::Widget); 170 widget_.reset(new views::Widget);
175 widget_->Init(params); 171 widget_->Init(params);
176 widget_->SetContentsView(delegate); 172 widget_->SetContentsView(delegate);
177 widget_->GetNativeView()->SetName("ExitWarningWindow"); 173 widget_->GetNativeView()->SetName("ExitWarningWindow");
178 widget_->Show(); 174 widget_->Show();
179 175
180 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 176 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
181 } 177 }
182 178
183 void ExitWarningHandler::Hide() { 179 void ExitWarningHandler::Hide() {
184 widget_.reset(); 180 widget_.reset();
185 } 181 }
186 182
187 } // namespace ash 183 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/exit_warning_handler.h ('k') | ash/accelerators/key_hold_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698