Chromium Code Reviews| 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/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/screensaver/screensaver_view.h" | |
| 9 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
| 11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 12 #include "ash/shell/example_factory.h" | 11 #include "ash/shell/example_factory.h" |
| 13 #include "ash/shell/panel_window.h" | 12 #include "ash/shell/panel_window.h" |
| 14 #include "ash/shell/toplevel_window.h" | 13 #include "ash/shell/toplevel_window.h" |
| 15 #include "ash/shell_delegate.h" | 14 #include "ash/shell_delegate.h" |
| 16 #include "ash/shell_window_ids.h" | 15 #include "ash/shell_window_ids.h" |
| 17 #include "ash/system/status_area_widget.h" | 16 #include "ash/system/status_area_widget.h" |
| 18 #include "ash/system/web_notification/web_notification_tray.h" | 17 #include "ash/system/web_notification/web_notification_tray.h" |
| 19 #include "ash/test/child_modal_window.h" | 18 #include "ash/test/child_modal_window.h" |
| 20 #include "base/bind.h" | 19 #include "base/bind.h" |
|
bartfab (slow)
2014/10/15 09:52:19
Nit: No longer used.
rkc
2014/11/20 21:06:33
Done.
| |
| 21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/time/time.h" | 21 #include "base/time/time.h" |
|
bartfab (slow)
2014/10/15 09:52:19
Nit: No longer used.
rkc
2014/11/20 21:06:33
Done.
| |
| 23 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
|
bartfab (slow)
2014/10/15 09:52:19
Nit: No longer used.
rkc
2014/11/20 21:06:33
Done.
| |
| 24 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 25 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
| 26 #include "ui/compositor/layer.h" | 25 #include "ui/compositor/layer.h" |
| 27 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 28 #include "ui/message_center/message_center.h" | 27 #include "ui/message_center/message_center.h" |
| 29 #include "ui/message_center/notification_types.h" | 28 #include "ui/message_center/notification_types.h" |
| 30 #include "ui/views/controls/button/label_button.h" | 29 #include "ui/views/controls/button/label_button.h" |
| 31 #include "ui/views/controls/menu/menu_item_view.h" | 30 #include "ui/views/controls/menu/menu_item_view.h" |
| 32 #include "ui/views/controls/menu/menu_runner.h" | 31 #include "ui/views/controls/menu/menu_runner.h" |
| 33 #include "ui/views/examples/examples_window_with_content.h" | 32 #include "ui/views/examples/examples_window_with_content.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 window_modal_button_(new views::LabelButton( | 217 window_modal_button_(new views::LabelButton( |
| 219 this, base::ASCIIToUTF16("Open Window Modal Window"))), | 218 this, base::ASCIIToUTF16("Open Window Modal Window"))), |
| 220 child_modal_button_(new views::LabelButton( | 219 child_modal_button_(new views::LabelButton( |
| 221 this, base::ASCIIToUTF16("Open Child Modal Window"))), | 220 this, base::ASCIIToUTF16("Open Child Modal Window"))), |
| 222 transient_button_(new views::LabelButton( | 221 transient_button_(new views::LabelButton( |
| 223 this, base::ASCIIToUTF16("Open Non-Modal Transient Window"))), | 222 this, base::ASCIIToUTF16("Open Non-Modal Transient Window"))), |
| 224 examples_button_(new views::LabelButton( | 223 examples_button_(new views::LabelButton( |
| 225 this, base::ASCIIToUTF16("Open Views Examples Window"))), | 224 this, base::ASCIIToUTF16("Open Views Examples Window"))), |
| 226 show_hide_window_button_(new views::LabelButton( | 225 show_hide_window_button_(new views::LabelButton( |
| 227 this, base::ASCIIToUTF16("Show/Hide a Window"))), | 226 this, base::ASCIIToUTF16("Show/Hide a Window"))), |
| 228 show_screensaver_(new views::LabelButton( | |
| 229 this, base::ASCIIToUTF16("Show the Screensaver [for 5 seconds]"))), | |
| 230 show_web_notification_(new views::LabelButton( | 227 show_web_notification_(new views::LabelButton( |
| 231 this, base::ASCIIToUTF16("Show a web/app notification"))) { | 228 this, base::ASCIIToUTF16("Show a web/app notification"))) { |
| 232 create_button_->SetStyle(views::Button::STYLE_BUTTON); | 229 create_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 233 panel_button_->SetStyle(views::Button::STYLE_BUTTON); | 230 panel_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 234 create_nonresizable_button_->SetStyle(views::Button::STYLE_BUTTON); | 231 create_nonresizable_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 235 bubble_button_->SetStyle(views::Button::STYLE_BUTTON); | 232 bubble_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 236 lock_button_->SetStyle(views::Button::STYLE_BUTTON); | 233 lock_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 237 widgets_button_->SetStyle(views::Button::STYLE_BUTTON); | 234 widgets_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 238 system_modal_button_->SetStyle(views::Button::STYLE_BUTTON); | 235 system_modal_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 239 window_modal_button_->SetStyle(views::Button::STYLE_BUTTON); | 236 window_modal_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 240 child_modal_button_->SetStyle(views::Button::STYLE_BUTTON); | 237 child_modal_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 241 transient_button_->SetStyle(views::Button::STYLE_BUTTON); | 238 transient_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 242 examples_button_->SetStyle(views::Button::STYLE_BUTTON); | 239 examples_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 243 show_hide_window_button_->SetStyle(views::Button::STYLE_BUTTON); | 240 show_hide_window_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 244 show_screensaver_->SetStyle(views::Button::STYLE_BUTTON); | |
| 245 show_web_notification_->SetStyle(views::Button::STYLE_BUTTON); | 241 show_web_notification_->SetStyle(views::Button::STYLE_BUTTON); |
| 246 | 242 |
| 247 views::GridLayout* layout = new views::GridLayout(this); | 243 views::GridLayout* layout = new views::GridLayout(this); |
| 248 layout->SetInsets(5, 5, 5, 5); | 244 layout->SetInsets(5, 5, 5, 5); |
| 249 SetLayoutManager(layout); | 245 SetLayoutManager(layout); |
| 250 views::ColumnSet* column_set = layout->AddColumnSet(0); | 246 views::ColumnSet* column_set = layout->AddColumnSet(0); |
| 251 column_set->AddColumn(views::GridLayout::LEADING, | 247 column_set->AddColumn(views::GridLayout::LEADING, |
| 252 views::GridLayout::CENTER, | 248 views::GridLayout::CENTER, |
| 253 0, | 249 0, |
| 254 views::GridLayout::USE_PREF, | 250 views::GridLayout::USE_PREF, |
| 255 0, | 251 0, |
| 256 0); | 252 0); |
| 257 AddViewToLayout(layout, create_button_); | 253 AddViewToLayout(layout, create_button_); |
| 258 AddViewToLayout(layout, panel_button_); | 254 AddViewToLayout(layout, panel_button_); |
| 259 AddViewToLayout(layout, create_nonresizable_button_); | 255 AddViewToLayout(layout, create_nonresizable_button_); |
| 260 AddViewToLayout(layout, bubble_button_); | 256 AddViewToLayout(layout, bubble_button_); |
| 261 AddViewToLayout(layout, lock_button_); | 257 AddViewToLayout(layout, lock_button_); |
| 262 AddViewToLayout(layout, widgets_button_); | 258 AddViewToLayout(layout, widgets_button_); |
| 263 AddViewToLayout(layout, system_modal_button_); | 259 AddViewToLayout(layout, system_modal_button_); |
| 264 AddViewToLayout(layout, window_modal_button_); | 260 AddViewToLayout(layout, window_modal_button_); |
| 265 AddViewToLayout(layout, child_modal_button_); | 261 AddViewToLayout(layout, child_modal_button_); |
| 266 AddViewToLayout(layout, transient_button_); | 262 AddViewToLayout(layout, transient_button_); |
| 267 AddViewToLayout(layout, examples_button_); | 263 AddViewToLayout(layout, examples_button_); |
| 268 AddViewToLayout(layout, show_hide_window_button_); | 264 AddViewToLayout(layout, show_hide_window_button_); |
| 269 AddViewToLayout(layout, show_screensaver_); | |
| 270 AddViewToLayout(layout, show_web_notification_); | 265 AddViewToLayout(layout, show_web_notification_); |
| 271 set_context_menu_controller(this); | 266 set_context_menu_controller(this); |
| 272 } | 267 } |
| 273 | 268 |
| 274 WindowTypeLauncher::~WindowTypeLauncher() { | 269 WindowTypeLauncher::~WindowTypeLauncher() { |
| 275 } | 270 } |
| 276 | 271 |
| 277 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { | 272 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { |
| 278 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); | 273 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); |
| 279 } | 274 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 } else if (sender == window_modal_button_) { | 321 } else if (sender == window_modal_button_) { |
| 327 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), | 322 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), |
| 328 ui::MODAL_TYPE_WINDOW); | 323 ui::MODAL_TYPE_WINDOW); |
| 329 } else if (sender == child_modal_button_) { | 324 } else if (sender == child_modal_button_) { |
| 330 ash::test::CreateChildModalParent( | 325 ash::test::CreateChildModalParent( |
| 331 GetWidget()->GetNativeView()->GetRootWindow()); | 326 GetWidget()->GetNativeView()->GetRootWindow()); |
| 332 } else if (sender == transient_button_) { | 327 } else if (sender == transient_button_) { |
| 333 NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); | 328 NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); |
| 334 } else if (sender == show_hide_window_button_) { | 329 } else if (sender == show_hide_window_button_) { |
| 335 NonModalTransient::ToggleNonModalTransient(GetWidget()->GetNativeView()); | 330 NonModalTransient::ToggleNonModalTransient(GetWidget()->GetNativeView()); |
| 336 } else if (sender == show_screensaver_) { | |
| 337 ash::ShowScreensaver(GURL("http://www.google.com")); | |
| 338 content::BrowserThread::PostDelayedTask(content::BrowserThread::UI, | |
| 339 FROM_HERE, | |
| 340 base::Bind(&ash::CloseScreensaver), | |
| 341 base::TimeDelta::FromSeconds(5)); | |
| 342 | |
| 343 } else if (sender == show_web_notification_) { | 331 } else if (sender == show_web_notification_) { |
| 344 scoped_ptr<message_center::Notification> notification; | 332 scoped_ptr<message_center::Notification> notification; |
| 345 notification.reset(new message_center::Notification( | 333 notification.reset(new message_center::Notification( |
| 346 message_center::NOTIFICATION_TYPE_SIMPLE, | 334 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 347 "id0", | 335 "id0", |
| 348 base::ASCIIToUTF16("Test Shell Web Notification"), | 336 base::ASCIIToUTF16("Test Shell Web Notification"), |
| 349 base::ASCIIToUTF16("Notification message body."), | 337 base::ASCIIToUTF16("Notification message body."), |
| 350 gfx::Image(), | 338 gfx::Image(), |
| 351 base::ASCIIToUTF16("www.testshell.org"), | 339 base::ASCIIToUTF16("www.testshell.org"), |
| 352 message_center::NotifierId( | 340 message_center::NotifierId( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 NULL, | 384 NULL, |
| 397 gfx::Rect(point, gfx::Size()), | 385 gfx::Rect(point, gfx::Size()), |
| 398 views::MENU_ANCHOR_TOPLEFT, | 386 views::MENU_ANCHOR_TOPLEFT, |
| 399 source_type) == MenuRunner::MENU_DELETED) { | 387 source_type) == MenuRunner::MENU_DELETED) { |
| 400 return; | 388 return; |
| 401 } | 389 } |
| 402 } | 390 } |
| 403 | 391 |
| 404 } // namespace shell | 392 } // namespace shell |
| 405 } // namespace ash | 393 } // namespace ash |
| OLD | NEW |