Index: ash/common/system/chromeos/palette/tools/capture_region_mode.cc |
diff --git a/ash/common/system/chromeos/palette/tools/capture_region_action.cc b/ash/common/system/chromeos/palette/tools/capture_region_mode.cc |
similarity index 53% |
rename from ash/common/system/chromeos/palette/tools/capture_region_action.cc |
rename to ash/common/system/chromeos/palette/tools/capture_region_mode.cc |
index fdf7c72e71944498a4cf7b51fb1b057219543dfb..6cac51df83f02f273586852429869b72aab6c64c 100644 |
--- a/ash/common/system/chromeos/palette/tools/capture_region_action.cc |
+++ b/ash/common/system/chromeos/palette/tools/capture_region_mode.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ash/common/system/chromeos/palette/tools/capture_region_action.h" |
+#include "ash/common/system/chromeos/palette/tools/capture_region_mode.h" |
#include "ash/common/accelerators/accelerator_controller.h" |
#include "ash/common/palette_delegate.h" |
@@ -22,20 +22,25 @@ const int kToastDurationMs = 2500; |
} // namespace |
-CaptureRegionAction::CaptureRegionAction(Delegate* delegate) |
- : CommonPaletteTool(delegate) {} |
+CaptureRegionMode::CaptureRegionMode(Delegate* delegate) |
+ : CommonPaletteTool(delegate), weak_factory_(this) {} |
-CaptureRegionAction::~CaptureRegionAction() {} |
+CaptureRegionMode::~CaptureRegionMode() {} |
-PaletteGroup CaptureRegionAction::GetGroup() const { |
- return PaletteGroup::ACTION; |
+PaletteGroup CaptureRegionMode::GetGroup() const { |
+ return PaletteGroup::MODE; |
} |
-PaletteToolId CaptureRegionAction::GetToolId() const { |
+PaletteToolId CaptureRegionMode::GetToolId() const { |
return PaletteToolId::CAPTURE_REGION; |
} |
-void CaptureRegionAction::OnEnable() { |
+gfx::VectorIconId CaptureRegionMode::GetActiveTrayIcon() { |
+ // TODO(jdufault): Update to real icon once new tray icons are ready. |
+ return gfx::VectorIconId::PALETTE_TRAY_ICON_MAGNIFY; |
+} |
+ |
+void CaptureRegionMode::OnEnable() { |
CommonPaletteTool::OnEnable(); |
ToastData toast(kToastId, l10n_util::GetStringUTF16( |
@@ -43,18 +48,31 @@ void CaptureRegionAction::OnEnable() { |
kToastDurationMs, base::string16()); |
ash::WmShell::Get()->toast_manager()->Show(toast); |
- WmShell::Get()->palette_delegate()->TakePartialScreenshot(); |
- delegate()->DisableTool(GetToolId()); |
+ WmShell::Get()->palette_delegate()->TakePartialScreenshot(base::Bind( |
+ &CaptureRegionMode::OnScreenshotDone, weak_factory_.GetWeakPtr())); |
delegate()->HidePalette(); |
} |
-views::View* CaptureRegionAction::CreateView() { |
+void CaptureRegionMode::OnDisable() { |
+ CommonPaletteTool::OnDisable(); |
+ |
+ // If the user manually cancelled the action we need to make sure to cancel |
+ // the screenshot session as well. |
+ WmShell::Get()->palette_delegate()->CancelPartialScreenshot(); |
+} |
+ |
+views::View* CaptureRegionMode::CreateView() { |
return CreateDefaultView( |
l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_CAPTURE_REGION_ACTION)); |
} |
-gfx::VectorIconId CaptureRegionAction::GetPaletteIconId() { |
+gfx::VectorIconId CaptureRegionMode::GetPaletteIconId() { |
return gfx::VectorIconId::PALETTE_ACTION_CAPTURE_REGION; |
} |
+void CaptureRegionMode::OnScreenshotDone() { |
+ // The screenshot finished, so disable the tool. |
+ delegate()->DisableTool(GetToolId()); |
+} |
+ |
} // namespace ash |