OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/accelerators/accelerator_controller_delegate_aura.h" | 5 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "ash/common/system/status_area_widget.h" | 24 #include "ash/common/system/status_area_widget.h" |
25 #include "ash/common/system/system_notifier.h" | 25 #include "ash/common/system/system_notifier.h" |
26 #include "ash/common/system/tray/system_tray.h" | 26 #include "ash/common/system/tray/system_tray.h" |
27 #include "ash/common/system/web_notification/web_notification_tray.h" | 27 #include "ash/common/system/web_notification/web_notification_tray.h" |
28 #include "ash/common/wallpaper/wallpaper_delegate.h" | 28 #include "ash/common/wallpaper/wallpaper_delegate.h" |
29 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 29 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
30 #include "ash/common/wm/window_state.h" | 30 #include "ash/common/wm/window_state.h" |
31 #include "ash/common/wm/wm_event.h" | 31 #include "ash/common/wm/wm_event.h" |
32 #include "ash/common/wm_shell.h" | 32 #include "ash/common/wm_shell.h" |
33 #include "ash/debug.h" | 33 #include "ash/debug.h" |
34 #include "ash/desktop_background/desktop_background_controller.h" | |
35 #include "ash/display/display_manager.h" | 34 #include "ash/display/display_manager.h" |
36 #include "ash/display/window_tree_host_manager.h" | 35 #include "ash/display/window_tree_host_manager.h" |
37 #include "ash/host/ash_window_tree_host.h" | 36 #include "ash/host/ash_window_tree_host.h" |
38 #include "ash/magnifier/magnification_controller.h" | 37 #include "ash/magnifier/magnification_controller.h" |
39 #include "ash/root_window_controller.h" | 38 #include "ash/root_window_controller.h" |
40 #include "ash/rotator/screen_rotation_animator.h" | 39 #include "ash/rotator/screen_rotation_animator.h" |
41 #include "ash/rotator/window_rotation.h" | 40 #include "ash/rotator/window_rotation.h" |
42 #include "ash/screen_util.h" | 41 #include "ash/screen_util.h" |
43 #include "ash/screenshot_delegate.h" | 42 #include "ash/screenshot_delegate.h" |
44 #include "ash/shell.h" | 43 #include "ash/shell.h" |
45 #include "ash/touch/touch_hud_debug.h" | 44 #include "ash/touch/touch_hud_debug.h" |
46 #include "ash/utility/screenshot_controller.h" | 45 #include "ash/utility/screenshot_controller.h" |
46 #include "ash/wallpaper/wallpaper_controller.h" | |
47 #include "ash/wm/power_button_controller.h" | 47 #include "ash/wm/power_button_controller.h" |
48 #include "ash/wm/window_state_aura.h" | 48 #include "ash/wm/window_state_aura.h" |
49 #include "ash/wm/window_util.h" | 49 #include "ash/wm/window_util.h" |
50 #include "base/metrics/histogram_macros.h" | 50 #include "base/metrics/histogram_macros.h" |
51 #include "base/metrics/user_metrics.h" | 51 #include "base/metrics/user_metrics.h" |
52 #include "base/strings/string_split.h" | 52 #include "base/strings/string_split.h" |
53 #include "base/strings/utf_string_conversions.h" | 53 #include "base/strings/utf_string_conversions.h" |
54 #include "third_party/skia/include/core/SkColor.h" | 54 #include "third_party/skia/include/core/SkColor.h" |
55 #include "third_party/skia/include/core/SkPaint.h" | 55 #include "third_party/skia/include/core/SkPaint.h" |
56 #include "ui/base/accelerators/accelerator.h" | 56 #include "ui/base/accelerators/accelerator.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 canvas.DrawColor(fill); | 280 canvas.DrawColor(fill); |
281 SkPaint paint; | 281 SkPaint paint; |
282 paint.setColor(rect); | 282 paint.setColor(rect); |
283 paint.setStrokeWidth(10); | 283 paint.setStrokeWidth(10); |
284 paint.setStyle(SkPaint::kStroke_Style); | 284 paint.setStyle(SkPaint::kStroke_Style); |
285 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 285 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
286 canvas.DrawRoundRect(gfx::Rect(image_size), 100, paint); | 286 canvas.DrawRoundRect(gfx::Rect(image_size), 100, paint); |
287 return gfx::ImageSkia(canvas.ExtractImageRep()); | 287 return gfx::ImageSkia(canvas.ExtractImageRep()); |
288 } | 288 } |
289 | 289 |
290 void HandleToggleDesktopBackgroundMode() { | 290 void HandleToggleWallpaperMode() { |
291 static int index = 0; | 291 static int index = 0; |
292 DesktopBackgroundController* desktop_background_controller = | 292 WallpaperController* wallpaper_controller = |
293 Shell::GetInstance()->desktop_background_controller(); | 293 Shell::GetInstance()->wallpaper_controller(); |
294 switch (++index % 4) { | 294 switch (++index % 4) { |
295 case 0: | 295 case 0: |
296 ash::WmShell::Get()->wallpaper_delegate()->InitializeWallpaper(); | 296 ash::WmShell::Get()->wallpaper_delegate()->InitializeWallpaper(); |
297 break; | 297 break; |
298 case 1: | 298 case 1: |
299 desktop_background_controller->SetWallpaperImage( | 299 wallpaper_controller->SetWallpaperImage( |
300 CreateWallpaperImage(SK_ColorRED, SK_ColorBLUE), | 300 CreateWallpaperImage(SK_ColorRED, SK_ColorBLUE), |
301 wallpaper::WALLPAPER_LAYOUT_STRETCH); | 301 wallpaper::WALLPAPER_LAYOUT_STRETCH); |
302 break; | 302 break; |
303 case 2: | 303 case 2: |
304 desktop_background_controller->SetWallpaperImage( | 304 wallpaper_controller->SetWallpaperImage( |
305 CreateWallpaperImage(SK_ColorBLUE, SK_ColorGREEN), | 305 CreateWallpaperImage(SK_ColorBLUE, SK_ColorGREEN), |
306 wallpaper::WALLPAPER_LAYOUT_CENTER); | 306 wallpaper::WALLPAPER_LAYOUT_CENTER); |
307 break; | 307 break; |
308 case 3: | 308 case 3: |
309 desktop_background_controller->SetWallpaperImage( | 309 wallpaper_controller->SetWallpaperImage( |
310 CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED), | 310 CreateWallpaperImage(SK_ColorGREEN, SK_ColorRED), |
311 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED); | 311 wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED); |
312 break; | 312 break; |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 bool CanHandleUnpin() { | 316 bool CanHandleUnpin() { |
317 wm::WindowState* window_state = wm::GetActiveWindowState(); | 317 wm::WindowState* window_state = wm::GetActiveWindowState(); |
318 return window_state && window_state->IsPinned(); | 318 return window_state && window_state->IsPinned(); |
319 } | 319 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 void AcceleratorControllerDelegateAura::SetScreenshotDelegate( | 357 void AcceleratorControllerDelegateAura::SetScreenshotDelegate( |
358 std::unique_ptr<ScreenshotDelegate> screenshot_delegate) { | 358 std::unique_ptr<ScreenshotDelegate> screenshot_delegate) { |
359 screenshot_delegate_ = std::move(screenshot_delegate); | 359 screenshot_delegate_ = std::move(screenshot_delegate); |
360 } | 360 } |
361 | 361 |
362 bool AcceleratorControllerDelegateAura::HandlesAction( | 362 bool AcceleratorControllerDelegateAura::HandlesAction( |
363 AcceleratorAction action) { | 363 AcceleratorAction action) { |
364 // NOTE: When adding a new accelerator that only depends on //ash/common code, | 364 // NOTE: When adding a new accelerator that only depends on //ash/common code, |
365 // add it to accelerator_controller.cc instead. See class comment. | 365 // add it to accelerator_controller.cc instead. See class comment. |
366 switch (action) { | 366 switch (action) { |
367 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: | 367 case DEBUG_TOGGLE_WALLPAPER_MODE: |
James Cook
2016/08/30 05:18:19
nit: alphabetize, here and below
msw
2016/08/30 16:07:59
Done.
| |
368 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: | 368 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
369 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: | 369 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
370 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: | 370 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
371 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: | 371 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: |
372 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: | 372 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: |
373 case FOCUS_SHELF: | 373 case FOCUS_SHELF: |
374 case LAUNCH_APP_0: | 374 case LAUNCH_APP_0: |
375 case LAUNCH_APP_1: | 375 case LAUNCH_APP_1: |
376 case LAUNCH_APP_2: | 376 case LAUNCH_APP_2: |
377 case LAUNCH_APP_3: | 377 case LAUNCH_APP_3: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 break; | 415 break; |
416 } | 416 } |
417 return false; | 417 return false; |
418 } | 418 } |
419 | 419 |
420 bool AcceleratorControllerDelegateAura::CanPerformAction( | 420 bool AcceleratorControllerDelegateAura::CanPerformAction( |
421 AcceleratorAction action, | 421 AcceleratorAction action, |
422 const ui::Accelerator& accelerator, | 422 const ui::Accelerator& accelerator, |
423 const ui::Accelerator& previous_accelerator) { | 423 const ui::Accelerator& previous_accelerator) { |
424 switch (action) { | 424 switch (action) { |
425 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: | 425 case DEBUG_TOGGLE_WALLPAPER_MODE: |
426 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: | 426 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
427 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: | 427 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
428 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: | 428 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
429 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: | 429 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: |
430 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: | 430 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: |
431 return debug::DebugAcceleratorsEnabled(); | 431 return debug::DebugAcceleratorsEnabled(); |
432 case MAGNIFY_SCREEN_ZOOM_IN: | 432 case MAGNIFY_SCREEN_ZOOM_IN: |
433 case MAGNIFY_SCREEN_ZOOM_OUT: | 433 case MAGNIFY_SCREEN_ZOOM_OUT: |
434 return CanHandleMagnifyScreen(); | 434 return CanHandleMagnifyScreen(); |
435 case SCALE_UI_DOWN: | 435 case SCALE_UI_DOWN: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 NOTREACHED(); | 486 NOTREACHED(); |
487 break; | 487 break; |
488 } | 488 } |
489 return false; | 489 return false; |
490 } | 490 } |
491 | 491 |
492 void AcceleratorControllerDelegateAura::PerformAction( | 492 void AcceleratorControllerDelegateAura::PerformAction( |
493 AcceleratorAction action, | 493 AcceleratorAction action, |
494 const ui::Accelerator& accelerator) { | 494 const ui::Accelerator& accelerator) { |
495 switch (action) { | 495 switch (action) { |
496 case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE: | 496 case DEBUG_TOGGLE_WALLPAPER_MODE: |
497 HandleToggleDesktopBackgroundMode(); | 497 HandleToggleWallpaperMode(); |
498 break; | 498 break; |
499 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: | 499 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: |
500 Shell::GetInstance()->display_manager()->ToggleDisplayScaleFactor(); | 500 Shell::GetInstance()->display_manager()->ToggleDisplayScaleFactor(); |
501 break; | 501 break; |
502 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: | 502 case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
503 Shell::GetPrimaryRootWindowController()->ash_host()->ToggleFullScreen(); | 503 Shell::GetPrimaryRootWindowController()->ash_host()->ToggleFullScreen(); |
504 break; | 504 break; |
505 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: | 505 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: |
506 debug::ToggleShowDebugBorders(); | 506 debug::ToggleShowDebugBorders(); |
507 break; | 507 break; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
646 message_center::NotifierId( | 646 message_center::NotifierId( |
647 message_center::NotifierId::SYSTEM_COMPONENT, | 647 message_center::NotifierId::SYSTEM_COMPONENT, |
648 system_notifier::kNotifierDeprecatedAccelerator), | 648 system_notifier::kNotifierDeprecatedAccelerator), |
649 message_center::RichNotificationData(), | 649 message_center::RichNotificationData(), |
650 new DeprecatedAcceleratorNotificationDelegate)); | 650 new DeprecatedAcceleratorNotificationDelegate)); |
651 message_center::MessageCenter::Get()->AddNotification( | 651 message_center::MessageCenter::Get()->AddNotification( |
652 std::move(notification)); | 652 std::move(notification)); |
653 } | 653 } |
654 | 654 |
655 } // namespace ash | 655 } // namespace ash |
OLD | NEW |