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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #if defined(USE_ASH) | 29 #if defined(USE_ASH) |
30 #include "ash/shell.h" | 30 #include "ash/shell.h" |
31 #include "ash/shell_delegate.h" | 31 #include "ash/shell_delegate.h" |
32 #endif | 32 #endif |
33 | 33 |
34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
35 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 35 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
36 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 36 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
37 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 37 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
38 #include "chrome/browser/chromeos/login/user_manager.h" | 38 #include "chromeos/login/login_state.h" |
39 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
40 #endif | 40 #endif |
41 | 41 |
42 // static | 42 // static |
43 const char ScreenshotSource::kScreenshotUrlRoot[] = "chrome://screenshots/"; | 43 const char ScreenshotSource::kScreenshotUrlRoot[] = "chrome://screenshots/"; |
44 // static | 44 // static |
45 const char ScreenshotSource::kScreenshotCurrent[] = "current"; | 45 const char ScreenshotSource::kScreenshotCurrent[] = "current"; |
46 // static | 46 // static |
47 const char ScreenshotSource::kScreenshotSaved[] = "saved/"; | 47 const char ScreenshotSource::kScreenshotSaved[] = "saved/"; |
48 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 // static | 116 // static |
117 bool ScreenshotSource::GetScreenshotDirectory(base::FilePath* directory) { | 117 bool ScreenshotSource::GetScreenshotDirectory(base::FilePath* directory) { |
118 if (ScreenshotSource::AreScreenshotsDisabled()) | 118 if (ScreenshotSource::AreScreenshotsDisabled()) |
119 return false; | 119 return false; |
120 | 120 |
121 bool is_logged_in = true; | 121 bool is_logged_in = true; |
122 | 122 |
123 #if defined(OS_CHROMEOS) | 123 #if defined(OS_CHROMEOS) |
124 is_logged_in = chromeos::UserManager::Get()->IsUserLoggedIn(); | 124 is_logged_in = chromeos::LoginState::Get()->IsUserLoggedIn(); |
125 #endif | 125 #endif |
126 | 126 |
127 if (is_logged_in) { | 127 if (is_logged_in) { |
128 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( | 128 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( |
129 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); | 129 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); |
130 *directory = download_prefs->DownloadPath(); | 130 *directory = download_prefs->DownloadPath(); |
131 } else { | 131 } else { |
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; |
(...skipping 128 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 |