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

Side by Side Diff: chrome/browser/ui/ash/screenshot_taker.h

Issue 13105002: Screenshot effect non-obvious (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: update Created 7 years, 8 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 unified diff | Download patch
OLDNEW
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/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
11 #include "base/time.h" 13 #include "base/time.h"
12 #include "ui/compositor/layer.h"
13 14
14 namespace aura { 15 namespace aura {
15 class Window; 16 class Window;
16 } // namespace aura 17 } // namespace aura
17 18
19 class ScreenshotTakerObserver {
20 public:
21 enum Result {
22 SCREENSHOT_SUCCESS = 0,
23 SCREENSHOT_GRABWINDOW_PARTIAL_FAILED,
24 SCREENSHOT_GRABWINDOW_FULL_FAILED,
25 SCREENSHOT_CREATE_DIR_FAILED,
26 SCREENSHOT_GET_DIR_FAILED,
27 SCREENSHOT_CHECK_DIR_FAILED,
28 SCREENSHOT_CREATE_FILE_FAILED,
29 SCREENSHOT_WRITE_FILE_FAILED,
30 SCREENSHOT_RESULT_COUNT
31 };
32
33 virtual ~ScreenshotTakerObserver() {}
sky 2013/03/31 01:16:03 Move this to protected to make it clear it's not o
sschmitz 2013/04/02 21:23:25 Done.
34
35 virtual void OnScreenshotCompleted(
36 Result screenshot_result, const base::FilePath& screenshot_path) = 0;
37 };
38
18 class ScreenshotTaker : public ash::ScreenshotDelegate { 39 class ScreenshotTaker : public ash::ScreenshotDelegate {
19 public: 40 public:
20 ScreenshotTaker(); 41 ScreenshotTaker();
21 virtual ~ScreenshotTaker(); 42 virtual ~ScreenshotTaker();
22 43
23 // Overridden from ash::ScreenshotDelegate: 44 // Overridden from ash::ScreenshotDelegate:
24 virtual void HandleTakeScreenshotForAllRootWindows() OVERRIDE; 45 virtual void HandleTakeScreenshotForAllRootWindows() OVERRIDE;
25 virtual void HandleTakePartialScreenshot(aura::Window* window, 46 virtual void HandleTakePartialScreenshot(aura::Window* window,
26 const gfx::Rect& rect) OVERRIDE; 47 const gfx::Rect& rect) OVERRIDE;
27 virtual bool CanTakeScreenshot() OVERRIDE; 48 virtual bool CanTakeScreenshot() OVERRIDE;
28 49
50 // For test we override the screenshot directory for cleanup.
51 void SetScreenshotDirectoryForTest(const base::FilePath& directory);
52
53 // For test we observe the completion of a screenshot.
54 static void SetObserverForTest(ScreenshotTakerObserver* observer);
sky 2013/03/31 01:16:03 If this is really only for a test, how about movin
sschmitz 2013/04/02 21:23:25 Made it general; used standard Observer list.
55 static ScreenshotTakerObserver* GetObserverForTest();
56
29 private: 57 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. 58 // The timestamp when the screenshot task was issued last time.
38 base::Time last_screenshot_timestamp_; 59 base::Time last_screenshot_timestamp_;
39 60
40 // The flashing effect of the screen for the visual feedback when taking a 61 base::FilePath screenshot_directory_for_test_;
41 // screenshot. 62
42 scoped_ptr<ui::Layer> visual_feedback_layer_; 63 static ScreenshotTakerObserver* observer_for_test_;
43 64
44 DISALLOW_COPY_AND_ASSIGN(ScreenshotTaker); 65 DISALLOW_COPY_AND_ASSIGN(ScreenshotTaker);
45 }; 66 };
46 67
47 #endif // CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ 68 #endif // CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698