OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 const char kInvalidURL[] = "Invalid URL"; | 50 const char kInvalidURL[] = "Invalid URL"; |
51 | 51 |
52 // Parameter keys | 52 // Parameter keys |
53 const char kBodyKey[] = "body"; | 53 const char kBodyKey[] = "body"; |
54 const char kBytesReceivedKey[] = "bytesReceived"; | 54 const char kBytesReceivedKey[] = "bytesReceived"; |
55 const char kDangerAcceptedKey[] = "dangerAccepted"; | 55 const char kDangerAcceptedKey[] = "dangerAccepted"; |
56 const char kDangerFile[] = "file"; | 56 const char kDangerFile[] = "file"; |
57 const char kDangerKey[] = "danger"; | 57 const char kDangerKey[] = "danger"; |
58 const char kDangerSafe[] = "safe"; | 58 const char kDangerSafe[] = "safe"; |
59 const char kDangerUrl[] = "url"; | 59 const char kDangerUrl[] = "url"; |
60 const char kDangerContent[] = "content"; | |
asanka
2011/11/16 18:34:05
Nit: These should be ordered alphabetically.
noelutz
2011/11/16 23:15:07
Done.
| |
60 const char kEndTimeKey[] = "endTime"; | 61 const char kEndTimeKey[] = "endTime"; |
61 const char kErrorKey[] = "error"; | 62 const char kErrorKey[] = "error"; |
62 const char kFileSizeKey[] = "fileSize"; | 63 const char kFileSizeKey[] = "fileSize"; |
63 const char kFilenameKey[] = "filename"; | 64 const char kFilenameKey[] = "filename"; |
64 const char kHeaderNameKey[] = "name"; | 65 const char kHeaderNameKey[] = "name"; |
65 const char kHeaderValueKey[] = "value"; | 66 const char kHeaderValueKey[] = "value"; |
66 const char kHeadersKey[] = "headers"; | 67 const char kHeadersKey[] = "headers"; |
67 const char kIdKey[] = "id"; | 68 const char kIdKey[] = "id"; |
68 const char kMethodKey[] = "method"; | 69 const char kMethodKey[] = "method"; |
69 const char kMimeKey[] = "mime"; | 70 const char kMimeKey[] = "mime"; |
70 const char kPausedKey[] = "paused"; | 71 const char kPausedKey[] = "paused"; |
71 const char kSaveAsKey[] = "saveAs"; | 72 const char kSaveAsKey[] = "saveAs"; |
72 const char kStartTimeKey[] = "startTime"; | 73 const char kStartTimeKey[] = "startTime"; |
73 const char kStateComplete[] = "complete"; | 74 const char kStateComplete[] = "complete"; |
74 const char kStateInProgress[] = "in_progress"; | 75 const char kStateInProgress[] = "in_progress"; |
75 const char kStateInterrupted[] = "interrupted"; | 76 const char kStateInterrupted[] = "interrupted"; |
76 const char kStateKey[] = "state"; | 77 const char kStateKey[] = "state"; |
77 const char kTotalBytesKey[] = "totalBytes"; | 78 const char kTotalBytesKey[] = "totalBytes"; |
78 const char kUrlKey[] = "url"; | 79 const char kUrlKey[] = "url"; |
79 | 80 |
80 const char* DangerString(DownloadItem::DangerType danger) { | 81 const char* DangerString(DownloadItem::DangerType danger) { |
81 switch (danger) { | 82 switch (danger) { |
82 case DownloadItem::NOT_DANGEROUS: return kDangerSafe; | 83 case DownloadItem::NOT_DANGEROUS: return kDangerSafe; |
83 case DownloadItem::DANGEROUS_FILE: return kDangerFile; | 84 case DownloadItem::DANGEROUS_FILE: return kDangerFile; |
84 case DownloadItem::DANGEROUS_URL: return kDangerUrl; | 85 case DownloadItem::DANGEROUS_URL: return kDangerUrl; |
86 case DownloadItem::DANGEROUS_CONTENT: return kDangerContent; | |
Randy Smith (Not in Mondays)
2011/11/16 18:04:04
I think (Asanka?) that we also want to export the
asanka
2011/11/16 18:34:05
I can see how it could be useful. However I'm not
noelutz
2011/11/16 23:15:07
Propagated the maybe.
| |
85 default: | 87 default: |
86 NOTREACHED(); | 88 NOTREACHED(); |
87 return ""; | 89 return ""; |
88 } | 90 } |
89 } | 91 } |
90 | 92 |
91 const char* StateString(DownloadItem::DownloadState state) { | 93 const char* StateString(DownloadItem::DownloadState state) { |
92 switch (state) { | 94 switch (state) { |
93 case DownloadItem::IN_PROGRESS: return kStateInProgress; | 95 case DownloadItem::IN_PROGRESS: return kStateInProgress; |
94 case DownloadItem::COMPLETE: return kStateComplete; | 96 case DownloadItem::COMPLETE: return kStateComplete; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 ListValue args; | 544 ListValue args; |
543 args.Append(arg); | 545 args.Append(arg); |
544 std::string json_args; | 546 std::string json_args; |
545 base::JSONWriter::Write(&args, false, &json_args); | 547 base::JSONWriter::Write(&args, false, &json_args); |
546 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 548 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
547 event_name, | 549 event_name, |
548 json_args, | 550 json_args, |
549 profile_, | 551 profile_, |
550 GURL()); | 552 GURL()); |
551 } | 553 } |
OLD | NEW |