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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 json->SetString(kReferrerUrlKey, (referrer.is_valid() ? referrer.spec() | 251 json->SetString(kReferrerUrlKey, (referrer.is_valid() ? referrer.spec() |
252 : std::string())); | 252 : std::string())); |
253 json->SetString(kFilenameKey, | 253 json->SetString(kFilenameKey, |
254 download_item->GetTargetFilePath().LossyDisplayName()); | 254 download_item->GetTargetFilePath().LossyDisplayName()); |
255 json->SetString(kDangerKey, DangerString(download_item->GetDangerType())); | 255 json->SetString(kDangerKey, DangerString(download_item->GetDangerType())); |
256 json->SetString(kStateKey, StateString(download_item->GetState())); | 256 json->SetString(kStateKey, StateString(download_item->GetState())); |
257 json->SetBoolean(kCanResumeKey, download_item->CanResume()); | 257 json->SetBoolean(kCanResumeKey, download_item->CanResume()); |
258 json->SetBoolean(kPausedKey, download_item->IsPaused()); | 258 json->SetBoolean(kPausedKey, download_item->IsPaused()); |
259 json->SetString(kMimeKey, download_item->GetMimeType()); | 259 json->SetString(kMimeKey, download_item->GetMimeType()); |
260 json->SetString(kStartTimeKey, TimeToISO8601(download_item->GetStartTime())); | 260 json->SetString(kStartTimeKey, TimeToISO8601(download_item->GetStartTime())); |
261 json->SetInteger(kBytesReceivedKey, download_item->GetReceivedBytes()); | 261 json->SetDouble(kBytesReceivedKey, download_item->GetReceivedBytes()); |
262 json->SetInteger(kTotalBytesKey, download_item->GetTotalBytes()); | 262 json->SetDouble(kTotalBytesKey, download_item->GetTotalBytes()); |
263 json->SetBoolean(kIncognitoKey, profile->IsOffTheRecord()); | 263 json->SetBoolean(kIncognitoKey, profile->IsOffTheRecord()); |
264 if (download_item->GetState() == DownloadItem::INTERRUPTED) { | 264 if (download_item->GetState() == DownloadItem::INTERRUPTED) { |
265 json->SetString(kErrorKey, content::InterruptReasonDebugString( | 265 json->SetString(kErrorKey, content::InterruptReasonDebugString( |
266 download_item->GetLastReason())); | 266 download_item->GetLastReason())); |
267 } else if (download_item->GetState() == DownloadItem::CANCELLED) { | 267 } else if (download_item->GetState() == DownloadItem::CANCELLED) { |
268 json->SetString(kErrorKey, content::InterruptReasonDebugString( | 268 json->SetString(kErrorKey, content::InterruptReasonDebugString( |
269 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)); | 269 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)); |
270 } | 270 } |
271 if (!download_item->GetEndTime().is_null()) | 271 if (!download_item->GetEndTime().is_null()) |
272 json->SetString(kEndTimeKey, TimeToISO8601(download_item->GetEndTime())); | 272 json->SetString(kEndTimeKey, TimeToISO8601(download_item->GetEndTime())); |
(...skipping 10 matching lines...) Expand all Loading... |
283 // language. This won't work if the extension was uninstalled, so the name | 283 // language. This won't work if the extension was uninstalled, so the name |
284 // might be the wrong language. | 284 // might be the wrong language. |
285 bool include_disabled = true; | 285 bool include_disabled = true; |
286 const extensions::Extension* extension = extensions::ExtensionSystem::Get( | 286 const extensions::Extension* extension = extensions::ExtensionSystem::Get( |
287 profile)->extension_service()->GetExtensionById( | 287 profile)->extension_service()->GetExtensionById( |
288 by_ext->id(), include_disabled); | 288 by_ext->id(), include_disabled); |
289 if (extension) | 289 if (extension) |
290 json->SetString(kByExtensionNameKey, extension->name()); | 290 json->SetString(kByExtensionNameKey, extension->name()); |
291 } | 291 } |
292 // TODO(benjhayden): Implement fileSize. | 292 // TODO(benjhayden): Implement fileSize. |
293 json->SetInteger(kFileSizeKey, download_item->GetTotalBytes()); | 293 json->SetDouble(kFileSizeKey, download_item->GetTotalBytes()); |
294 return scoped_ptr<base::DictionaryValue>(json); | 294 return scoped_ptr<base::DictionaryValue>(json); |
295 } | 295 } |
296 | 296 |
297 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor { | 297 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor { |
298 public: | 298 public: |
299 DownloadFileIconExtractorImpl() {} | 299 DownloadFileIconExtractorImpl() {} |
300 | 300 |
301 virtual ~DownloadFileIconExtractorImpl() {} | 301 virtual ~DownloadFileIconExtractorImpl() {} |
302 | 302 |
303 virtual bool ExtractIconURLForPath(const base::FilePath& path, | 303 virtual bool ExtractIconURLForPath(const base::FilePath& path, |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 extensions::UnloadedExtensionInfo* unloaded = | 1904 extensions::UnloadedExtensionInfo* unloaded = |
1905 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 1905 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); |
1906 std::set<const extensions::Extension*>::iterator iter = | 1906 std::set<const extensions::Extension*>::iterator iter = |
1907 shelf_disabling_extensions_.find(unloaded->extension); | 1907 shelf_disabling_extensions_.find(unloaded->extension); |
1908 if (iter != shelf_disabling_extensions_.end()) | 1908 if (iter != shelf_disabling_extensions_.end()) |
1909 shelf_disabling_extensions_.erase(iter); | 1909 shelf_disabling_extensions_.erase(iter); |
1910 break; | 1910 break; |
1911 } | 1911 } |
1912 } | 1912 } |
1913 } | 1913 } |
OLD | NEW |