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

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

Issue 14947007: [Downloads] Allow acquiring dangerous download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 6 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); 365 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
366 content::DownloadItem* file = GetDownloadByValue(args); 366 content::DownloadItem* file = GetDownloadByValue(args);
367 if (file) 367 if (file)
368 ShowDangerPrompt(file); 368 ShowDangerPrompt(file);
369 } 369 }
370 370
371 void DownloadsDOMHandler::HandleDiscardDangerous(const base::ListValue* args) { 371 void DownloadsDOMHandler::HandleDiscardDangerous(const base::ListValue* args) {
372 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DISCARD_DANGEROUS); 372 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DISCARD_DANGEROUS);
373 content::DownloadItem* file = GetDownloadByValue(args); 373 content::DownloadItem* file = GetDownloadByValue(args);
374 if (file) 374 if (file)
375 file->Delete(content::DownloadItem::DELETE_DUE_TO_USER_DISCARD); 375 file->Remove();
376 } 376 }
377 377
378 void DownloadsDOMHandler::HandleShow(const base::ListValue* args) { 378 void DownloadsDOMHandler::HandleShow(const base::ListValue* args) {
379 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW); 379 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW);
380 content::DownloadItem* file = GetDownloadByValue(args); 380 content::DownloadItem* file = GetDownloadByValue(args);
381 if (file) 381 if (file)
382 file->ShowDownloadInShell(); 382 file->ShowDownloadInShell();
383 } 383 }
384 384
385 void DownloadsDOMHandler::HandlePause(const base::ListValue* args) { 385 void DownloadsDOMHandler::HandlePause(const base::ListValue* args) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) { 507 void DownloadsDOMHandler::DangerPromptAccepted(int download_id) {
508 content::DownloadItem* item = NULL; 508 content::DownloadItem* item = NULL;
509 if (main_notifier_.GetManager()) 509 if (main_notifier_.GetManager())
510 item = main_notifier_.GetManager()->GetDownload(download_id); 510 item = main_notifier_.GetManager()->GetDownload(download_id);
511 if (!item && original_notifier_.get() && original_notifier_->GetManager()) 511 if (!item && original_notifier_.get() && original_notifier_->GetManager())
512 item = original_notifier_->GetManager()->GetDownload(download_id); 512 item = original_notifier_->GetManager()->GetDownload(download_id);
513 if (!item || (item->GetState() != content::DownloadItem::IN_PROGRESS)) 513 if (!item || (item->GetState() != content::DownloadItem::IN_PROGRESS))
514 return; 514 return;
515 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); 515 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
516 item->DangerousDownloadValidated(); 516 item->ValidateDangerousDownload();
517 } 517 }
518 518
519 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() { 519 bool DownloadsDOMHandler::IsDeletingHistoryAllowed() {
520 content::DownloadManager* manager = main_notifier_.GetManager(); 520 content::DownloadManager* manager = main_notifier_.GetManager();
521 return (manager && 521 return (manager &&
522 Profile::FromBrowserContext(manager->GetBrowserContext())-> 522 Profile::FromBrowserContext(manager->GetBrowserContext())->
523 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)); 523 GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory));
524 } 524 }
525 525
526 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue( 526 content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue(
(...skipping 14 matching lines...) Expand all
541 } 541 }
542 542
543 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { 543 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) {
544 web_ui()->CallJavascriptFunction("downloadsList", downloads); 544 web_ui()->CallJavascriptFunction("downloadsList", downloads);
545 } 545 }
546 546
547 void DownloadsDOMHandler::CallDownloadUpdated( 547 void DownloadsDOMHandler::CallDownloadUpdated(
548 const base::ListValue& download_item) { 548 const base::ListValue& download_item) {
549 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); 549 web_ui()->CallJavascriptFunction("downloadUpdated", download_item);
550 } 550 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.cc ('k') | content/browser/android/download_controller_android_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698