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" | 8 #include "ash/screensaver/screensaver_view.h" |
9 #include "ash/session_state_delegate.h" | 9 #include "ash/session_state_delegate.h" |
10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 AddViewToLayout(layout, lock_button_); | 259 AddViewToLayout(layout, lock_button_); |
260 AddViewToLayout(layout, widgets_button_); | 260 AddViewToLayout(layout, widgets_button_); |
261 AddViewToLayout(layout, system_modal_button_); | 261 AddViewToLayout(layout, system_modal_button_); |
262 AddViewToLayout(layout, window_modal_button_); | 262 AddViewToLayout(layout, window_modal_button_); |
263 AddViewToLayout(layout, child_modal_button_); | 263 AddViewToLayout(layout, child_modal_button_); |
264 AddViewToLayout(layout, transient_button_); | 264 AddViewToLayout(layout, transient_button_); |
265 AddViewToLayout(layout, examples_button_); | 265 AddViewToLayout(layout, examples_button_); |
266 AddViewToLayout(layout, show_hide_window_button_); | 266 AddViewToLayout(layout, show_hide_window_button_); |
267 AddViewToLayout(layout, show_screensaver_); | 267 AddViewToLayout(layout, show_screensaver_); |
268 AddViewToLayout(layout, show_web_notification_); | 268 AddViewToLayout(layout, show_web_notification_); |
269 #if !defined(OS_MACOSX) | |
270 set_context_menu_controller(this); | 269 set_context_menu_controller(this); |
271 #endif | |
272 } | 270 } |
273 | 271 |
274 WindowTypeLauncher::~WindowTypeLauncher() { | 272 WindowTypeLauncher::~WindowTypeLauncher() { |
275 } | 273 } |
276 | 274 |
277 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { | 275 void WindowTypeLauncher::OnPaint(gfx::Canvas* canvas) { |
278 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); | 276 canvas->FillRect(GetLocalBounds(), SK_ColorWHITE); |
279 } | 277 } |
280 | 278 |
281 bool WindowTypeLauncher::OnMousePressed(const ui::MouseEvent& event) { | 279 bool WindowTypeLauncher::OnMousePressed(const ui::MouseEvent& event) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 ASCIIToUTF16("Notification message body."), | 343 ASCIIToUTF16("Notification message body."), |
346 gfx::Image(), | 344 gfx::Image(), |
347 ASCIIToUTF16("www.testshell.org"), | 345 ASCIIToUTF16("www.testshell.org"), |
348 message_center::NotifierId(), | 346 message_center::NotifierId(), |
349 message_center::RichNotificationData(), | 347 message_center::RichNotificationData(), |
350 NULL /* delegate */)); | 348 NULL /* delegate */)); |
351 | 349 |
352 ash::Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget() | 350 ash::Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget() |
353 ->web_notification_tray()->message_center() | 351 ->web_notification_tray()->message_center() |
354 ->AddNotification(notification.Pass()); | 352 ->AddNotification(notification.Pass()); |
355 } | 353 } else if (sender == examples_button_) { |
356 #if !defined(OS_MACOSX) | |
357 else if (sender == examples_button_) { | |
358 views::examples::ShowExamplesWindowWithContent( | 354 views::examples::ShowExamplesWindowWithContent( |
359 views::examples::DO_NOTHING_ON_CLOSE, | 355 views::examples::DO_NOTHING_ON_CLOSE, |
360 ash::Shell::GetInstance()->browser_context()); | 356 ash::Shell::GetInstance()->browser_context()); |
361 } | 357 } |
362 #endif // !defined(OS_MACOSX) | |
363 } | 358 } |
364 | 359 |
365 #if !defined(OS_MACOSX) | |
366 void WindowTypeLauncher::ExecuteCommand(int id, int event_flags) { | 360 void WindowTypeLauncher::ExecuteCommand(int id, int event_flags) { |
367 switch (id) { | 361 switch (id) { |
368 case COMMAND_NEW_WINDOW: | 362 case COMMAND_NEW_WINDOW: |
369 InitWindowTypeLauncher(); | 363 InitWindowTypeLauncher(); |
370 break; | 364 break; |
371 case COMMAND_TOGGLE_FULLSCREEN: | 365 case COMMAND_TOGGLE_FULLSCREEN: |
372 GetWidget()->SetFullscreen(!GetWidget()->IsFullscreen()); | 366 GetWidget()->SetFullscreen(!GetWidget()->IsFullscreen()); |
373 break; | 367 break; |
374 default: | 368 default: |
375 break; | 369 break; |
376 } | 370 } |
377 } | 371 } |
378 #endif // !defined(OS_MACOSX) | |
379 | 372 |
380 #if !defined(OS_MACOSX) | |
381 void WindowTypeLauncher::ShowContextMenuForView( | 373 void WindowTypeLauncher::ShowContextMenuForView( |
382 views::View* source, | 374 views::View* source, |
383 const gfx::Point& point, | 375 const gfx::Point& point, |
384 ui::MenuSourceType source_type) { | 376 ui::MenuSourceType source_type) { |
385 MenuItemView* root = new MenuItemView(this); | 377 MenuItemView* root = new MenuItemView(this); |
386 root->AppendMenuItem(COMMAND_NEW_WINDOW, | 378 root->AppendMenuItem(COMMAND_NEW_WINDOW, |
387 ASCIIToUTF16("New Window"), | 379 ASCIIToUTF16("New Window"), |
388 MenuItemView::NORMAL); | 380 MenuItemView::NORMAL); |
389 root->AppendMenuItem(COMMAND_TOGGLE_FULLSCREEN, | 381 root->AppendMenuItem(COMMAND_TOGGLE_FULLSCREEN, |
390 ASCIIToUTF16("Toggle FullScreen"), | 382 ASCIIToUTF16("Toggle FullScreen"), |
391 MenuItemView::NORMAL); | 383 MenuItemView::NORMAL); |
392 // MenuRunner takes ownership of root. | 384 // MenuRunner takes ownership of root. |
393 menu_runner_.reset(new MenuRunner(root)); | 385 menu_runner_.reset(new MenuRunner(root)); |
394 if (menu_runner_->RunMenuAt(GetWidget(), NULL, | 386 if (menu_runner_->RunMenuAt(GetWidget(), NULL, |
395 gfx::Rect(point, gfx::Size()), | 387 gfx::Rect(point, gfx::Size()), |
396 MenuItemView::TOPLEFT, | 388 MenuItemView::TOPLEFT, |
397 source_type, | 389 source_type, |
398 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | 390 MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == |
399 MenuRunner::MENU_DELETED) | 391 MenuRunner::MENU_DELETED) |
400 return; | 392 return; |
401 } | 393 } |
402 #endif // !defined(OS_MACOSX) | |
403 | 394 |
404 } // namespace shell | 395 } // namespace shell |
405 } // namespace ash | 396 } // namespace ash |
OLD | NEW |