summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/history')
-rw-r--r--chrome/browser/history/download_database.cc14
-rw-r--r--chrome/browser/history/download_database.h3
-rw-r--r--chrome/browser/history/download_types.h7
-rw-r--r--chrome/browser/history/history.cc6
-rw-r--r--chrome/browser/history/history.h4
-rw-r--r--chrome/browser/history/history_backend.cc7
-rw-r--r--chrome/browser/history/history_backend.h1
7 files changed, 41 insertions, 1 deletions
diff --git a/chrome/browser/history/download_database.cc b/chrome/browser/history/download_database.cc
index 1baf976..e604e5d 100644
--- a/chrome/browser/history/download_database.cc
+++ b/chrome/browser/history/download_database.cc
@@ -93,6 +93,20 @@ bool DownloadDatabase::UpdateDownload(int64 received_bytes,
return statement->step() == SQLITE_DONE;
}
+bool DownloadDatabase::UpdateDownloadPath(const std::wstring& path,
+ DownloadID db_handle) {
+ DCHECK(db_handle > 0);
+ SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(),
+ "UPDATE downloads "
+ "SET full_path=? WHERE id=?");
+ if (!statement.is_valid())
+ return false;
+
+ statement->bind_wstring(0, path);
+ statement->bind_int64(1, db_handle);
+ return statement->step() == SQLITE_DONE;
+}
+
int64 DownloadDatabase::CreateDownload(const DownloadCreateInfo& info) {
SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(),
"INSERT INTO downloads "
diff --git a/chrome/browser/history/download_database.h b/chrome/browser/history/download_database.h
index 1fc9812..d733546 100644
--- a/chrome/browser/history/download_database.h
+++ b/chrome/browser/history/download_database.h
@@ -27,6 +27,9 @@ class DownloadDatabase {
// Update the state of one download. Returns true if successful.
bool UpdateDownload(int64 received_bytes, int32 state, DownloadID db_handle);
+ // Update the path of one download. Returns true if successful.
+ bool UpdateDownloadPath(const std::wstring& path, DownloadID db_handle);
+
// Create a new database entry for one download and return its primary db id.
int64 CreateDownload(const DownloadCreateInfo& info);
diff --git a/chrome/browser/history/download_types.h b/chrome/browser/history/download_types.h
index 16f3ad7..5b6e5b4 100644
--- a/chrome/browser/history/download_types.h
+++ b/chrome/browser/history/download_types.h
@@ -37,7 +37,8 @@ struct DownloadCreateInfo {
render_view_id(-1),
request_id(-1),
db_handle(0),
- save_as(false) {
+ save_as(false),
+ is_dangerous(false) {
}
DownloadCreateInfo() : download_id(-1) {}
@@ -59,6 +60,10 @@ struct DownloadCreateInfo {
std::string content_disposition;
std::string mime_type;
bool save_as;
+ // Whether this download is potentially dangerous (ex: exe, dll, ...).
+ bool is_dangerous;
+ // The original name for a dangerous download.
+ std::wstring original_name;
};
#endif // CHROME_BROWSER_DOWNLOAD_TYPES_H__
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index db04446..92bea22 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -469,6 +469,12 @@ void HistoryService::UpdateDownload(int64 received_bytes,
received_bytes, state, db_handle);
}
+void HistoryService::UpdateDownloadPath(const std::wstring& path,
+ int64 db_handle) {
+ ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownloadPath,
+ path, db_handle);
+}
+
void HistoryService::RemoveDownload(int64 db_handle) {
ScheduleAndForget(PRIORITY_NORMAL,
&HistoryBackend::RemoveDownload, db_handle);
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 74ef67b..2aee029 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -421,6 +421,10 @@ class HistoryService : public CancelableRequestProvider,
// the database with no need for a callback.
void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle);
+ // Called to update the history service about the path of a download.
+ // This is a 'fire and forget' query.
+ void UpdateDownloadPath(const std::wstring& path, int64 db_handle);
+
// Permanently remove a download from the history system. This is a 'fire and
// forget' operation.
void RemoveDownload(int64 db_handle);
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index 21f77fb..f8e6449 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -934,6 +934,13 @@ void HistoryBackend::UpdateDownload(int64 received_bytes,
db_->UpdateDownload(received_bytes, state, db_handle);
}
+// Update the path of a particular download entry.
+void HistoryBackend::UpdateDownloadPath(const std::wstring& path,
+ int64 db_handle) {
+ if (db_.get())
+ db_->UpdateDownloadPath(path, db_handle);
+}
+
// Create a new download entry and pass back the db_handle to it.
void HistoryBackend::CreateDownload(
scoped_refptr<DownloadCreateRequest> request,
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index dd37c3e..e646570 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -193,6 +193,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
void QueryDownloads(scoped_refptr<DownloadQueryRequest> request);
void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle);
+ void UpdateDownloadPath(const std::wstring& path, int64 db_handle);
void CreateDownload(scoped_refptr<DownloadCreateRequest> request,
const DownloadCreateInfo& info);
void RemoveDownload(int64 db_handle);