| 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" | |
| 21 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/time/time.h" | |
| 23 #include "content/public/browser/browser_thread.h" | |
| 24 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 25 #include "ui/aura/window_event_dispatcher.h" | 21 #include "ui/aura/window_event_dispatcher.h" |
| 26 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
| 27 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 28 #include "ui/message_center/message_center.h" | 24 #include "ui/message_center/message_center.h" |
| 29 #include "ui/message_center/notification_types.h" | 25 #include "ui/message_center/notification_types.h" |
| 30 #include "ui/views/controls/button/label_button.h" | 26 #include "ui/views/controls/button/label_button.h" |
| 31 #include "ui/views/controls/menu/menu_item_view.h" | 27 #include "ui/views/controls/menu/menu_item_view.h" |
| 32 #include "ui/views/controls/menu/menu_runner.h" | 28 #include "ui/views/controls/menu/menu_runner.h" |
| 33 #include "ui/views/examples/examples_window_with_content.h" | 29 #include "ui/views/examples/examples_window_with_content.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 window_modal_button_(new views::LabelButton( | 197 window_modal_button_(new views::LabelButton( |
| 202 this, base::ASCIIToUTF16("Open Window Modal Window"))), | 198 this, base::ASCIIToUTF16("Open Window Modal Window"))), |
| 203 child_modal_button_(new views::LabelButton( | 199 child_modal_button_(new views::LabelButton( |
| 204 this, base::ASCIIToUTF16("Open Child Modal Window"))), | 200 this, base::ASCIIToUTF16("Open Child Modal Window"))), |
| 205 transient_button_(new views::LabelButton( | 201 transient_button_(new views::LabelButton( |
| 206 this, base::ASCIIToUTF16("Open Non-Modal Transient Window"))), | 202 this, base::ASCIIToUTF16("Open Non-Modal Transient Window"))), |
| 207 examples_button_(new views::LabelButton( | 203 examples_button_(new views::LabelButton( |
| 208 this, base::ASCIIToUTF16("Open Views Examples Window"))), | 204 this, base::ASCIIToUTF16("Open Views Examples Window"))), |
| 209 show_hide_window_button_(new views::LabelButton( | 205 show_hide_window_button_(new views::LabelButton( |
| 210 this, base::ASCIIToUTF16("Show/Hide a Window"))), | 206 this, base::ASCIIToUTF16("Show/Hide a Window"))), |
| 211 show_screensaver_(new views::LabelButton( | |
| 212 this, base::ASCIIToUTF16("Show the Screensaver [for 5 seconds]"))), | |
| 213 show_web_notification_(new views::LabelButton( | 207 show_web_notification_(new views::LabelButton( |
| 214 this, base::ASCIIToUTF16("Show a web/app notification"))) { | 208 this, base::ASCIIToUTF16("Show a web/app notification"))) { |
| 215 create_button_->SetStyle(views::Button::STYLE_BUTTON); | 209 create_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 216 panel_button_->SetStyle(views::Button::STYLE_BUTTON); | 210 panel_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 217 create_nonresizable_button_->SetStyle(views::Button::STYLE_BUTTON); | 211 create_nonresizable_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 218 bubble_button_->SetStyle(views::Button::STYLE_BUTTON); | 212 bubble_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 219 lock_button_->SetStyle(views::Button::STYLE_BUTTON); | 213 lock_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 220 widgets_button_->SetStyle(views::Button::STYLE_BUTTON); | 214 widgets_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 221 system_modal_button_->SetStyle(views::Button::STYLE_BUTTON); | 215 system_modal_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 222 window_modal_button_->SetStyle(views::Button::STYLE_BUTTON); | 216 window_modal_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 223 child_modal_button_->SetStyle(views::Button::STYLE_BUTTON); | 217 child_modal_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 224 transient_button_->SetStyle(views::Button::STYLE_BUTTON); | 218 transient_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 225 examples_button_->SetStyle(views::Button::STYLE_BUTTON); | 219 examples_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 226 show_hide_window_button_->SetStyle(views::Button::STYLE_BUTTON); | 220 show_hide_window_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 227 show_screensaver_->SetStyle(views::Button::STYLE_BUTTON); | |
| 228 show_web_notification_->SetStyle(views::Button::STYLE_BUTTON); | 221 show_web_notification_->SetStyle(views::Button::STYLE_BUTTON); |
| 229 | 222 |
| 230 views::GridLayout* layout = new views::GridLayout(this); | 223 views::GridLayout* layout = new views::GridLayout(this); |
| 231 layout->SetInsets(5, 5, 5, 5); | 224 layout->SetInsets(5, 5, 5, 5); |
| 232 SetLayoutManager(layout); | 225 SetLayoutManager(layout); |
| 233 views::ColumnSet* column_set = layout->AddColumnSet(0); | 226 views::ColumnSet* column_set = layout->AddColumnSet(0); |
| 234 column_set->AddColumn(views::GridLayout::LEADING, | 227 column_set->AddColumn(views::GridLayout::LEADING, |
| 235 views::GridLayout::CENTER, | 228 views::GridLayout::CENTER, |
| 236 0, | 229 0, |
| 237 views::GridLayout::USE_PREF, | 230 views::GridLayout::USE_PREF, |
| 238 0, | 231 0, |
| 239 0); | 232 0); |
| 240 AddViewToLayout(layout, create_button_); | 233 AddViewToLayout(layout, create_button_); |
| 241 AddViewToLayout(layout, panel_button_); | 234 AddViewToLayout(layout, panel_button_); |
| 242 AddViewToLayout(layout, create_nonresizable_button_); | 235 AddViewToLayout(layout, create_nonresizable_button_); |
| 243 AddViewToLayout(layout, bubble_button_); | 236 AddViewToLayout(layout, bubble_button_); |
| 244 AddViewToLayout(layout, lock_button_); | 237 AddViewToLayout(layout, lock_button_); |
| 245 AddViewToLayout(layout, widgets_button_); | 238 AddViewToLayout(layout, widgets_button_); |
| 246 AddViewToLayout(layout, system_modal_button_); | 239 AddViewToLayout(layout, system_modal_button_); |
| 247 AddViewToLayout(layout, window_modal_button_); | 240 AddViewToLayout(layout, window_modal_button_); |
| 248 AddViewToLayout(layout, child_modal_button_); | 241 AddViewToLayout(layout, child_modal_button_); |
| 249 AddViewToLayout(layout, transient_button_); | 242 AddViewToLayout(layout, transient_button_); |
| 250 AddViewToLayout(layout, examples_button_); | 243 AddViewToLayout(layout, examples_button_); |
| 251 AddViewToLayout(layout, show_hide_window_button_); | 244 AddViewToLayout(layout, show_hide_window_button_); |
| 252 AddViewToLayout(layout, show_screensaver_); | |
| 253 AddViewToLayout(layout, show_web_notification_); | 245 AddViewToLayout(layout, show_web_notification_); |
| 254 set_context_menu_controller(this); | 246 set_context_menu_controller(this); |
| 255 } | 247 } |
| 256 | 248 |
| 257 WindowTypeLauncher::~WindowTypeLauncher() { | 249 WindowTypeLauncher::~WindowTypeLauncher() { |
| 258 } | 250 } |
| 259 | 251 |
| 260 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { | 252 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { |
| 261 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); | 253 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); |
| 262 } | 254 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } else if (sender == window_modal_button_) { | 301 } else if (sender == window_modal_button_) { |
| 310 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), | 302 ModalWindow::OpenModalWindow(GetWidget()->GetNativeView(), |
| 311 ui::MODAL_TYPE_WINDOW); | 303 ui::MODAL_TYPE_WINDOW); |
| 312 } else if (sender == child_modal_button_) { | 304 } else if (sender == child_modal_button_) { |
| 313 ash::test::CreateChildModalParent( | 305 ash::test::CreateChildModalParent( |
| 314 GetWidget()->GetNativeView()->GetRootWindow()); | 306 GetWidget()->GetNativeView()->GetRootWindow()); |
| 315 } else if (sender == transient_button_) { | 307 } else if (sender == transient_button_) { |
| 316 NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); | 308 NonModalTransient::OpenNonModalTransient(GetWidget()->GetNativeView()); |
| 317 } else if (sender == show_hide_window_button_) { | 309 } else if (sender == show_hide_window_button_) { |
| 318 NonModalTransient::ToggleNonModalTransient(GetWidget()->GetNativeView()); | 310 NonModalTransient::ToggleNonModalTransient(GetWidget()->GetNativeView()); |
| 319 } else if (sender == show_screensaver_) { | |
| 320 ash::ShowScreensaver(GURL("http://www.google.com")); | |
| 321 content::BrowserThread::PostDelayedTask(content::BrowserThread::UI, | |
| 322 FROM_HERE, | |
| 323 base::Bind(&ash::CloseScreensaver), | |
| 324 base::TimeDelta::FromSeconds(5)); | |
| 325 | |
| 326 } else if (sender == show_web_notification_) { | 311 } else if (sender == show_web_notification_) { |
| 327 scoped_ptr<message_center::Notification> notification; | 312 scoped_ptr<message_center::Notification> notification; |
| 328 notification.reset(new message_center::Notification( | 313 notification.reset(new message_center::Notification( |
| 329 message_center::NOTIFICATION_TYPE_SIMPLE, | 314 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 330 "id0", | 315 "id0", |
| 331 base::ASCIIToUTF16("Test Shell Web Notification"), | 316 base::ASCIIToUTF16("Test Shell Web Notification"), |
| 332 base::ASCIIToUTF16("Notification message body."), | 317 base::ASCIIToUTF16("Notification message body."), |
| 333 gfx::Image(), | 318 gfx::Image(), |
| 334 base::ASCIIToUTF16("www.testshell.org"), | 319 base::ASCIIToUTF16("www.testshell.org"), |
| 335 message_center::NotifierId( | 320 message_center::NotifierId( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 NULL, | 364 NULL, |
| 380 gfx::Rect(point, gfx::Size()), | 365 gfx::Rect(point, gfx::Size()), |
| 381 views::MENU_ANCHOR_TOPLEFT, | 366 views::MENU_ANCHOR_TOPLEFT, |
| 382 source_type) == MenuRunner::MENU_DELETED) { | 367 source_type) == MenuRunner::MENU_DELETED) { |
| 383 return; | 368 return; |
| 384 } | 369 } |
| 385 } | 370 } |
| 386 | 371 |
| 387 } // namespace shell | 372 } // namespace shell |
| 388 } // namespace ash | 373 } // namespace ash |
| OLD | NEW |