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

Side by Side Diff: chrome/browser/ui/webui/screenshot_source.h

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

Powered by Google App Engine
This is Rietveld 408576698