| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 15 | 15 |
| 16 typedef std::vector<unsigned char> ScreenshotData; | 16 typedef std::vector<unsigned char> ScreenshotData; |
| 17 typedef linked_ptr<ScreenshotData> ScreenshotDataPtr; | 17 typedef linked_ptr<ScreenshotData> ScreenshotDataPtr; |
| 18 | 18 |
| 19 // ScreenshotSource is the data source that serves screenshots (saved | 19 // ScreenshotSource is the data source that serves screenshots (saved |
| 20 // or current) to the bug report html ui. | 20 // or current) to the bug report html ui. |
| 21 class ScreenshotSource : public ChromeURLDataManager::DataSource { | 21 class ScreenshotSource : public ChromeURLDataManager::DataSource { |
| 22 public: | 22 public: |
| 23 explicit ScreenshotSource( | 23 explicit ScreenshotSource( |
| 24 std::vector<unsigned char>* current_screenshot); | 24 std::vector<unsigned char>* current_screenshot); |
| 25 | 25 |
| 26 // Called when the network layer has requested a resource underneath | 26 // Called when the network layer has requested a resource underneath |
| 27 // the path we registered. | 27 // the path we registered. |
| 28 virtual void StartDataRequest(const std::string& path, | 28 virtual void StartDataRequest(const std::string& path, |
| 29 bool is_incognito, | 29 bool is_incognito, |
| 30 int request_id); | 30 int request_id) OVERRIDE; |
| 31 | 31 |
| 32 virtual std::string GetMimeType(const std::string&) const; | 32 virtual std::string GetMimeType(const std::string&) const OVERRIDE; |
| 33 | 33 |
| 34 // Get the screenshot specified by the given relative path that we've cached | 34 // Get the screenshot specified by the given relative path that we've cached |
| 35 // from a previous request to the screenshots source. | 35 // from a previous request to the screenshots source. |
| 36 // Note: This method strips the query string from the given path. | 36 // Note: This method strips the query string from the given path. |
| 37 ScreenshotDataPtr GetCachedScreenshot(const std::string& screenshot_path); | 37 ScreenshotDataPtr GetCachedScreenshot(const std::string& screenshot_path); |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 virtual ~ScreenshotSource(); | 40 virtual ~ScreenshotSource(); |
| 41 | 41 |
| 42 // Send the screenshot specified by the given relative path to the requestor. | 42 // Send the screenshot specified by the given relative path to the requestor. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 59 ScreenshotDataPtr current_screenshot_; | 59 ScreenshotDataPtr current_screenshot_; |
| 60 | 60 |
| 61 // Key: Relative path to the screenshot (including filename) | 61 // Key: Relative path to the screenshot (including filename) |
| 62 // Value: Pointer to the screenshot data associated with the path. | 62 // Value: Pointer to the screenshot data associated with the path. |
| 63 std::map<std::string, ScreenshotDataPtr> cached_screenshots_; | 63 std::map<std::string, ScreenshotDataPtr> cached_screenshots_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); | 65 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ | 68 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ |
| OLD | NEW |