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

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

Issue 2739553005: Moves maintaining root_window_for_new_windows_ to Shell (Closed)
Patch Set: remove ash:: Created 3 years, 9 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
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/common/accelerators/exit_warning_handler.h" 5 #include "ash/common/accelerators/exit_warning_handler.h"
6 6
7 #include "ash/common/shell_delegate.h" 7 #include "ash/common/shell_delegate.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/shell.h"
12 #include "ash/strings/grit/ash_strings.h" 13 #include "ash/strings/grit/ash_strings.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "ui/accessibility/ax_node_data.h" 17 #include "ui/accessibility/ax_node_data.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/font_list.h" 21 #include "ui/gfx/font_list.h"
21 #include "ui/gfx/text_utils.h" 22 #include "ui/gfx/text_utils.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 &ExitWarningHandler::TimerAction); 137 &ExitWarningHandler::TimerAction);
137 } 138 }
138 139
139 void ExitWarningHandler::CancelTimer() { 140 void ExitWarningHandler::CancelTimer() {
140 timer_.Stop(); 141 timer_.Stop();
141 } 142 }
142 143
143 void ExitWarningHandler::Show() { 144 void ExitWarningHandler::Show() {
144 if (widget_) 145 if (widget_)
145 return; 146 return;
146 WmWindow* root_window = WmShell::Get()->GetRootWindowForNewWindows(); 147 WmWindow* root_window = Shell::GetWmRootWindowForNewWindows();
147 ExitWarningWidgetDelegateView* delegate = new ExitWarningWidgetDelegateView; 148 ExitWarningWidgetDelegateView* delegate = new ExitWarningWidgetDelegateView;
148 gfx::Size rs = root_window->GetBounds().size(); 149 gfx::Size rs = root_window->GetBounds().size();
149 gfx::Size ps = delegate->GetPreferredSize(); 150 gfx::Size ps = delegate->GetPreferredSize();
150 gfx::Rect bounds((rs.width() - ps.width()) / 2, 151 gfx::Rect bounds((rs.width() - ps.width()) / 2,
151 (rs.height() - ps.height()) / 3, ps.width(), ps.height()); 152 (rs.height() - ps.height()) / 3, ps.width(), ps.height());
152 views::Widget::InitParams params; 153 views::Widget::InitParams params;
153 params.type = views::Widget::InitParams::TYPE_POPUP; 154 params.type = views::Widget::InitParams::TYPE_POPUP;
154 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 155 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
155 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 156 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
156 params.accept_events = false; 157 params.accept_events = false;
157 params.keep_on_top = true; 158 params.keep_on_top = true;
158 params.remove_standard_frame = true; 159 params.remove_standard_frame = true;
159 params.delegate = delegate; 160 params.delegate = delegate;
160 params.bounds = bounds; 161 params.bounds = bounds;
161 params.name = "ExitWarningWindow"; 162 params.name = "ExitWarningWindow";
162 widget_.reset(new views::Widget); 163 widget_.reset(new views::Widget);
163 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 164 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
164 widget_.get(), kShellWindowId_SettingBubbleContainer, &params); 165 widget_.get(), kShellWindowId_SettingBubbleContainer, &params);
165 widget_->Init(params); 166 widget_->Init(params);
166 widget_->Show(); 167 widget_->Show();
167 168
168 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 169 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
169 } 170 }
170 171
171 void ExitWarningHandler::Hide() { 172 void ExitWarningHandler::Hide() {
172 widget_.reset(); 173 widget_.reset();
173 } 174 }
174 175
175 } // namespace ash 176 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/accelerators/accelerator_controller.cc ('k') | ash/common/scoped_root_window_for_new_windows.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698