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

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, 3 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 dangerous_item, 493 dangerous_item,
494 TabContents::FromWebContents(GetWebUIWebContents()), 494 TabContents::FromWebContents(GetWebUIWebContents()),
495 base::Bind(&DownloadsDOMHandler::DangerPromptAccepted, 495 base::Bind(&DownloadsDOMHandler::DangerPromptAccepted,
496 weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()), 496 weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()),
497 base::Closure()); 497 base::Closure());
498 // danger_prompt will delete itself. 498 // danger_prompt will delete itself.
499 DCHECK(danger_prompt); 499 DCHECK(danger_prompt);
500 } 500 }
501 501
502 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) { 502 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) {
503 content::DownloadItem* item = download_manager_->GetActiveDownloadItem( 503 content::DownloadItem* item = download_manager_->GetDownload(download_id);
Randy Smith (Not in Mondays) 2012/09/11 19:02:21 I think we want a cancellation/interrupt guard som
benjhayden 2012/09/12 18:17:25 Done.
504 download_id);
505 if (!item) 504 if (!item)
506 return; 505 return;
507 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); 506 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
508 item->DangerousDownloadValidated(); 507 item->DangerousDownloadValidated();
509 } 508 }
510 509
511 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( 510 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue(
512 const base::ListValue* args) { 511 const base::ListValue* args) {
513 int id = -1; 512 int id = -1;
514 if (!ExtractIntegerValue(args, &id)) 513 if (!ExtractIntegerValue(args, &id))
515 return NULL; 514 return NULL;
516 content::DownloadItem* download_item = download_manager_->GetDownload(id); 515 content::DownloadItem* download_item = download_manager_->GetDownload(id);
517 if (!download_item && original_profile_download_manager_) 516 if (!download_item && original_profile_download_manager_)
518 download_item = original_profile_download_manager_->GetDownload(id); 517 download_item = original_profile_download_manager_->GetDownload(id);
519 return download_item; 518 return download_item;
520 } 519 }
521 520
522 content::WebContents* DownloadsDOMHandler::GetWebUIWebContents() { 521 content::WebContents* DownloadsDOMHandler::GetWebUIWebContents() {
523 return web_ui()->GetWebContents(); 522 return web_ui()->GetWebContents();
524 } 523 }
525 524
526 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { 525 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) {
527 web_ui()->CallJavascriptFunction("downloadsList", downloads); 526 web_ui()->CallJavascriptFunction("downloadsList", downloads);
528 } 527 }
529 528
530 void DownloadsDOMHandler::CallDownloadUpdated( 529 void DownloadsDOMHandler::CallDownloadUpdated(
531 const base::ListValue& download_item) { 530 const base::ListValue& download_item) {
532 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); 531 web_ui()->CallJavascriptFunction("downloadUpdated", download_item);
533 } 532 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698