Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ | 6 #define CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ |
| 7 | 7 |
| 8 #include "ash/screenshot_delegate.h" | 8 #include "ash/screenshot_delegate.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/time.h" | 12 #include "base/time.h" |
| 12 #include "ui/compositor/layer.h" | |
| 13 | 13 |
| 14 namespace aura { | 14 namespace aura { |
| 15 class Window; | 15 class Window; |
| 16 } // namespace aura | 16 } // namespace aura |
| 17 | 17 |
| 18 namespace base { | |
| 19 class FilePath; | |
| 20 } // namespace base | |
| 21 | |
| 22 namespace Screenshot { | |
| 23 enum Result { | |
|
James Cook
2013/03/29 20:00:32
Move this into ScreenshotTakerObserver
sschmitz
2013/03/29 21:02:35
Done.
| |
| 24 SCREENSHOT_SUCCESS = 0, | |
| 25 SCREENSHOT_GRABWINDOW_PARTIAL_FAILED, | |
| 26 SCREENSHOT_GRABWINDOW_FULL_FAILED, | |
| 27 SCREENSHOT_CREATE_DIR_FAILED, | |
| 28 SCREENSHOT_GET_DIR_FAILED, | |
| 29 SCREENSHOT_CHECK_DIR_FAILED, | |
| 30 SCREENSHOT_CREATE_FILE_FAILED, | |
| 31 SCREENSHOT_WRITE_FILE_FAILED, | |
| 32 SCREENSHOT_RESULT_COUNT // must be last | |
|
James Cook
2013/03/29 20:00:32
Two spaces before comment and period at end (or ju
sschmitz
2013/03/29 21:02:35
Done.
| |
| 33 }; | |
| 34 } // namespace Screenshot | |
| 35 | |
| 36 class ScreenshotTakerObserver { | |
| 37 public: | |
| 38 virtual ~ScreenshotTakerObserver() {} | |
| 39 | |
| 40 virtual void OnScreenshotCompleted( | |
| 41 Screenshot::Result screenshot_result, | |
| 42 const base::FilePath& screenshot_path) = 0; | |
| 43 }; | |
| 44 | |
| 18 class ScreenshotTaker : public ash::ScreenshotDelegate { | 45 class ScreenshotTaker : public ash::ScreenshotDelegate { |
| 19 public: | 46 public: |
| 20 ScreenshotTaker(); | 47 ScreenshotTaker(); |
| 21 virtual ~ScreenshotTaker(); | 48 virtual ~ScreenshotTaker(); |
| 22 | 49 |
| 23 // Overridden from ash::ScreenshotDelegate: | 50 // Overridden from ash::ScreenshotDelegate: |
| 24 virtual void HandleTakeScreenshotForAllRootWindows() OVERRIDE; | 51 virtual void HandleTakeScreenshotForAllRootWindows() OVERRIDE; |
| 25 virtual void HandleTakePartialScreenshot(aura::Window* window, | 52 virtual void HandleTakePartialScreenshot(aura::Window* window, |
| 26 const gfx::Rect& rect) OVERRIDE; | 53 const gfx::Rect& rect) OVERRIDE; |
| 27 virtual bool CanTakeScreenshot() OVERRIDE; | 54 virtual bool CanTakeScreenshot() OVERRIDE; |
| 28 | 55 |
| 56 // For test we override the screenshot directory for cleanup. | |
| 57 void SetScreenshotDirectoryForTest(const base::FilePath& directory); | |
| 58 | |
| 59 // For test we observe the completion of a screenshot. | |
| 60 static void SetObserverForTest(ScreenshotTakerObserver* observer); | |
| 61 static ScreenshotTakerObserver* GetObserverForTest(); | |
| 62 | |
| 29 private: | 63 private: |
| 30 // Flashes the screen to provide visual feedback that a screenshot has | |
| 31 // been taken. | |
| 32 void DisplayVisualFeedback(const gfx::Rect& rect); | |
| 33 | |
| 34 // Closes the visual feedback layer. | |
| 35 void CloseVisualFeedbackLayer(); | |
| 36 | |
| 37 // The timestamp when the screenshot task was issued last time. | 64 // The timestamp when the screenshot task was issued last time. |
| 38 base::Time last_screenshot_timestamp_; | 65 base::Time last_screenshot_timestamp_; |
| 39 | 66 |
| 40 // The flashing effect of the screen for the visual feedback when taking a | 67 scoped_ptr<base::FilePath> screenshot_directory_for_test_; |
| 41 // screenshot. | 68 |
| 42 scoped_ptr<ui::Layer> visual_feedback_layer_; | 69 static ScreenshotTakerObserver* s_observer_for_test; |
|
James Cook
2013/03/29 20:00:32
statics are observer_for_test_ like members.
sschmitz
2013/03/29 21:02:35
Done.
| |
| 43 | 70 |
| 44 DISALLOW_COPY_AND_ASSIGN(ScreenshotTaker); | 71 DISALLOW_COPY_AND_ASSIGN(ScreenshotTaker); |
| 45 }; | 72 }; |
| 46 | 73 |
| 47 #endif // CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ | 74 #endif // CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ |
| OLD | NEW |