Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/ui/webui/downloads_dom_handler.cc

Issue 10912183: Remove DownloadManager::GetDownloadItem in favor of GetDownload() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()), 468 weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()),
469 base::Closure()); 469 base::Closure());
470 // danger_prompt will delete itself. 470 // danger_prompt will delete itself.
471 DCHECK(danger_prompt); 471 DCHECK(danger_prompt);
472 } 472 }
473 473
474 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) { 474 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) {
475 content::DownloadItem* item = NULL; 475 content::DownloadItem* item = NULL;
476 if (main_notifier_.GetManager()) 476 if (main_notifier_.GetManager())
477 item = main_notifier_.GetManager()->GetDownload(download_id); 477 item = main_notifier_.GetManager()->GetDownload(download_id);
478 if (original_notifier_.get() && original_notifier_->GetManager()) 478 if (!item && original_notifier_.get() && original_notifier_->GetManager())
479 item = original_notifier_->GetManager()->GetDownload(download_id); 479 item = original_notifier_->GetManager()->GetDownload(download_id);
480 if (!item) 480 if (!item || (item->GetState() != content::DownloadItem::IN_PROGRESS))
481 return; 481 return;
482 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); 482 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
483 item->DangerousDownloadValidated(); 483 item->DangerousDownloadValidated();
484 } 484 }
485 485
486 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( 486 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue(
487 const base::ListValue* args) { 487 const base::ListValue* args) {
488 int download_id = -1; 488 int download_id = -1;
489 if (!ExtractIntegerValue(args, &download_id)) 489 if (!ExtractIntegerValue(args, &download_id))
490 return NULL; 490 return NULL;
491 content::DownloadItem* item = NULL; 491 content::DownloadItem* item = NULL;
492 if (main_notifier_.GetManager()) 492 if (main_notifier_.GetManager())
493 item = main_notifier_.GetManager()->GetDownload(download_id); 493 item = main_notifier_.GetManager()->GetDownload(download_id);
494 if (original_notifier_.get() && original_notifier_->GetManager()) 494 if (!item && original_notifier_.get() && original_notifier_->GetManager())
495 item = original_notifier_->GetManager()->GetDownload(download_id); 495 item = original_notifier_->GetManager()->GetDownload(download_id);
496 return item; 496 return item;
497 } 497 }
498 498
499 content::WebContents* DownloadsDOMHandler::GetWebUIWebContents() { 499 content::WebContents* DownloadsDOMHandler::GetWebUIWebContents() {
500 return web_ui()->GetWebContents(); 500 return web_ui()->GetWebContents();
501 } 501 }
502 502
503 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { 503 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) {
504 web_ui()->CallJavascriptFunction("downloadsList", downloads); 504 web_ui()->CallJavascriptFunction("downloadsList", downloads);
505 } 505 }
506 506
507 void DownloadsDOMHandler::CallDownloadUpdated( 507 void DownloadsDOMHandler::CallDownloadUpdated(
508 const base::ListValue& download_item) { 508 const base::ListValue& download_item) {
509 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); 509 web_ui()->CallJavascriptFunction("downloadUpdated", download_item);
510 } 510 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_installer.cc ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698