OLD | NEW |
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/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cctype> | 8 #include <cctype> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <set> | 10 #include <set> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 exploded.millisecond); | 211 exploded.millisecond); |
212 } | 212 } |
213 | 213 |
214 scoped_ptr<base::DictionaryValue> DownloadItemToJSON( | 214 scoped_ptr<base::DictionaryValue> DownloadItemToJSON( |
215 DownloadItem* download_item, | 215 DownloadItem* download_item, |
216 bool incognito) { | 216 bool incognito) { |
217 base::DictionaryValue* json = new base::DictionaryValue(); | 217 base::DictionaryValue* json = new base::DictionaryValue(); |
218 json->SetBoolean(kExistsKey, !download_item->GetFileExternallyRemoved()); | 218 json->SetBoolean(kExistsKey, !download_item->GetFileExternallyRemoved()); |
219 json->SetInteger(kIdKey, download_item->GetId()); | 219 json->SetInteger(kIdKey, download_item->GetId()); |
220 const GURL& url = download_item->GetOriginalUrl(); | 220 const GURL& url = download_item->GetOriginalUrl(); |
221 json->SetString(kUrlKey, (url.is_valid() ? url.spec() : "")); | 221 json->SetString(kUrlKey, (url.is_valid() ? url.spec() : std::string())); |
222 json->SetString( | 222 json->SetString(kFilenameKey, |
223 kFilenameKey, download_item->GetFullPath().LossyDisplayName()); | 223 download_item->GetFullPath().LossyDisplayName()); |
224 json->SetString(kDangerKey, DangerString(download_item->GetDangerType())); | 224 json->SetString(kDangerKey, DangerString(download_item->GetDangerType())); |
225 if (download_item->GetDangerType() != | 225 if (download_item->GetDangerType() != |
226 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) | 226 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) |
227 json->SetBoolean(kDangerAcceptedKey, | 227 json->SetBoolean(kDangerAcceptedKey, |
228 download_item->GetDangerType() == | 228 download_item->GetDangerType() == |
229 content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED); | 229 content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED); |
230 json->SetString(kStateKey, StateString(download_item->GetState())); | 230 json->SetString(kStateKey, StateString(download_item->GetState())); |
231 json->SetBoolean(kPausedKey, download_item->IsPaused()); | 231 json->SetBoolean(kPausedKey, download_item->IsPaused()); |
232 json->SetString(kMimeKey, download_item->GetMimeType()); | 232 json->SetString(kMimeKey, download_item->GetMimeType()); |
233 json->SetString(kStartTimeKey, TimeToISO8601(download_item->GetStartTime())); | 233 json->SetString(kStartTimeKey, TimeToISO8601(download_item->GetStartTime())); |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 DownloadsNotificationSource notification_source; | 1444 DownloadsNotificationSource notification_source; |
1445 notification_source.event_name = event_name; | 1445 notification_source.event_name = event_name; |
1446 notification_source.profile = profile_; | 1446 notification_source.profile = profile_; |
1447 content::Source<DownloadsNotificationSource> content_source( | 1447 content::Source<DownloadsNotificationSource> content_source( |
1448 ¬ification_source); | 1448 ¬ification_source); |
1449 content::NotificationService::current()->Notify( | 1449 content::NotificationService::current()->Notify( |
1450 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, | 1450 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
1451 content_source, | 1451 content_source, |
1452 content::Details<std::string>(&json_args)); | 1452 content::Details<std::string>(&json_args)); |
1453 } | 1453 } |
OLD | NEW |