| 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/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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 results_value.Append(download_util::CreateDownloadItemValue(download, id)); | 185 results_value.Append(download_util::CreateDownloadItemValue(download, id)); |
| 186 web_ui()->CallJavascriptFunction("downloadUpdated", results_value); | 186 web_ui()->CallJavascriptFunction("downloadUpdated", results_value); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void DownloadsDOMHandler::OnDownloadDestroyed( | 189 void DownloadsDOMHandler::OnDownloadDestroyed( |
| 190 content::DownloadItem* download) { | 190 content::DownloadItem* download) { |
| 191 download->RemoveObserver(this); | 191 download->RemoveObserver(this); |
| 192 OrderedDownloads::iterator it = std::find(download_items_.begin(), | 192 OrderedDownloads::iterator it = std::find(download_items_.begin(), |
| 193 download_items_.end(), | 193 download_items_.end(), |
| 194 download); | 194 download); |
| 195 *it = NULL; | 195 if (it != download_items_.end()) |
| 196 *it = NULL; |
| 196 // A later ModelChanged() notification will change the WebUI's | 197 // A later ModelChanged() notification will change the WebUI's |
| 197 // view of the downloads list. | 198 // view of the downloads list. |
| 198 } | 199 } |
| 199 | 200 |
| 200 // A download has started or been deleted. Query our DownloadManager for the | 201 // A download has started or been deleted. Query our DownloadManager for the |
| 201 // current set of downloads. | 202 // current set of downloads. |
| 202 void DownloadsDOMHandler::ModelChanged(content::DownloadManager* manager) { | 203 void DownloadsDOMHandler::ModelChanged(content::DownloadManager* manager) { |
| 203 DCHECK(manager == download_manager_ || | 204 DCHECK(manager == download_manager_ || |
| 204 manager == original_profile_download_manager_); | 205 manager == original_profile_download_manager_); |
| 205 | 206 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 } | 408 } |
| 408 | 409 |
| 409 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( | 410 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( |
| 410 const ListValue* args) { | 411 const ListValue* args) { |
| 411 int id; | 412 int id; |
| 412 if (ExtractIntegerValue(args, &id)) { | 413 if (ExtractIntegerValue(args, &id)) { |
| 413 return GetDownloadById(id); | 414 return GetDownloadById(id); |
| 414 } | 415 } |
| 415 return NULL; | 416 return NULL; |
| 416 } | 417 } |
| OLD | NEW |