summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 17:24:38 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 17:24:38 +0000
commita62d42908f4fcb66a60808025435ecd67b89cf0a (patch)
treeeefa595673e6ddc566f0b2078352b005e35561c9 /content
parent3d0824177f14eba2dbc775dc35ea9c5a5cac1f0f (diff)
downloadchromium_src-a62d42908f4fcb66a60808025435ecd67b89cf0a.zip
chromium_src-a62d42908f4fcb66a60808025435ecd67b89cf0a.tar.gz
chromium_src-a62d42908f4fcb66a60808025435ecd67b89cf0a.tar.bz2
Move DownloadDangerType to its own file.
BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9141031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118852 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/download/download_create_info.cc4
-rw-r--r--content/browser/download/download_create_info.h4
-rw-r--r--content/browser/download/download_item_impl.cc31
-rw-r--r--content/browser/download/download_item_impl.h4
-rw-r--r--content/browser/download/download_manager_impl.cc9
-rw-r--r--content/browser/download/download_query.cc13
-rw-r--r--content/browser/download/download_query.h2
-rw-r--r--content/browser/download/download_query_unittest.cc15
-rw-r--r--content/browser/download/download_state_info.cc21
-rw-r--r--content/browser/download/download_state_info.h33
-rw-r--r--content/browser/download/mock_download_item.h4
-rw-r--r--content/content_browser.gypi1
-rw-r--r--content/public/browser/download_danger_type.h39
-rw-r--r--content/public/browser/download_item.h7
14 files changed, 100 insertions, 87 deletions
diff --git a/content/browser/download/download_create_info.cc b/content/browser/download/download_create_info.cc
index afd95a7..fbcd175 100644
--- a/content/browser/download/download_create_info.cc
+++ b/content/browser/download/download_create_info.cc
@@ -20,7 +20,6 @@ DownloadCreateInfo::DownloadCreateInfo(const FilePath& path,
content::PageTransition transition_type)
: path(path),
url_chain(1, url),
- path_uniquifier(0),
start_time(start_time),
received_bytes(received_bytes),
total_bytes(total_bytes),
@@ -33,8 +32,7 @@ DownloadCreateInfo::DownloadCreateInfo(const FilePath& path,
}
DownloadCreateInfo::DownloadCreateInfo()
- : path_uniquifier(0),
- received_bytes(0),
+ : received_bytes(0),
total_bytes(0),
state(-1),
download_id(DownloadId::Invalid()),
diff --git a/content/browser/download/download_create_info.h b/content/browser/download/download_create_info.h
index 90f9160..9be00c1 100644
--- a/content/browser/download/download_create_info.h
+++ b/content/browser/download/download_create_info.h
@@ -50,10 +50,6 @@ struct CONTENT_EXPORT DownloadCreateInfo {
// The URL that referred us.
GURL referrer_url;
- // A number that should be added to the suggested path to make it unique.
- // 0 means no number should be appended. Not actually stored in the db.
- int path_uniquifier;
-
// The time when the download started.
base::Time start_time;
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index 505fea3..cc48515 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -34,6 +34,7 @@ using content::BrowserThread;
using content::DownloadFile;
using content::DownloadItem;
using content::DownloadManager;
+using content::WebContents;
// A DownloadItem normally goes through the following states:
// * Created (when download starts)
@@ -201,8 +202,7 @@ DownloadItemImpl::DownloadItemImpl(
bool is_otr)
: state_info_(info.original_name, info.save_info.file_path,
info.has_user_gesture, info.transition_type,
- info.prompt_user_for_save_location, info.path_uniquifier,
- DownloadStateInfo::NOT_DANGEROUS),
+ info.prompt_user_for_save_location),
request_handle_(request_handle),
download_id_(info.download_id),
full_path_(info.path),
@@ -360,7 +360,7 @@ void DownloadItemImpl::DangerousDownloadValidated() {
UMA_HISTOGRAM_ENUMERATION("Download.DangerousDownloadValidated",
GetDangerType(),
- DownloadStateInfo::DANGEROUS_TYPE_MAX);
+ content::DOWNLOAD_DANGER_TYPE_MAX);
safety_state_ = DANGEROUS_BUT_VALIDATED;
UpdateObservers();
@@ -547,12 +547,14 @@ void DownloadItemImpl::Delete(DeleteReason reason) {
switch (reason) {
case DELETE_DUE_TO_USER_DISCARD:
- UMA_HISTOGRAM_ENUMERATION("Download.UserDiscard", GetDangerType(),
- DownloadStateInfo::DANGEROUS_TYPE_MAX);
+ UMA_HISTOGRAM_ENUMERATION(
+ "Download.UserDiscard", GetDangerType(),
+ content::DOWNLOAD_DANGER_TYPE_MAX);
break;
case DELETE_DUE_TO_BROWSER_SHUTDOWN:
- UMA_HISTOGRAM_ENUMERATION("Download.Discard", GetDangerType(),
- DownloadStateInfo::DANGEROUS_TYPE_MAX);
+ UMA_HISTOGRAM_ENUMERATION(
+ "Download.Discard", GetDangerType(),
+ content::DOWNLOAD_DANGER_TYPE_MAX);
break;
default:
NOTREACHED();
@@ -651,8 +653,9 @@ void DownloadItemImpl::OnDownloadCompleting(DownloadFileManager* file_manager) {
// If we prompted the user for save location, then we should overwrite the
// target. Otherwise, if the danger state was NOT_DANGEROUS, we already
// uniquified the path and should overwrite.
- bool should_overwrite = (PromptUserForSaveLocation() ||
- GetDangerType() == DownloadStateInfo::NOT_DANGEROUS);
+ bool should_overwrite =
+ (PromptUserForSaveLocation() ||
+ GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
if (NeedsRename()) {
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&DownloadFileManager::RenameCompletingDownloadFile,
@@ -725,7 +728,7 @@ void DownloadItemImpl::SetFileCheckResults(const DownloadStateInfo& state) {
UpdateSafetyState();
}
-DownloadStateInfo::DangerType DownloadItemImpl::GetDangerType() const {
+content::DownloadDangerType DownloadItemImpl::GetDangerType() const {
return state_info_.danger;
}
@@ -736,21 +739,21 @@ bool DownloadItemImpl::IsDangerous() const {
void DownloadItemImpl::MarkFileDangerous() {
// TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- state_info_.danger = DownloadStateInfo::DANGEROUS_FILE;
+ state_info_.danger = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
UpdateSafetyState();
}
void DownloadItemImpl::MarkUrlDangerous() {
// TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- state_info_.danger = DownloadStateInfo::DANGEROUS_URL;
+ state_info_.danger = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL;
UpdateSafetyState();
}
void DownloadItemImpl::MarkContentDangerous() {
// TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- state_info_.danger = DownloadStateInfo::DANGEROUS_CONTENT;
+ state_info_.danger = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT;
UpdateSafetyState();
}
@@ -767,7 +770,7 @@ DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
GetOpened());
}
-TabContents* DownloadItemImpl::GetTabContents() const {
+WebContents* DownloadItemImpl::GetWebContents() const {
// TODO(rdsmith): Remove null check after removing GetTabContents() from
// paths that might be used by DownloadItems created from history import.
// Currently such items have null request_handle_s, where other items
diff --git a/content/browser/download/download_item_impl.h b/content/browser/download/download_item_impl.h
index dca9c0f..87c7d31 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -171,7 +171,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
virtual void SetOpenWhenComplete(bool open) OVERRIDE;
virtual bool GetFileExternallyRemoved() const OVERRIDE;
virtual SafetyState GetSafetyState() const OVERRIDE;
- virtual DownloadStateInfo::DangerType GetDangerType() const OVERRIDE;
+ virtual content::DownloadDangerType GetDangerType() const OVERRIDE;
virtual bool IsDangerous() const OVERRIDE;
virtual void MarkFileDangerous() OVERRIDE;
virtual void MarkUrlDangerous() OVERRIDE;
@@ -190,7 +190,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const OVERRIDE;
virtual DownloadStateInfo GetStateInfo() const OVERRIDE;
virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
- virtual TabContents* GetTabContents() const OVERRIDE;
+ virtual content::WebContents* GetWebContents() const OVERRIDE;
virtual FilePath GetTargetFilePath() const OVERRIDE;
virtual FilePath GetFileNameToReportUser() const OVERRIDE;
virtual FilePath GetUserVerifiedFilePath() const OVERRIDE;
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 82c61e3..d391e56 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -334,7 +334,7 @@ void DownloadManagerImpl::RestartDownload(int32 download_id) {
if (download->PromptUserForSaveLocation()) {
// We must ask the user for the place to put the download.
- WebContents* contents = download->GetTabContents();
+ WebContents* contents = download->GetWebContents();
// |id_ptr| will be deleted in either FileSelected() or
// FileSelectionCancelled().
@@ -344,7 +344,8 @@ void DownloadManagerImpl::RestartDownload(int32 download_id) {
// If |download| is a potentially dangerous file, then |suggested_path|
// contains the intermediate name instead of the final download
// filename. The latter is GetTargetName().
- if (download->GetDangerType() != DownloadStateInfo::NOT_DANGEROUS)
+ if (download->GetDangerType() !=
+ content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)
target_path = suggested_path.DirName().Append(download->GetTargetName());
else
target_path = suggested_path;
@@ -600,7 +601,7 @@ void DownloadManagerImpl::OnDownloadRenamedToFinalName(
if (!item)
return;
- if (item->GetDangerType() == DownloadStateInfo::NOT_DANGEROUS ||
+ if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS ||
item->PromptUserForSaveLocation()) {
DCHECK_EQ(0, uniquifier)
<< "We should not uniquify user supplied filenames or safe filenames "
@@ -1011,7 +1012,7 @@ void DownloadManagerImpl::OnDownloadItemAddedToPersistentStore(
void DownloadManagerImpl::ShowDownloadInBrowser(DownloadItem* download) {
// The 'contents' may no longer exist if the user closed the tab before we
// get this start completion event.
- WebContents* content = download->GetTabContents();
+ WebContents* content = download->GetWebContents();
// If the contents no longer exists, we ask the embedder to suggest another
// tab.
diff --git a/content/browser/download/download_query.cc b/content/browser/download/download_query.cc
index 74e7470..cc14b18a 100644
--- a/content/browser/download/download_query.cc
+++ b/content/browser/download/download_query.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
@@ -22,6 +23,7 @@
#include "googleurl/src/gurl.h"
#include "unicode/regex.h"
+using content::DownloadDangerType;
using content::DownloadItem;
namespace {
@@ -74,7 +76,7 @@ static DownloadItem::DownloadState GetState(const DownloadItem& item) {
return item.GetState();
}
-static DownloadStateInfo::DangerType GetDangerType(const DownloadItem& item) {
+static DownloadDangerType GetDangerType(const DownloadItem& item) {
return item.GetDangerType();
}
@@ -208,10 +210,9 @@ void DownloadQuery::AddFilter(DownloadItem::DownloadState state) {
InnerCallback<DownloadItem::DownloadState>(base::Bind(&GetState))));
}
-void DownloadQuery::AddFilter(DownloadStateInfo::DangerType danger) {
- AddFilter(base::Bind(&FieldMatches<DownloadStateInfo::DangerType>, danger, EQ,
- InnerCallback<DownloadStateInfo::DangerType>(base::Bind(
- &GetDangerType))));
+void DownloadQuery::AddFilter(DownloadDangerType danger) {
+ AddFilter(base::Bind(&FieldMatches<DownloadDangerType>, danger, EQ,
+ InnerCallback<content::DownloadDangerType>(base::Bind(&GetDangerType))));
}
bool DownloadQuery::AddFilter(DownloadQuery::FilterType type,
@@ -339,7 +340,7 @@ void DownloadQuery::AddSorter(DownloadQuery::SortType type,
sorters_.push_back(Sorter::Build<string16>(direction, &GetFilename));
break;
case SORT_DANGER:
- sorters_.push_back(Sorter::Build<DownloadStateInfo::DangerType>(
+ sorters_.push_back(Sorter::Build<DownloadDangerType>(
direction, &GetDangerType));
break;
case SORT_DANGER_ACCEPTED:
diff --git a/content/browser/download/download_query.h b/content/browser/download/download_query.h
index 22c026d..a9f718d 100644
--- a/content/browser/download/download_query.h
+++ b/content/browser/download/download_query.h
@@ -98,7 +98,7 @@ class CONTENT_EXPORT DownloadQuery {
// filter out all items.
bool AddFilter(const FilterCallback& filter);
bool AddFilter(FilterType type, const base::Value& value);
- void AddFilter(DownloadStateInfo::DangerType danger);
+ void AddFilter(content::DownloadDangerType danger);
void AddFilter(content::DownloadItem::DownloadState state);
// Adds a new sorter of type |type| with direction |direction|. After
diff --git a/content/browser/download/download_query_unittest.cc b/content/browser/download/download_query_unittest.cc
index 26eba38..60687ed 100644
--- a/content/browser/download/download_query_unittest.cc
+++ b/content/browser/download/download_query_unittest.cc
@@ -193,8 +193,8 @@ TEST_F(DownloadQueryTest, DownloadQueryAllFilters) {
17, DownloadItem::CANCELLED,
DownloadItem::IN_PROGRESS)));
EXPECT_CALL(mock(i), GetDangerType()).WillRepeatedly(Return(SWITCH2(i,
- 18, DownloadStateInfo::DANGEROUS_FILE,
- DownloadStateInfo::NOT_DANGEROUS)));
+ 18, content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE,
+ content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)));
}
for (size_t i = 0; i < kNumItems; ++i) {
switch (i) {
@@ -223,7 +223,8 @@ TEST_F(DownloadQueryTest, DownloadQueryAllFilters) {
match_url.spec().c_str()); break;
case 16: CHECK(query()->AddFilter(base::Bind(&IdNotEqual, 16))); break;
case 17: query()->AddFilter(DownloadItem::IN_PROGRESS); break;
- case 18: query()->AddFilter(DownloadStateInfo::NOT_DANGEROUS); break;
+ case 18: query()->AddFilter(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
+ break;
default: NOTREACHED(); break;
}
Search();
@@ -254,15 +255,15 @@ TEST_F(DownloadQueryTest, DownloadQuerySortBytesReceived) {
TEST_F(DownloadQueryTest, DownloadQuerySortDanger) {
CreateMocks(2);
EXPECT_CALL(mock(0), GetDangerType()).WillRepeatedly(Return(
- DownloadStateInfo::DANGEROUS_FILE));
+ content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE));
EXPECT_CALL(mock(1), GetDangerType()).WillRepeatedly(Return(
- DownloadStateInfo::NOT_DANGEROUS));
+ content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS));
query()->AddSorter(
DownloadQuery::SORT_DANGER, DownloadQuery::ASCENDING);
Search();
- EXPECT_EQ(DownloadStateInfo::NOT_DANGEROUS,
+ EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
results()->at(0)->GetDangerType());
- EXPECT_EQ(DownloadStateInfo::DANGEROUS_FILE,
+ EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE,
results()->at(1)->GetDangerType());
}
diff --git a/content/browser/download/download_state_info.cc b/content/browser/download/download_state_info.cc
index 832753d..dd26812 100644
--- a/content/browser/download/download_state_info.cc
+++ b/content/browser/download/download_state_info.cc
@@ -11,7 +11,7 @@ DownloadStateInfo::DownloadStateInfo()
has_user_gesture(false),
transition_type(content::PAGE_TRANSITION_LINK),
prompt_user_for_save_location(false),
- danger(NOT_DANGEROUS) {
+ danger(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
}
DownloadStateInfo::DownloadStateInfo(
@@ -21,7 +21,7 @@ DownloadStateInfo::DownloadStateInfo(
has_user_gesture(has_user_gesture),
transition_type(content::PAGE_TRANSITION_LINK),
prompt_user_for_save_location(prompt_user_for_save_location),
- danger(NOT_DANGEROUS) {
+ danger(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
}
DownloadStateInfo::DownloadStateInfo(
@@ -29,15 +29,13 @@ DownloadStateInfo::DownloadStateInfo(
const FilePath& forced_name,
bool has_user_gesture,
content::PageTransition transition_type,
- bool prompt_user_for_save_location,
- int uniquifier,
- DangerType danger_type)
+ bool prompt_user_for_save_location)
: target_name(target),
- path_uniquifier(uniquifier),
+ path_uniquifier(0),
has_user_gesture(has_user_gesture),
transition_type(transition_type),
prompt_user_for_save_location(prompt_user_for_save_location),
- danger(danger_type),
+ danger(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
force_file_name(forced_name) {
}
@@ -45,10 +43,11 @@ bool DownloadStateInfo::IsDangerous() const {
// TODO(noelutz): At this point only the windows views UI supports
// warnings based on dangerous content.
#ifdef OS_WIN
- return (danger == DANGEROUS_FILE ||
- danger == DANGEROUS_URL ||
- danger == DANGEROUS_CONTENT);
+ return (danger == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
+ danger == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
+ danger == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT);
#else
- return (danger == DANGEROUS_FILE || danger == DANGEROUS_URL);
+ return (danger == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
+ danger == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
#endif
}
diff --git a/content/browser/download/download_state_info.h b/content/browser/download/download_state_info.h
index a59d7c78..09318dc 100644
--- a/content/browser/download/download_state_info.h
+++ b/content/browser/download/download_state_info.h
@@ -8,37 +8,12 @@
#include "base/file_path.h"
#include "content/common/content_export.h"
+#include "content/public/browser/download_danger_type.h"
#include "content/public/common/page_transition_types.h"
// Contains information relating to the process of determining what to do with
// the download.
struct DownloadStateInfo {
- // This enum is also used by histograms. Do not change the ordering or remove
- // items.
- enum DangerType {
- // The download is safe.
- NOT_DANGEROUS = 0,
-
- // A dangerous file to the system (e.g.: a pdf or extension from
- // places other than gallery).
- DANGEROUS_FILE,
-
- // Safebrowsing download service shows this URL leads to malicious file
- // download.
- DANGEROUS_URL,
-
- // SafeBrowsing download service shows this file content as being malicious.
- DANGEROUS_CONTENT,
-
- // The content of this download may be malicious (e.g., extension is exe but
- // SafeBrowsing has not finished checking the content).
- MAYBE_DANGEROUS_CONTENT,
-
- // Memory space for histograms is determined by the max.
- // ALWAYS ADD NEW VALUES BEFORE THIS ONE.
- DANGEROUS_TYPE_MAX
- };
-
DownloadStateInfo();
DownloadStateInfo(bool has_user_gesture,
bool prompt_user_for_save_location);
@@ -46,9 +21,7 @@ struct DownloadStateInfo {
const FilePath& forced_name,
bool has_user_gesture,
content::PageTransition transition_type,
- bool prompt_user_for_save_location,
- int uniquifier,
- DangerType danger);
+ bool prompt_user_for_save_location);
// Indicates if the download is dangerous.
CONTENT_EXPORT bool IsDangerous() const;
@@ -75,7 +48,7 @@ struct DownloadStateInfo {
// default location.
bool prompt_user_for_save_location;
- DangerType danger;
+ content::DownloadDangerType danger;
// True if this download's file name was specified initially.
FilePath force_file_name;
diff --git a/content/browser/download/mock_download_item.h b/content/browser/download/mock_download_item.h
index 7b3f429..42d25b8 100644
--- a/content/browser/download/mock_download_item.h
+++ b/content/browser/download/mock_download_item.h
@@ -84,7 +84,7 @@ class MockDownloadItem : public content::DownloadItem {
MOCK_METHOD1(SetOpenWhenComplete, void(bool));
MOCK_CONST_METHOD0(GetFileExternallyRemoved, bool());
MOCK_CONST_METHOD0(GetSafetyState, SafetyState());
- MOCK_CONST_METHOD0(GetDangerType, DownloadStateInfo::DangerType());
+ MOCK_CONST_METHOD0(GetDangerType, content::DownloadDangerType());
MOCK_CONST_METHOD0(IsDangerous, bool());
MOCK_METHOD0(MarkFileDangerous, void());
MOCK_METHOD0(MarkUrlDangerous, void());
@@ -103,7 +103,7 @@ class MockDownloadItem : public content::DownloadItem {
MOCK_CONST_METHOD0(GetPersistentStoreInfo, DownloadPersistentStoreInfo());
MOCK_CONST_METHOD0(GetStateInfo, DownloadStateInfo());
MOCK_CONST_METHOD0(GetBrowserContext, content::BrowserContext*());
- MOCK_CONST_METHOD0(GetTabContents, TabContents*());
+ MOCK_CONST_METHOD0(GetWebContents, content::WebContents*());
MOCK_CONST_METHOD0(GetTargetFilePath, FilePath());
MOCK_CONST_METHOD0(GetFileNameToReportUser, FilePath());
MOCK_CONST_METHOD0(GetUserVerifiedFilePath, FilePath());
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index e4d73c3..8f6d40f 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -43,6 +43,7 @@
'public/browser/content_ipc_logging.h',
'public/browser/devtools_agent_host_registry.h',
'public/browser/devtools_client_host.h',
+ 'public/browser/download_danger_type.h',
'public/browser/devtools_frontend_host_delegate.h',
'public/browser/devtools_http_handler.h',
'public/browser/devtools_http_handler_delegate.h',
diff --git a/content/public/browser/download_danger_type.h b/content/public/browser/download_danger_type.h
new file mode 100644
index 0000000..2c8ba88
--- /dev/null
+++ b/content/public/browser/download_danger_type.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_DANGER_TYPE_H_
+#define CONTENT_PUBLIC_BROWSER_DOWNLOAD_DANGER_TYPE_H_
+#pragma once
+
+namespace content {
+
+// This enum is also used by histograms. Do not change the ordering or remove
+// items.
+enum DownloadDangerType {
+ // The download is safe.
+ DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS = 0,
+
+ // A dangerous file to the system (e.g.: a pdf or extension from
+ // places other than gallery).
+ DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE,
+
+ // Safebrowsing download service shows this URL leads to malicious file
+ // download.
+ DOWNLOAD_DANGER_TYPE_DANGEROUS_URL,
+
+ // SafeBrowsing download service shows this file content as being malicious.
+ DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT,
+
+ // The content of this download may be malicious (e.g., extension is exe but
+ // SafeBrowsing has not finished checking the content).
+ DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT,
+
+ // Memory space for histograms is determined by the max.
+ // ALWAYS ADD NEW VALUES BEFORE THIS ONE.
+ DOWNLOAD_DANGER_TYPE_MAX
+};
+
+}
+
+#endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_DANGER_TYPE_H_
diff --git a/content/public/browser/download_item.h b/content/public/browser/download_item.h
index 0d194842..453d37f 100644
--- a/content/public/browser/download_item.h
+++ b/content/public/browser/download_item.h
@@ -24,12 +24,12 @@
#include "base/string16.h"
#include "content/browser/download/download_state_info.h"
#include "content/browser/download/interrupt_reasons.h"
+#include "content/public/browser/download_danger_type.h"
class DownloadId;
class DownloadFileManager;
class FilePath;
class GURL;
-class TabContents;
struct DownloadCreateInfo;
struct DownloadPersistentStoreInfo;
@@ -42,6 +42,7 @@ namespace content {
class BrowserContext;
class DownloadManager;
+class WebContents;
// One DownloadItem per download. This is the model class that stores all the
// state for a download. Multiple views, such as a tab's download shelf and the
@@ -281,7 +282,7 @@ class CONTENT_EXPORT DownloadItem {
virtual bool GetFileExternallyRemoved() const = 0;
virtual SafetyState GetSafetyState() const = 0;
// Why |safety_state_| is not SAFE.
- virtual DownloadStateInfo::DangerType GetDangerType() const = 0;
+ virtual DownloadDangerType GetDangerType() const = 0;
virtual bool IsDangerous() const = 0;
virtual void MarkContentDangerous() = 0;
virtual void MarkFileDangerous() = 0;
@@ -303,7 +304,7 @@ class CONTENT_EXPORT DownloadItem {
virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0;
virtual DownloadStateInfo GetStateInfo() const = 0;
virtual BrowserContext* GetBrowserContext() const = 0;
- virtual TabContents* GetTabContents() const = 0;
+ virtual WebContents* GetWebContents() const = 0;
// Returns the final target file path for the download.
virtual FilePath GetTargetFilePath() const = 0;