| OLD | NEW |
| 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 #include "chrome/browser/ui/webui/downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // TODO(rdsmith): Change to DCHECK when http://crbug.com/84508 is fixed. | 307 // TODO(rdsmith): Change to DCHECK when http://crbug.com/84508 is fixed. |
| 308 CHECK_NE(DownloadItem::kUninitializedHandle, file->db_handle()); | 308 CHECK_NE(DownloadItem::kUninitializedHandle, file->db_handle()); |
| 309 file->Remove(); | 309 file->Remove(); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 void DownloadsDOMHandler::HandleCancel(const ListValue* args) { | 313 void DownloadsDOMHandler::HandleCancel(const ListValue* args) { |
| 314 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CANCEL); | 314 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CANCEL); |
| 315 DownloadItem* file = GetDownloadByValue(args); | 315 DownloadItem* file = GetDownloadByValue(args); |
| 316 if (file) | 316 if (file) |
| 317 file->Cancel(true); | 317 file->Cancel(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void DownloadsDOMHandler::HandleClearAll(const ListValue* args) { | 320 void DownloadsDOMHandler::HandleClearAll(const ListValue* args) { |
| 321 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CLEAR_ALL); | 321 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CLEAR_ALL); |
| 322 download_manager_->RemoveAllDownloads(); | 322 download_manager_->RemoveAllDownloads(); |
| 323 | 323 |
| 324 Profile* profile = | 324 Profile* profile = |
| 325 Profile::FromBrowserContext(download_manager_->browser_context()); | 325 Profile::FromBrowserContext(download_manager_->browser_context()); |
| 326 // If this is an incognito downloader, clear All should clear main download | 326 // If this is an incognito downloader, clear All should clear main download |
| 327 // manager as well. | 327 // manager as well. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return NULL; | 383 return NULL; |
| 384 } | 384 } |
| 385 | 385 |
| 386 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { | 386 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { |
| 387 int id; | 387 int id; |
| 388 if (ExtractIntegerValue(args, &id)) { | 388 if (ExtractIntegerValue(args, &id)) { |
| 389 return GetDownloadById(id); | 389 return GetDownloadById(id); |
| 390 } | 390 } |
| 391 return NULL; | 391 return NULL; |
| 392 } | 392 } |
| OLD | NEW |