| 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/options/certificate_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/certificate_manager_handler.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead( | 292 base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead( |
| 293 const base::FilePath& path, | 293 const base::FilePath& path, |
| 294 const ReadCallback& callback, | 294 const ReadCallback& callback, |
| 295 base::CancelableTaskTracker* tracker) { | 295 base::CancelableTaskTracker* tracker) { |
| 296 // Owned by reply callback posted below. | 296 // Owned by reply callback posted below. |
| 297 int* saved_errno = new int(0); | 297 int* saved_errno = new int(0); |
| 298 std::string* data = new std::string(); | 298 std::string* data = new std::string(); |
| 299 | 299 |
| 300 // Post task to file thread to read file. | 300 // Post task to file thread to read file. |
| 301 return tracker->PostTaskAndReply( | 301 return tracker->PostTaskAndReply( |
| 302 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), | 302 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get(), |
| 303 FROM_HERE, | 303 FROM_HERE, |
| 304 base::Bind(&FileAccessProvider::DoRead, this, path, saved_errno, data), | 304 base::Bind(&FileAccessProvider::DoRead, this, path, saved_errno, data), |
| 305 base::Bind(callback, base::Owned(saved_errno), base::Owned(data))); | 305 base::Bind(callback, base::Owned(saved_errno), base::Owned(data))); |
| 306 } | 306 } |
| 307 | 307 |
| 308 base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite( | 308 base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite( |
| 309 const base::FilePath& path, | 309 const base::FilePath& path, |
| 310 const std::string& data, | 310 const std::string& data, |
| 311 const WriteCallback& callback, | 311 const WriteCallback& callback, |
| 312 base::CancelableTaskTracker* tracker) { | 312 base::CancelableTaskTracker* tracker) { |
| 313 // Owned by reply callback posted below. | 313 // Owned by reply callback posted below. |
| 314 int* saved_errno = new int(0); | 314 int* saved_errno = new int(0); |
| 315 int* bytes_written = new int(0); | 315 int* bytes_written = new int(0); |
| 316 | 316 |
| 317 // Post task to file thread to write file. | 317 // Post task to file thread to write file. |
| 318 return tracker->PostTaskAndReply( | 318 return tracker->PostTaskAndReply( |
| 319 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), | 319 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get(), |
| 320 FROM_HERE, | 320 FROM_HERE, base::Bind(&FileAccessProvider::DoWrite, this, path, data, |
| 321 base::Bind(&FileAccessProvider::DoWrite, | 321 saved_errno, bytes_written), |
| 322 this, | 322 base::Bind(callback, base::Owned(saved_errno), |
| 323 path, | 323 base::Owned(bytes_written))); |
| 324 data, | |
| 325 saved_errno, | |
| 326 bytes_written), | |
| 327 base::Bind( | |
| 328 callback, base::Owned(saved_errno), base::Owned(bytes_written))); | |
| 329 } | 324 } |
| 330 | 325 |
| 331 void FileAccessProvider::DoRead(const base::FilePath& path, | 326 void FileAccessProvider::DoRead(const base::FilePath& path, |
| 332 int* saved_errno, | 327 int* saved_errno, |
| 333 std::string* data) { | 328 std::string* data) { |
| 334 bool success = base::ReadFileToString(path, data); | 329 bool success = base::ReadFileToString(path, data); |
| 335 *saved_errno = success ? 0 : errno; | 330 *saved_errno = success ? 0 : errno; |
| 336 } | 331 } |
| 337 | 332 |
| 338 void FileAccessProvider::DoWrite(const base::FilePath& path, | 333 void FileAccessProvider::DoWrite(const base::FilePath& path, |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 web_ui()->CallJavascriptFunctionUnsafe("CertificateImportErrorOverlay.show", | 1228 web_ui()->CallJavascriptFunctionUnsafe("CertificateImportErrorOverlay.show", |
| 1234 title_value, error_value, | 1229 title_value, error_value, |
| 1235 cert_error_list); | 1230 cert_error_list); |
| 1236 } | 1231 } |
| 1237 | 1232 |
| 1238 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { | 1233 gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const { |
| 1239 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 1234 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
| 1240 } | 1235 } |
| 1241 | 1236 |
| 1242 } // namespace options | 1237 } // namespace options |
| OLD | NEW |