Commit e3750dad authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

capture_mode: Enter capture mode with accelerators.

Existing screenshot accelerators now enter capture mode.

Test: manual, no screenshots taken with capture mode enabled
Change-Id: Iaa80f4f16b906907c8f574627c4ce4217469a039
Fixed: 1113848
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341831Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796045}
parent c2e39ede
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ash/ambient/ambient_controller.h" #include "ash/ambient/ambient_controller.h"
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/assistant/model/assistant_ui_model.h" #include "ash/assistant/model/assistant_ui_model.h"
#include "ash/capture_mode/capture_mode_controller.h"
#include "ash/debug.h" #include "ash/debug.h"
#include "ash/display/display_configuration_controller.h" #include "ash/display/display_configuration_controller.h"
#include "ash/display/display_move_window_util.h" #include "ash/display/display_move_window_util.h"
...@@ -743,15 +744,42 @@ void HandleShowKeyboardShortcutViewer() { ...@@ -743,15 +744,42 @@ void HandleShowKeyboardShortcutViewer() {
NewWindowDelegate::GetInstance()->ShowKeyboardShortcutViewer(); NewWindowDelegate::GetInstance()->ShowKeyboardShortcutViewer();
} }
bool CanHandleScreenshot() {
// The old screenshot code will handle the different sessions in its own code.
if (!features::IsCaptureModeEnabled())
return true;
return !Shell::Get()->session_controller()->IsUserSessionBlocked();
}
// Tries to enter capture mode image type with |source|. Returns false if
// unsuccessful (capture mode disabled).
bool MaybeEnterImageCaptureMode(CaptureModeSource source) {
if (!features::IsCaptureModeEnabled())
return false;
auto* capture_mode_controller = CaptureModeController::Get();
capture_mode_controller->SetSource(source);
capture_mode_controller->SetType(CaptureModeType::kImage);
capture_mode_controller->Start();
return true;
}
void HandleTakeWindowScreenshot() { void HandleTakeWindowScreenshot() {
base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot")); base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot"));
if (MaybeEnterImageCaptureMode(CaptureModeSource::kWindow))
return;
Shell::Get()->screenshot_controller()->StartWindowScreenshotSession(); Shell::Get()->screenshot_controller()->StartWindowScreenshotSession();
} }
void HandleTakePartialScreenshot() { void HandleTakePartialScreenshot() {
base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot")); base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot"));
if (MaybeEnterImageCaptureMode(CaptureModeSource::kRegion))
return;
Shell::Get()->screenshot_controller()->StartPartialScreenshotSession( Shell::Get()->screenshot_controller()->StartPartialScreenshotSession(
true /* draw_overlay_immediately */); /*draw_overlay_immediately=*/true);
} }
void HandleTakeScreenshot() { void HandleTakeScreenshot() {
...@@ -1938,6 +1966,10 @@ bool AcceleratorControllerImpl::CanPerformAction( ...@@ -1938,6 +1966,10 @@ bool AcceleratorControllerImpl::CanPerformAction(
return !!FindPipWidget(); return !!FindPipWidget();
case MINIMIZE_TOP_WINDOW_ON_BACK: case MINIMIZE_TOP_WINDOW_ON_BACK:
return window_util::ShouldMinimizeTopWindowOnBack(); return window_util::ShouldMinimizeTopWindowOnBack();
case TAKE_PARTIAL_SCREENSHOT:
case TAKE_SCREENSHOT:
case TAKE_WINDOW_SCREENSHOT:
return CanHandleScreenshot();
// The following are always enabled. // The following are always enabled.
case BRIGHTNESS_DOWN: case BRIGHTNESS_DOWN:
...@@ -1982,9 +2014,6 @@ bool AcceleratorControllerImpl::CanPerformAction( ...@@ -1982,9 +2014,6 @@ bool AcceleratorControllerImpl::CanPerformAction(
case SHOW_SHORTCUT_VIEWER: case SHOW_SHORTCUT_VIEWER:
case SHOW_TASK_MANAGER: case SHOW_TASK_MANAGER:
case SUSPEND: case SUSPEND:
case TAKE_PARTIAL_SCREENSHOT:
case TAKE_SCREENSHOT:
case TAKE_WINDOW_SCREENSHOT:
case TOGGLE_FULLSCREEN: case TOGGLE_FULLSCREEN:
case TOGGLE_HIGH_CONTRAST: case TOGGLE_HIGH_CONTRAST:
case TOGGLE_MAXIMIZED: case TOGGLE_MAXIMIZED:
......
...@@ -1899,7 +1899,9 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { ...@@ -1899,7 +1899,9 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) {
// when a modal window is open // when a modal window is open
// //
// Screenshot // Screenshot
{ // TODO(sammiequon): Add some basic tests once capture mode is more fleshed
// out.
if (!features::IsCaptureModeEnabled()) {
TestScreenshotDelegate* delegate = GetScreenshotDelegate(); TestScreenshotDelegate* delegate = GetScreenshotDelegate();
delegate->set_can_take_screenshot(false); delegate->set_can_take_screenshot(false);
EXPECT_TRUE(ProcessInController( EXPECT_TRUE(ProcessInController(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment