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/shell/window_type_launcher.h" | 5 #include "ash/shell/window_type_launcher.h" |
6 | 6 |
| 7 #include "ash/screensaver/screensaver_view.h" |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
9 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
10 #include "ash/shell/example_factory.h" | 11 #include "ash/shell/example_factory.h" |
11 #include "ash/shell/panel_window.h" | 12 #include "ash/shell/panel_window.h" |
12 #include "ash/shell/toplevel_window.h" | 13 #include "ash/shell/toplevel_window.h" |
13 #include "ash/wm/shadow_types.h" | 14 #include "ash/wm/shadow_types.h" |
| 15 #include "base/bind.h" |
| 16 #include "base/time.h" |
14 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "content/public/browser/browser_thread.h" |
15 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
16 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
17 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/compositor/layer.h" | 22 #include "ui/gfx/compositor/layer.h" |
19 #include "ui/views/controls/button/text_button.h" | 23 #include "ui/views/controls/button/text_button.h" |
20 #include "ui/views/controls/menu/menu_item_view.h" | 24 #include "ui/views/controls/menu/menu_item_view.h" |
21 #include "ui/views/controls/menu/menu_runner.h" | 25 #include "ui/views/controls/menu/menu_runner.h" |
22 #include "ui/views/examples/examples_window.h" | 26 #include "ui/views/examples/examples_window.h" |
23 #include "ui/views/layout/grid_layout.h" | 27 #include "ui/views/layout/grid_layout.h" |
24 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 new views::NativeTextButton( | 213 new views::NativeTextButton( |
210 this, ASCIIToUTF16("Open Window Modal Window")))), | 214 this, ASCIIToUTF16("Open Window Modal Window")))), |
211 ALLOW_THIS_IN_INITIALIZER_LIST(transient_button_( | 215 ALLOW_THIS_IN_INITIALIZER_LIST(transient_button_( |
212 new views::NativeTextButton( | 216 new views::NativeTextButton( |
213 this, ASCIIToUTF16("Open Non-Modal Transient Window")))), | 217 this, ASCIIToUTF16("Open Non-Modal Transient Window")))), |
214 ALLOW_THIS_IN_INITIALIZER_LIST(examples_button_( | 218 ALLOW_THIS_IN_INITIALIZER_LIST(examples_button_( |
215 new views::NativeTextButton( | 219 new views::NativeTextButton( |
216 this, ASCIIToUTF16("Open Views Examples Window")))), | 220 this, ASCIIToUTF16("Open Views Examples Window")))), |
217 ALLOW_THIS_IN_INITIALIZER_LIST(show_hide_window_button_( | 221 ALLOW_THIS_IN_INITIALIZER_LIST(show_hide_window_button_( |
218 new views::NativeTextButton( | 222 new views::NativeTextButton( |
219 this, ASCIIToUTF16("Show/Hide a Window")))) { | 223 this, ASCIIToUTF16("Show/Hide a Window")))), |
| 224 ALLOW_THIS_IN_INITIALIZER_LIST(show_screensaver_( |
| 225 new views::NativeTextButton( |
| 226 this, ASCIIToUTF16("Show the Screensaver [for 5 seconds]")))) { |
220 views::GridLayout* layout = new views::GridLayout(this); | 227 views::GridLayout* layout = new views::GridLayout(this); |
221 layout->SetInsets(5, 5, 5, 5); | 228 layout->SetInsets(5, 5, 5, 5); |
222 SetLayoutManager(layout); | 229 SetLayoutManager(layout); |
223 views::ColumnSet* column_set = layout->AddColumnSet(0); | 230 views::ColumnSet* column_set = layout->AddColumnSet(0); |
224 column_set->AddColumn(views::GridLayout::LEADING, | 231 column_set->AddColumn(views::GridLayout::LEADING, |
225 views::GridLayout::CENTER, | 232 views::GridLayout::CENTER, |
226 0, | 233 0, |
227 views::GridLayout::USE_PREF, | 234 views::GridLayout::USE_PREF, |
228 0, | 235 0, |
229 0); | 236 0); |
230 AddViewToLayout(layout, create_button_); | 237 AddViewToLayout(layout, create_button_); |
231 AddViewToLayout(layout, create_persistant_button_); | 238 AddViewToLayout(layout, create_persistant_button_); |
232 AddViewToLayout(layout, panel_button_); | 239 AddViewToLayout(layout, panel_button_); |
233 AddViewToLayout(layout, create_nonresizable_button_); | 240 AddViewToLayout(layout, create_nonresizable_button_); |
234 AddViewToLayout(layout, bubble_button_); | 241 AddViewToLayout(layout, bubble_button_); |
235 AddViewToLayout(layout, lock_button_); | 242 AddViewToLayout(layout, lock_button_); |
236 AddViewToLayout(layout, widgets_button_); | 243 AddViewToLayout(layout, widgets_button_); |
237 AddViewToLayout(layout, system_modal_button_); | 244 AddViewToLayout(layout, system_modal_button_); |
238 AddViewToLayout(layout, window_modal_button_); | 245 AddViewToLayout(layout, window_modal_button_); |
239 AddViewToLayout(layout, transient_button_); | 246 AddViewToLayout(layout, transient_button_); |
240 AddViewToLayout(layout, examples_button_); | 247 AddViewToLayout(layout, examples_button_); |
241 AddViewToLayout(layout, show_hide_window_button_); | 248 AddViewToLayout(layout, show_hide_window_button_); |
| 249 AddViewToLayout(layout, show_screensaver_); |
242 #if !defined(OS_MACOSX) | 250 #if !defined(OS_MACOSX) |
243 set_context_menu_controller(this); | 251 set_context_menu_controller(this); |
244 #endif | 252 #endif |
245 } | 253 } |
246 | 254 |
247 WindowTypeLauncher::~WindowTypeLauncher() { | 255 WindowTypeLauncher::~WindowTypeLauncher() { |
248 } | 256 } |
249 | 257 |
250 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { | 258 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { |
251 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); | 259 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } else if (sender == system_modal_button_) { | 306 } else if (sender == system_modal_button_) { |
299 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), | 307 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), |
300 ui::MODAL_TYPE_SYSTEM); | 308 ui::MODAL_TYPE_SYSTEM); |
301 } else if (sender == window_modal_button_) { | 309 } else if (sender == window_modal_button_) { |
302 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), | 310 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), |
303 ui::MODAL_TYPE_WINDOW); | 311 ui::MODAL_TYPE_WINDOW); |
304 } else if (sender == transient_button_) { | 312 } else if (sender == transient_button_) { |
305 NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); | 313 NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); |
306 } else if (sender == show_hide_window_button_) { | 314 } else if (sender == show_hide_window_button_) { |
307 NonModalTransient::ToggleNonModalTransient(GetWidget()->GetNativeView()); | 315 NonModalTransient::ToggleNonModalTransient(GetWidget()->GetNativeView()); |
| 316 } else if (sender == show_screensaver_) { |
| 317 ash::ShowScreensaver(GURL("http://www.google.com")); |
| 318 content::BrowserThread::PostDelayedTask(content::BrowserThread::UI, |
| 319 FROM_HERE, |
| 320 base::Bind(&ash::CloseScreensaver), |
| 321 base::TimeDelta::FromSeconds(5)); |
| 322 |
308 } | 323 } |
309 #if !defined(OS_MACOSX) | 324 #if !defined(OS_MACOSX) |
310 else if (sender == examples_button_) { | 325 else if (sender == examples_button_) { |
311 views::examples::ShowExamplesWindow( | 326 views::examples::ShowExamplesWindow( |
312 views::examples::DO_NOTHING_ON_CLOSE, | 327 views::examples::DO_NOTHING_ON_CLOSE, |
313 ash::Shell::GetInstance()->browser_context()); | 328 ash::Shell::GetInstance()->browser_context()); |
314 } | 329 } |
315 #endif // !defined(OS_MACOSX) | 330 #endif // !defined(OS_MACOSX) |
316 } | 331 } |
317 | 332 |
(...skipping 26 matching lines...) Expand all Loading... |
344 menu_runner_.reset(new MenuRunner(root)); | 359 menu_runner_.reset(new MenuRunner(root)); |
345 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), | 360 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(point, gfx::Size()), |
346 MenuItemView::TOPLEFT, | 361 MenuItemView::TOPLEFT, |
347 MenuRunner::HAS_MNEMONICS) == MenuRunner::MENU_DELETED) | 362 MenuRunner::HAS_MNEMONICS) == MenuRunner::MENU_DELETED) |
348 return; | 363 return; |
349 } | 364 } |
350 #endif // !defined(OS_MACOSX) | 365 #endif // !defined(OS_MACOSX) |
351 | 366 |
352 } // namespace shell | 367 } // namespace shell |
353 } // namespace ash | 368 } // namespace ash |
OLD | NEW |