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

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

Issue 706013004: Move non-browser specific ScreenshotTaker code to ui/snapshot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing comma. Created 6 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_
6 #define CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_
7
8 #include "ash/screenshot_delegate.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "base/time/time.h"
16 #include "chrome/browser/notifications/notification.h"
17
18 class Profile;
19
20 namespace ash {
21 namespace test {
22 class ScreenshotTakerTest;
23 }
24 }
25 namespace aura {
26 class Window;
27 }
28
29 class ScreenshotTakerObserver {
30 public:
31 enum Result {
32 SCREENSHOT_SUCCESS = 0,
33 SCREENSHOT_GRABWINDOW_PARTIAL_FAILED,
34 SCREENSHOT_GRABWINDOW_FULL_FAILED,
35 SCREENSHOT_CREATE_DIR_FAILED,
36 SCREENSHOT_GET_DIR_FAILED,
37 SCREENSHOT_CHECK_DIR_FAILED,
38 SCREENSHOT_CREATE_FILE_FAILED,
39 SCREENSHOT_WRITE_FILE_FAILED,
40 SCREENSHOTS_DISABLED,
41 SCREENSHOT_RESULT_COUNT
42 };
43
44 virtual void OnScreenshotCompleted(
45 Result screenshot_result,
46 const base::FilePath& screenshot_path) = 0;
47
48 protected:
49 virtual ~ScreenshotTakerObserver() {}
50 };
51
52 class ScreenshotTaker : public ash::ScreenshotDelegate {
53 public:
54 ScreenshotTaker();
55
56 ~ScreenshotTaker() override;
57
58 // Overridden from ash::ScreenshotDelegate:
59 void HandleTakeScreenshotForAllRootWindows() override;
60 void HandleTakePartialScreenshot(aura::Window* window,
61 const gfx::Rect& rect) override;
62 bool CanTakeScreenshot() override;
63
64 void ShowNotification(
65 ScreenshotTakerObserver::Result screenshot_result,
66 const base::FilePath& screenshot_path);
67
68 void AddObserver(ScreenshotTakerObserver* observer);
69 void RemoveObserver(ScreenshotTakerObserver* observer);
70 bool HasObserver(const ScreenshotTakerObserver* observer) const;
71
72 private:
73 friend class ash::test::ScreenshotTakerTest;
74
75 void GrabWindowSnapshotAsyncCallback(
76 base::FilePath screenshot_path,
77 bool is_partial,
78 int window_idx,
79 scoped_refptr<base::RefCountedBytes> png_data);
80 void GrabPartialWindowSnapshotAsync(aura::Window* window,
81 const gfx::Rect& snapshot_bounds,
82 Profile* profile,
83 base::FilePath screenshot_path);
84 void GrabFullWindowSnapshotAsync(aura::Window* window,
85 const gfx::Rect& snapshot_bounds,
86 Profile* profile,
87 base::FilePath screenshot_path,
88 int window_idx);
89
90 Profile* GetProfile();
91 void SetScreenshotDirectoryForTest(const base::FilePath& directory);
92 void SetScreenshotBasenameForTest(const std::string& basename);
93 void SetScreenshotProfileForTest(Profile* profile);
94
95 #if defined(OS_CHROMEOS)
96 Notification* CreateNotification(
97 ScreenshotTakerObserver::Result screenshot_result,
98 const base::FilePath& screenshot_path);
99 #endif
100
101 // The timestamp when the screenshot task was issued last time.
102 base::Time last_screenshot_timestamp_;
103
104 ObserverList<ScreenshotTakerObserver> observers_;
105
106 base::FilePath screenshot_directory_for_test_;
107 std::string screenshot_basename_for_test_;
108 Profile* profile_for_test_;
109
110 base::WeakPtrFactory<ScreenshotTaker> factory_;
111
112 DISALLOW_COPY_AND_ASSIGN(ScreenshotTaker);
113 };
114
115 #endif // CHROME_BROWSER_UI_ASH_SCREENSHOT_TAKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698