OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/webui/screenshot_source.h" | 5 #include "chrome/browser/ui/webui/screenshot_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (!file_util::GetTempDir(directory)) { | 132 if (!file_util::GetTempDir(directory)) { |
133 LOG(ERROR) << "Failed to find temporary directory."; | 133 LOG(ERROR) << "Failed to find temporary directory."; |
134 return false; | 134 return false; |
135 } | 135 } |
136 } | 136 } |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 #endif | 140 #endif |
141 | 141 |
142 std::string ScreenshotSource::GetSource() { | 142 std::string ScreenshotSource::GetSource() const { |
143 return chrome::kChromeUIScreenshotPath; | 143 return chrome::kChromeUIScreenshotPath; |
144 } | 144 } |
145 | 145 |
146 void ScreenshotSource::StartDataRequest( | 146 void ScreenshotSource::StartDataRequest( |
147 const std::string& path, | 147 const std::string& path, |
148 bool is_incognito, | 148 bool is_incognito, |
149 const content::URLDataSource::GotDataCallback& callback) { | 149 const content::URLDataSource::GotDataCallback& callback) { |
150 SendScreenshot(path, callback); | 150 SendScreenshot(path, callback); |
151 } | 151 } |
152 | 152 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 void ScreenshotSource::CacheAndSendScreenshot( | 263 void ScreenshotSource::CacheAndSendScreenshot( |
264 const std::string& screenshot_path, | 264 const std::string& screenshot_path, |
265 const content::URLDataSource::GotDataCallback& callback, | 265 const content::URLDataSource::GotDataCallback& callback, |
266 ScreenshotDataPtr bytes) { | 266 ScreenshotDataPtr bytes) { |
267 // Strip the query from the screenshot path. | 267 // Strip the query from the screenshot path. |
268 std::string path = screenshot_path.substr( | 268 std::string path = screenshot_path.substr( |
269 0, screenshot_path.find_first_of("?")); | 269 0, screenshot_path.find_first_of("?")); |
270 cached_screenshots_[path] = bytes; | 270 cached_screenshots_[path] = bytes; |
271 callback.Run(new base::RefCountedBytes(*bytes)); | 271 callback.Run(new base::RefCountedBytes(*bytes)); |
272 } | 272 } |
OLD | NEW |