| 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/download/download_extension_api.h" | 5 #include "chrome/browser/download/download_extension_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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/download/download_util.h" | 32 #include "chrome/browser/download/download_util.h" |
| 33 #include "chrome/browser/extensions/extension_event_names.h" | 33 #include "chrome/browser/extensions/extension_event_names.h" |
| 34 #include "chrome/browser/extensions/extension_event_router.h" | 34 #include "chrome/browser/extensions/extension_event_router.h" |
| 35 #include "chrome/browser/icon_loader.h" | 35 #include "chrome/browser/icon_loader.h" |
| 36 #include "chrome/browser/icon_manager.h" | 36 #include "chrome/browser/icon_manager.h" |
| 37 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 37 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 38 #include "chrome/browser/ui/browser_list.h" | 38 #include "chrome/browser/ui/browser_list.h" |
| 39 #include "chrome/browser/ui/webui/web_ui_util.h" | 39 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 40 #include "content/browser/download/download_state_info.h" | 40 #include "content/browser/download/download_state_info.h" |
| 41 #include "content/browser/download/download_types.h" | 41 #include "content/browser/download/download_types.h" |
| 42 #include "content/browser/download/interrupt_reasons.h" | |
| 43 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 42 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 43 #include "content/public/browser/download_interrupt_reasons.h" |
| 44 #include "content/public/browser/download_item.h" | 44 #include "content/public/browser/download_item.h" |
| 45 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
| 46 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
| 47 #include "net/base/load_flags.h" | 47 #include "net/base/load_flags.h" |
| 48 #include "net/http/http_util.h" | 48 #include "net/http/http_util.h" |
| 49 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
| 50 | 50 |
| 51 using content::BrowserThread; | 51 using content::BrowserThread; |
| 52 using content::DownloadId; | 52 using content::DownloadId; |
| 53 using content::DownloadItem; | 53 using content::DownloadItem; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (item->GetDangerType() != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) | 181 if (item->GetDangerType() != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) |
| 182 json->SetBoolean(kDangerAcceptedKey, | 182 json->SetBoolean(kDangerAcceptedKey, |
| 183 item->GetSafetyState() == DownloadItem::DANGEROUS_BUT_VALIDATED); | 183 item->GetSafetyState() == DownloadItem::DANGEROUS_BUT_VALIDATED); |
| 184 json->SetString(kStateKey, StateString(item->GetState())); | 184 json->SetString(kStateKey, StateString(item->GetState())); |
| 185 json->SetBoolean(kPausedKey, item->IsPaused()); | 185 json->SetBoolean(kPausedKey, item->IsPaused()); |
| 186 json->SetString(kMimeKey, item->GetMimeType()); | 186 json->SetString(kMimeKey, item->GetMimeType()); |
| 187 json->SetInteger(kStartTimeKey, | 187 json->SetInteger(kStartTimeKey, |
| 188 (item->GetStartTime() - base::Time::UnixEpoch()).InMilliseconds()); | 188 (item->GetStartTime() - base::Time::UnixEpoch()).InMilliseconds()); |
| 189 json->SetInteger(kBytesReceivedKey, item->GetReceivedBytes()); | 189 json->SetInteger(kBytesReceivedKey, item->GetReceivedBytes()); |
| 190 json->SetInteger(kTotalBytesKey, item->GetTotalBytes()); | 190 json->SetInteger(kTotalBytesKey, item->GetTotalBytes()); |
| 191 if (item->GetState() == DownloadItem::INTERRUPTED) | 191 if (item->GetState() == DownloadItem::INTERRUPTED) { |
| 192 json->SetInteger(kErrorKey, static_cast<int>(item->GetLastReason())); | 192 json->SetInteger(kErrorKey, static_cast<int>(item->GetLastReason())); |
| 193 else if (item->GetState() == DownloadItem::CANCELLED) | 193 } else if (item->GetState() == DownloadItem::CANCELLED) { |
| 194 json->SetInteger(kErrorKey, static_cast<int>( | 194 json->SetInteger(kErrorKey, static_cast<int>( |
| 195 DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)); | 195 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)); |
| 196 } |
| 196 // TODO(benjhayden): Implement endTime and fileSize. | 197 // TODO(benjhayden): Implement endTime and fileSize. |
| 197 // json->SetInteger(kEndTimeKey, -1); | 198 // json->SetInteger(kEndTimeKey, -1); |
| 198 json->SetInteger(kFileSizeKey, item->GetTotalBytes()); | 199 json->SetInteger(kFileSizeKey, item->GetTotalBytes()); |
| 199 return scoped_ptr<base::DictionaryValue>(json); | 200 return scoped_ptr<base::DictionaryValue>(json); |
| 200 } | 201 } |
| 201 | 202 |
| 202 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor { | 203 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor { |
| 203 public: | 204 public: |
| 204 DownloadFileIconExtractorImpl() {} | 205 DownloadFileIconExtractorImpl() {} |
| 205 | 206 |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 ListValue args; | 1067 ListValue args; |
| 1067 args.Append(arg); | 1068 args.Append(arg); |
| 1068 std::string json_args; | 1069 std::string json_args; |
| 1069 base::JSONWriter::Write(&args, false, &json_args); | 1070 base::JSONWriter::Write(&args, false, &json_args); |
| 1070 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 1071 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 1071 event_name, | 1072 event_name, |
| 1072 json_args, | 1073 json_args, |
| 1073 profile_, | 1074 profile_, |
| 1074 GURL()); | 1075 GURL()); |
| 1075 } | 1076 } |
| OLD | NEW |