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

Unified Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 1706193002: Expose final download URL (actual url after redirects) in the extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/downloads/downloads_api.cc
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index 0a297d2116bd4a67bd2bed82ea1b9fbfa9a1556f..4f62857c4596830e4bf2a0482820d49bbef795fe 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -172,6 +172,8 @@ const char kTotalBytesKey[] = "totalBytes";
const char kTotalBytesLessKey[] = "totalBytesLess";
const char kUrlKey[] = "url";
const char kUrlRegexKey[] = "urlRegex";
+const char kFinalUrlKey[] = "finalUrl";
+const char kFinalUrlRegexKey[] = "finalUrlRegex";
// Note: Any change to the danger type strings, should be accompanied by a
// corresponding change to downloads.json.
@@ -253,6 +255,9 @@ scoped_ptr<base::DictionaryValue> DownloadItemToJSON(
json->SetInteger(kIdKey, download_item->GetId());
const GURL& url = download_item->GetOriginalUrl();
json->SetString(kUrlKey, (url.is_valid() ? url.spec() : std::string()));
+ const GURL& finalUrl = download_item->GetURL();
+ json->SetString(kFinalUrlKey,
+ (finalUrl.is_valid() ? finalUrl.spec() : std::string()));
const GURL& referrer = download_item->GetReferrerUrl();
json->SetString(kReferrerUrlKey, (referrer.is_valid() ? referrer.spec()
: std::string()));
@@ -376,6 +381,8 @@ void InitFilterTypeMap(FilterTypeMap* filter_types_ptr) {
filter_types[kTotalBytesLessKey] = DownloadQuery::FILTER_TOTAL_BYTES_LESS;
filter_types[kUrlKey] = DownloadQuery::FILTER_URL;
filter_types[kUrlRegexKey] = DownloadQuery::FILTER_URL_REGEX;
+ filter_types[kFinalUrlKey] = DownloadQuery::FILTER_FINAL_URL;
+ filter_types[kFinalUrlRegexKey] = DownloadQuery::FILTER_FINAL_URL_REGEX;
}
typedef base::hash_map<std::string, DownloadQuery::SortType> SortTypeMap;
@@ -393,6 +400,7 @@ void InitSortTypeMap(SortTypeMap* sorter_types_ptr) {
sorter_types[kStateKey] = DownloadQuery::SORT_STATE;
sorter_types[kTotalBytesKey] = DownloadQuery::SORT_TOTAL_BYTES;
sorter_types[kUrlKey] = DownloadQuery::SORT_URL;
+ sorter_types[kFinalUrlKey] = DownloadQuery::SORT_FINAL_URL;
}
bool IsNotTemporaryDownloadFilter(const DownloadItem& download_item) {
@@ -905,6 +913,7 @@ bool InvalidId(DownloadItem* valid_item, std::string* message_out) {
bool IsDownloadDeltaField(const std::string& field) {
return ((field == kUrlKey) ||
+ (field == kFinalUrlKey) ||
(field == kFilenameKey) ||
(field == kDangerKey) ||
(field == kMimeKey) ||

Powered by Google App Engine
This is Rietveld 408576698