OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WEBUI_SCREENSHOT_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 14 matching lines...) Expand all Loading... |
25 class Profile; | 25 class Profile; |
26 | 26 |
27 // ScreenshotSource is the data source that serves screenshots (saved | 27 // ScreenshotSource is the data source that serves screenshots (saved |
28 // or current) to the bug report html ui. | 28 // or current) to the bug report html ui. |
29 class ScreenshotSource : public ChromeURLDataManager::DataSource { | 29 class ScreenshotSource : public ChromeURLDataManager::DataSource { |
30 public: | 30 public: |
31 explicit ScreenshotSource( | 31 explicit ScreenshotSource( |
32 std::vector<unsigned char>* current_screenshot, | 32 std::vector<unsigned char>* current_screenshot, |
33 Profile* profile); | 33 Profile* profile); |
34 | 34 |
| 35 #if defined(USE_ASH) |
| 36 // Queries the browser process to determine if screenshots are disabled. |
| 37 static bool AreScreenshotsDisabled(); |
| 38 // Common access for the screenshot directory, parameter is set to the |
| 39 // requested directory and return value of true is given upon success. |
| 40 static bool GetScreenshotDirectory(FilePath* directory); |
| 41 #endif |
| 42 // Get the basefilename for screenshots |
| 43 static std::string GetScreenshotBaseFilename(); |
| 44 |
35 // Called when the network layer has requested a resource underneath | 45 // Called when the network layer has requested a resource underneath |
36 // the path we registered. | 46 // the path we registered. |
37 virtual void StartDataRequest(const std::string& path, | 47 virtual void StartDataRequest(const std::string& path, |
38 bool is_incognito, | 48 bool is_incognito, |
39 int request_id) OVERRIDE; | 49 int request_id) OVERRIDE; |
40 | 50 |
41 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 51 virtual std::string GetMimeType(const std::string&) const OVERRIDE; |
42 | 52 |
43 // Get the screenshot specified by the given relative path that we've cached | 53 // Get the screenshot specified by the given relative path that we've cached |
44 // from a previous request to the screenshots source. | 54 // from a previous request to the screenshots source. |
45 // Note: This method strips the query string from the given path. | 55 // Note: This method strips the query string from the given path. |
46 ScreenshotDataPtr GetCachedScreenshot(const std::string& screenshot_path); | 56 ScreenshotDataPtr GetCachedScreenshot(const std::string& screenshot_path); |
47 | 57 |
| 58 static const char kScreenshotUrlRoot[]; |
| 59 static const char kScreenshotCurrent[]; |
| 60 static const char kScreenshotSaved[]; |
| 61 #if defined(OS_CHROMEOS) |
| 62 static const char kScreenshotPrefix[]; |
| 63 static const char kScreenshotSuffix[]; |
| 64 #endif |
| 65 |
| 66 |
48 private: | 67 private: |
49 virtual ~ScreenshotSource(); | 68 virtual ~ScreenshotSource(); |
50 | 69 |
51 // Send the screenshot specified by the given relative path to the requestor. | 70 // Send the screenshot specified by the given relative path to the requestor. |
52 // This is the ancestor for SendSavedScreenshot and CacheAndSendScreenshot. | 71 // This is the ancestor for SendSavedScreenshot and CacheAndSendScreenshot. |
53 // All calls to send a screenshot should only call this method. | 72 // All calls to send a screenshot should only call this method. |
54 // Note: This method strips the query string from the given path. | 73 // Note: This method strips the query string from the given path. |
55 void SendScreenshot(const std::string& screenshot_path, int request_id); | 74 void SendScreenshot(const std::string& screenshot_path, int request_id); |
56 #if defined(OS_CHROMEOS) | 75 #if defined(OS_CHROMEOS) |
57 // Send a saved screenshot image file specified by the given screenshot path | 76 // Send a saved screenshot image file specified by the given screenshot path |
(...skipping 23 matching lines...) Expand all Loading... |
81 Profile* profile_; | 100 Profile* profile_; |
82 | 101 |
83 // Key: Relative path to the screenshot (including filename) | 102 // Key: Relative path to the screenshot (including filename) |
84 // Value: Pointer to the screenshot data associated with the path. | 103 // Value: Pointer to the screenshot data associated with the path. |
85 std::map<std::string, ScreenshotDataPtr> cached_screenshots_; | 104 std::map<std::string, ScreenshotDataPtr> cached_screenshots_; |
86 | 105 |
87 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); | 106 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); |
88 }; | 107 }; |
89 | 108 |
90 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ | 109 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ |
OLD | NEW |