Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2441)

Unified Diff: ash/utility/screenshot_controller.cc

Issue 2291913002: Allow the user to cancel the capture region action, and show its active status in the tray. (Closed)
Patch Set: Address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/utility/screenshot_controller.h ('k') | ash/utility/screenshot_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/utility/screenshot_controller.cc
diff --git a/ash/utility/screenshot_controller.cc b/ash/utility/screenshot_controller.cc
index 1a912248812441001d980b71752a9aab4ba9ea29..cfc98c195b6d16e173ead4c6d0d163056f21d046 100644
--- a/ash/utility/screenshot_controller.cc
+++ b/ash/utility/screenshot_controller.cc
@@ -245,7 +245,7 @@ ScreenshotController::ScreenshotController()
ScreenshotController::~ScreenshotController() {
if (screenshot_delegate_)
- Cancel();
+ CancelScreenshotSession();
Shell::GetInstance()->RemovePreTargetHandler(this);
}
@@ -298,6 +298,18 @@ void ScreenshotController::StartPartialScreenshotSession(
EnableMouseWarp(false);
}
+void ScreenshotController::CancelScreenshotSession() {
+ mode_ = NONE;
+ pen_events_only_ = false;
+ root_window_ = nullptr;
+ SetSelectedWindow(nullptr);
+ screenshot_delegate_ = nullptr;
+ display::Screen::GetScreen()->RemoveObserver(this);
+ base::STLDeleteValues(&layers_);
+ cursor_setter_.reset();
+ EnableMouseWarp(true);
+}
+
void ScreenshotController::MaybeStart(const ui::LocatedEvent& event) {
aura::Window* current_root =
static_cast<aura::Window*>(event.target())->GetRootWindow();
@@ -326,7 +338,7 @@ void ScreenshotController::MaybeStart(const ui::LocatedEvent& event) {
void ScreenshotController::CompleteWindowScreenshot() {
if (selected_)
screenshot_delegate_->HandleTakeWindowScreenshot(selected_);
- Cancel();
+ CancelScreenshotSession();
}
void ScreenshotController::CompletePartialScreenshot() {
@@ -347,19 +359,7 @@ void ScreenshotController::CompletePartialScreenshot() {
screenshot_delegate_->HandleTakePartialScreenshot(
root_window_, gfx::IntersectRects(root_window_->bounds(), region));
}
- Cancel();
-}
-
-void ScreenshotController::Cancel() {
- mode_ = NONE;
- pen_events_only_ = false;
- root_window_ = nullptr;
- SetSelectedWindow(nullptr);
- screenshot_delegate_ = nullptr;
- display::Screen::GetScreen()->RemoveObserver(this);
- base::STLDeleteValues(&layers_);
- cursor_setter_.reset();
- EnableMouseWarp(true);
+ CancelScreenshotSession();
}
void ScreenshotController::Update(const ui::LocatedEvent& event) {
@@ -423,7 +423,7 @@ void ScreenshotController::OnKeyEvent(ui::KeyEvent* event) {
if (event->type() == ui::ET_KEY_RELEASED) {
if (event->key_code() == ui::VKEY_ESCAPE) {
- Cancel();
+ CancelScreenshotSession();
event->StopPropagation();
} else if (event->key_code() == ui::VKEY_RETURN && mode_ == WINDOW) {
CompleteWindowScreenshot();
@@ -522,14 +522,14 @@ void ScreenshotController::OnTouchEvent(ui::TouchEvent* event) {
void ScreenshotController::OnDisplayAdded(const display::Display& new_display) {
if (!screenshot_delegate_)
return;
- Cancel();
+ CancelScreenshotSession();
}
void ScreenshotController::OnDisplayRemoved(
const display::Display& old_display) {
if (!screenshot_delegate_)
return;
- Cancel();
+ CancelScreenshotSession();
}
void ScreenshotController::OnDisplayMetricsChanged(
« no previous file with comments | « ash/utility/screenshot_controller.h ('k') | ash/utility/screenshot_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698