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

Side by Side Diff: chrome/browser/download/download_item_model.cc

Issue 15881012: Implement safebrowsing download feedback service, enabled for dev & canary only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/download/download_item_model.h" 5 #include "chrome/browser/download/download_item_model.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/supports_user_data.h" 12 #include "base/supports_user_data.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "chrome/browser/download/download_crx_util.h" 14 #include "chrome/browser/download/download_crx_util.h"
15 #include "chrome/browser/safe_browsing/download_feedback_service.h"
15 #include "chrome/common/time_format.h" 16 #include "chrome/common/time_format.h"
16 #include "content/public/browser/download_danger_type.h" 17 #include "content/public/browser/download_danger_type.h"
17 #include "content/public/browser/download_interrupt_reasons.h" 18 #include "content/public/browser/download_interrupt_reasons.h"
18 #include "content/public/browser/download_item.h" 19 #include "content/public/browser/download_item.h"
19 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/text/bytes_formatting.h" 23 #include "ui/base/text/bytes_formatting.h"
23 #include "ui/base/text/text_elider.h" 24 #include "ui/base/text/text_elider.h"
24 25
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // We shouldn't get any of these due to the IsDangerous() test above. 387 // We shouldn't get any of these due to the IsDangerous() test above.
387 NOTREACHED(); 388 NOTREACHED();
388 // Fallthrough. 389 // Fallthrough.
389 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: 390 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE:
390 return false; 391 return false;
391 } 392 }
392 NOTREACHED(); 393 NOTREACHED();
393 return false; 394 return false;
394 } 395 }
395 396
397 bool DownloadItemModel::ShouldAllowDownloadFeedback() const {
398 if (!IsDangerous())
399 return false;
400 return safe_browsing::DownloadFeedbackService::IsEnabledForDownload(
401 *download_);
402 }
403
396 bool DownloadItemModel::ShouldRemoveFromShelfWhenComplete() const { 404 bool DownloadItemModel::ShouldRemoveFromShelfWhenComplete() const {
397 // If the download was already opened automatically, it should be removed. 405 // If the download was already opened automatically, it should be removed.
398 if (download_->GetAutoOpened()) 406 if (download_->GetAutoOpened())
399 return true; 407 return true;
400 408
401 // If the download is interrupted or cancelled, it should not be removed. 409 // If the download is interrupted or cancelled, it should not be removed.
402 DownloadItem::DownloadState state = download_->GetState(); 410 DownloadItem::DownloadState state = download_->GetState();
403 if (state == DownloadItem::INTERRUPTED || state == DownloadItem::CANCELLED) 411 if (state == DownloadItem::INTERRUPTED || state == DownloadItem::CANCELLED)
404 return false; 412 return false;
405 413
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } 517 }
510 518
511 // In progress download with no known time left and non-zero completed bytes: 519 // In progress download with no known time left and non-zero completed bytes:
512 // "100/120 MB" or "100 MB" 520 // "100/120 MB" or "100 MB"
513 if (GetCompletedBytes() > 0) 521 if (GetCompletedBytes() > 0)
514 return size_ratio; 522 return size_ratio;
515 523
516 // Instead of displaying "0 B" we say "Starting..." 524 // Instead of displaying "0 B" we say "Starting..."
517 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); 525 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING);
518 } 526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698