| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 #endif | 140 #endif |
| 141 | 141 |
| 142 std::string ScreenshotSource::GetSource() { | 142 std::string ScreenshotSource::GetSource() { |
| 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 const content::URLDataSource::ExtraRequestInfo& info, |
| 149 const content::URLDataSource::GotDataCallback& callback) { | 149 const content::URLDataSource::GotDataCallback& callback) { |
| 150 SendScreenshot(path, callback); | 150 SendScreenshot(path, callback); |
| 151 } | 151 } |
| 152 | 152 |
| 153 std::string ScreenshotSource::GetMimeType(const std::string&) const { | 153 std::string ScreenshotSource::GetMimeType(const std::string&) const { |
| 154 // We need to explicitly return a mime type, otherwise if the user tries to | 154 // We need to explicitly return a mime type, otherwise if the user tries to |
| 155 // drag the image they get no extension. | 155 // drag the image they get no extension. |
| 156 return "image/png"; | 156 return "image/png"; |
| 157 } | 157 } |
| 158 | 158 |
| (...skipping 104 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 |