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

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: review 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/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 class ScreenshotTakerObserver {
23 public:
24 enum Result {
25 SCREENSHOT_SUCCESS = 0,
26 SCREENSHOT_GRABWINDOW_PARTIAL_FAILED,
27 SCREENSHOT_GRABWINDOW_FULL_FAILED,
28 SCREENSHOT_CREATE_DIR_FAILED,
29 SCREENSHOT_GET_DIR_FAILED,
30 SCREENSHOT_CHECK_DIR_FAILED,
31 SCREENSHOT_CREATE_FILE_FAILED,
32 SCREENSHOT_WRITE_FILE_FAILED,
33 SCREENSHOT_RESULT_COUNT
34 };
35
36 virtual ~ScreenshotTakerObserver() {}
37
38 virtual void OnScreenshotCompleted(
39 Result screenshot_result, const base::FilePath& screenshot_path) = 0;
40 };
41
18 class ScreenshotTaker : public ash::ScreenshotDelegate { 42 class ScreenshotTaker : public ash::ScreenshotDelegate {
19 public: 43 public:
20 ScreenshotTaker(); 44 ScreenshotTaker();
21 virtual ~ScreenshotTaker(); 45 virtual ~ScreenshotTaker();
22 46
23 // Overridden from ash::ScreenshotDelegate: 47 // Overridden from ash::ScreenshotDelegate:
24 virtual void HandleTakeScreenshotForAllRootWindows() OVERRIDE; 48 virtual void HandleTakeScreenshotForAllRootWindows() OVERRIDE;
25 virtual void HandleTakePartialScreenshot(aura::Window* window, 49 virtual void HandleTakePartialScreenshot(aura::Window* window,
26 const gfx::Rect& rect) OVERRIDE; 50 const gfx::Rect& rect) OVERRIDE;
27 virtual bool CanTakeScreenshot() OVERRIDE; 51 virtual bool CanTakeScreenshot() OVERRIDE;
28 52
53 // For test we override the screenshot directory for cleanup.
54 void SetScreenshotDirectoryForTest(const base::FilePath& directory);
55
56 // For test we observe the completion of a screenshot.
57 static void SetObserverForTest(ScreenshotTakerObserver* observer);
58 static ScreenshotTakerObserver* GetObserverForTest();
Jun Mukai 2013/03/29 23:01:37 move them to private methods and declare friend cl
sschmitz 2013/03/29 23:40:44 I think there would be a problem, because friendsh
Jun Mukai 2013/03/30 00:37:17 You can call the private methods from SetUp() of y
sschmitz 2013/04/02 21:23:25 I did what you suggested. Made the override functi
59
29 private: 60 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. 61 // The timestamp when the screenshot task was issued last time.
38 base::Time last_screenshot_timestamp_; 62 base::Time last_screenshot_timestamp_;
39 63
40 // The flashing effect of the screen for the visual feedback when taking a 64 scoped_ptr<base::FilePath> screenshot_directory_for_test_;
James Cook 2013/03/29 22:49:34 I don't think this needs to be a pointer - you sho
sschmitz 2013/03/29 23:40:44 Done.
41 // screenshot. 65
42 scoped_ptr<ui::Layer> visual_feedback_layer_; 66 static ScreenshotTakerObserver* observer_for_test_;
Jun Mukai 2013/03/29 23:01:37 why static? I don't think your test needs to crea
sschmitz 2013/03/29 23:40:44 The reason for static is to avoid passing a weak p
Jun Mukai 2013/03/30 00:37:17 I still personally prefer non-static solution but
sschmitz 2013/04/02 21:23:25 Yes. Good point. I removed all statics in favor of
43 67
44 DISALLOW_COPY_AND_ASSIGN(ScreenshotTaker); 68 DISALLOW_COPY_AND_ASSIGN(ScreenshotTaker);
45 }; 69 };
46 70
47 #endif // CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_ 71 #endif // CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698