diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-16 06:36:18 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-16 06:36:18 +0000 |
commit | bfbb87188dd4a850f8e51dd57d98b62473e0bc72 (patch) | |
tree | c1310e9840a4c74b1a1f85f5d314f5774a5c7e27 /ui | |
parent | 84ddfcf4b2f4d7533afa5d431083ad828c159c32 (diff) | |
download | chromium_src-bfbb87188dd4a850f8e51dd57d98b62473e0bc72.zip chromium_src-bfbb87188dd4a850f8e51dd57d98b62473e0bc72.tar.gz chromium_src-bfbb87188dd4a850f8e51dd57d98b62473e0bc72.tar.bz2 |
Implement HandleTakeSnapshot by using GrabWindowSnapshot
BUG=chromium:105198
TEST=manually
Review URL: http://codereview.chromium.org/8785017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura_shell/screenshot_delegate.h | 22 | ||||
-rw-r--r-- | ui/aura_shell/shell_accelerator_controller.cc | 18 | ||||
-rw-r--r-- | ui/aura_shell/shell_accelerator_controller.h | 6 |
3 files changed, 38 insertions, 8 deletions
diff --git a/ui/aura_shell/screenshot_delegate.h b/ui/aura_shell/screenshot_delegate.h new file mode 100644 index 0000000..9f6fe34 --- /dev/null +++ b/ui/aura_shell/screenshot_delegate.h @@ -0,0 +1,22 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_AURA_SHELL_SCREENSHOT_DELEGATE_H_ +#define UI_AURA_SHELL_SCREENSHOT_DELEGATE_H_ +#pragma once + +namespace aura_shell { + +// Delegate for taking screenshots. +class ScreenshotDelegate { + public: + virtual ~ScreenshotDelegate() {} + + // The actual task of taking a screenshot. This method is called + // when the user wants to take a screenshot manually. + virtual void HandleTakeScreenshot() = 0; +}; +} // namespace aura_shell + +#endif // UI_AURA_SHELL_SCREENSHOT_DELEGATE_H_ diff --git a/ui/aura_shell/shell_accelerator_controller.cc b/ui/aura_shell/shell_accelerator_controller.cc index 8c966ce..2089994 100644 --- a/ui/aura_shell/shell_accelerator_controller.cc +++ b/ui/aura_shell/shell_accelerator_controller.cc @@ -4,11 +4,11 @@ #include "ui/aura_shell/shell_accelerator_controller.h" -#include "base/logging.h" #include "ui/aura/event.h" #include "ui/aura/root_window.h" #include "ui/aura_shell/launcher/launcher.h" #include "ui/aura_shell/launcher/launcher_model.h" +#include "ui/aura_shell/screenshot_delegate.h" #include "ui/aura_shell/shell.h" #include "ui/aura_shell/shell_window_ids.h" #include "ui/aura_shell/window_util.h" @@ -74,12 +74,6 @@ bool HandleCycleWindow(bool forward) { return true; } -bool HandleTakeScreenshot() { - // TODO(mazda): http://crbug.com/105198 - NOTIMPLEMENTED(); - return false; -} - #if !defined(NDEBUG) // Rotates the screen. bool HandleRotateScreen() { @@ -171,6 +165,11 @@ bool ShellAcceleratorController::Process(const ui::Accelerator& accelerator) { return accelerator_manager_->Process(accelerator); } +void ShellAcceleratorController::SetScreenshotDelegate( + ScreenshotDelegate* screenshot_delegate) { + screenshot_delegate_.reset(screenshot_delegate); +} + //////////////////////////////////////////////////////////////////////////////// // ShellAcceleratorController, ui::AcceleratorTarget implementation: @@ -185,7 +184,10 @@ bool ShellAcceleratorController::AcceleratorPressed( case CYCLE_FORWARD: return HandleCycleWindow(true); case TAKE_SCREENSHOT: - return HandleTakeScreenshot(); + if (screenshot_delegate_.get()) + screenshot_delegate_->HandleTakeScreenshot(); + // Return true to prevent propagation of the key event. + return true; #if !defined(NDEBUG) case ROTATE_SCREEN: return HandleRotateScreen(); diff --git a/ui/aura_shell/shell_accelerator_controller.h b/ui/aura_shell/shell_accelerator_controller.h index 1a8e239..08f4a67 100644 --- a/ui/aura_shell/shell_accelerator_controller.h +++ b/ui/aura_shell/shell_accelerator_controller.h @@ -20,6 +20,8 @@ class AcceleratorManager; namespace aura_shell { +class ScreenshotDelegate; + // ShellAcceleratorController provides functions for registering or // unregistering global keyboard accelerators, which are handled earlier than // any windows. It also implements several handlers as an accelerator target. @@ -53,12 +55,16 @@ class AURA_SHELL_EXPORT ShellAcceleratorController // Overridden from ui::AcceleratorTarget: virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; + void SetScreenshotDelegate(ScreenshotDelegate* screenshot_delegate); + private: // Initialize the accelerators this class handles as a target. void Init(); scoped_ptr<ui::AcceleratorManager> accelerator_manager_; + scoped_ptr<ScreenshotDelegate> screenshot_delegate_; + // A map from accelerators to the AcceleratorAction values, which are used in // the implementation. std::map<ui::Accelerator, int> accelerators_; |