 Chromium Code Reviews
 Chromium Code Reviews Issue 10908081:
  Refactor screenshot directory source  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 10908081:
  Refactor screenshot directory source  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) | 
| 17 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" | 17 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" | 
| 18 #include "chrome/browser/google_apis/gdata_errorcode.h" | 18 #include "chrome/browser/google_apis/gdata_errorcode.h" | 
| 19 #include "chrome/browser/chromeos/gdata/gdata_util.h" | |
| 20 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 
csilv
2012/09/13 05:32:17
nit: alphabetical order lines 17-20
 | |
| 19 #endif | 21 #endif | 
| 20 | 22 | 
| 21 typedef std::vector<unsigned char> ScreenshotData; | 23 typedef std::vector<unsigned char> ScreenshotData; | 
| 22 typedef linked_ptr<ScreenshotData> ScreenshotDataPtr; | 24 typedef linked_ptr<ScreenshotData> ScreenshotDataPtr; | 
| 23 | 25 | 
| 24 class FilePath; | 26 class FilePath; | 
| 25 class Profile; | 27 class Profile; | 
| 26 | 28 | 
| 27 // ScreenshotSource is the data source that serves screenshots (saved | 29 // ScreenshotSource is the data source that serves screenshots (saved | 
| 28 // or current) to the bug report html ui. | 30 // or current) to the bug report html ui. | 
| 29 class ScreenshotSource : public ChromeURLDataManager::DataSource { | 31 class ScreenshotSource : public ChromeURLDataManager::DataSource { | 
| 30 public: | 32 public: | 
| 31 explicit ScreenshotSource( | 33 explicit ScreenshotSource( | 
| 32 std::vector<unsigned char>* current_screenshot, | 34 std::vector<unsigned char>* current_screenshot, | 
| 33 Profile* profile); | 35 Profile* profile); | 
| 34 | 36 | 
| 37 #if defined(USE_ASH) | |
| 38 | |
| 39 // Queries the browser process to determine if screenshots are disabled. | |
| 40 static bool AreScreenshotsDisabled(); | |
| 41 | |
| 42 // Common access for the screenshot directory, parameter is set to the | |
| 43 // requested directory and return value of true is given upon success. | |
| 44 static bool GetScreenshotDirectory(FilePath* directory); | |
| 45 #endif | |
| 46 | |
| 47 // Get the basefilename for screenshots | |
| 48 static std::string GetScreenshotBaseFilename(); | |
| 49 | |
| 35 // Called when the network layer has requested a resource underneath | 50 // Called when the network layer has requested a resource underneath | 
| 36 // the path we registered. | 51 // the path we registered. | 
| 37 virtual void StartDataRequest(const std::string& path, | 52 virtual void StartDataRequest(const std::string& path, | 
| 38 bool is_incognito, | 53 bool is_incognito, | 
| 39 int request_id) OVERRIDE; | 54 int request_id) OVERRIDE; | 
| 40 | 55 | 
| 41 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 56 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 
| 42 | 57 | 
| 43 // Get the screenshot specified by the given relative path that we've cached | 58 // Get the screenshot specified by the given relative path that we've cached | 
| 44 // from a previous request to the screenshots source. | 59 // from a previous request to the screenshots source. | 
| 45 // Note: This method strips the query string from the given path. | 60 // Note: This method strips the query string from the given path. | 
| 46 ScreenshotDataPtr GetCachedScreenshot(const std::string& screenshot_path); | 61 ScreenshotDataPtr GetCachedScreenshot(const std::string& screenshot_path); | 
| 47 | 62 | 
| 63 // Url that represents the base directory for screenshots. | |
| 64 static const char kScreenshotUrlRoot[]; | |
| 65 // Identifier for the current screenshot | |
| 66 // (relative to screenshot base directory). | |
| 67 static const char kScreenshotCurrent[]; | |
| 68 // Path for directory where screenshots are saved | |
| 69 // (relative to screenshot base directory). | |
| 70 static const char kScreenshotSaved[]; | |
| 71 #if defined(OS_CHROMEOS) | |
| 72 // Common prefix to screenshot filenames. | |
| 73 static const char kScreenshotPrefix[]; | |
| 74 // Common suffix to screenshot filenames. | |
| 75 static const char kScreenshotSuffix[]; | |
| 76 #endif | |
| 77 | |
| 48 private: | 78 private: | 
| 49 virtual ~ScreenshotSource(); | 79 virtual ~ScreenshotSource(); | 
| 50 | 80 | 
| 51 // Send the screenshot specified by the given relative path to the requestor. | 81 // Send the screenshot specified by the given relative path to the requestor. | 
| 52 // This is the ancestor for SendSavedScreenshot and CacheAndSendScreenshot. | 82 // This is the ancestor for SendSavedScreenshot and CacheAndSendScreenshot. | 
| 53 // All calls to send a screenshot should only call this method. | 83 // All calls to send a screenshot should only call this method. | 
| 54 // Note: This method strips the query string from the given path. | 84 // Note: This method strips the query string from the given path. | 
| 55 void SendScreenshot(const std::string& screenshot_path, int request_id); | 85 void SendScreenshot(const std::string& screenshot_path, int request_id); | 
| 56 #if defined(OS_CHROMEOS) | 86 #if defined(OS_CHROMEOS) | 
| 57 // Send a saved screenshot image file specified by the given screenshot path | 87 // Send a saved screenshot image file specified by the given screenshot path | 
| (...skipping 23 matching lines...) Expand all Loading... | |
| 81 Profile* profile_; | 111 Profile* profile_; | 
| 82 | 112 | 
| 83 // Key: Relative path to the screenshot (including filename) | 113 // Key: Relative path to the screenshot (including filename) | 
| 84 // Value: Pointer to the screenshot data associated with the path. | 114 // Value: Pointer to the screenshot data associated with the path. | 
| 85 std::map<std::string, ScreenshotDataPtr> cached_screenshots_; | 115 std::map<std::string, ScreenshotDataPtr> cached_screenshots_; | 
| 86 | 116 | 
| 87 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); | 117 DISALLOW_COPY_AND_ASSIGN(ScreenshotSource); | 
| 88 }; | 118 }; | 
| 89 | 119 | 
| 90 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ | 120 #endif // CHROME_BROWSER_UI_WEBUI_SCREENSHOT_SOURCE_H_ | 
| OLD | NEW |