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/ui/webui/downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const char* GetDangerTypeString(content::DownloadDangerType danger_type) { | 87 const char* GetDangerTypeString(content::DownloadDangerType danger_type) { |
88 switch (danger_type) { | 88 switch (danger_type) { |
89 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 89 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
90 return "DANGEROUS_FILE"; | 90 return "DANGEROUS_FILE"; |
91 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | 91 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
92 return "DANGEROUS_URL"; | 92 return "DANGEROUS_URL"; |
93 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 93 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
94 return "DANGEROUS_CONTENT"; | 94 return "DANGEROUS_CONTENT"; |
95 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | 95 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
96 return "UNCOMMON_CONTENT"; | 96 return "UNCOMMON_CONTENT"; |
| 97 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: |
| 98 return "DANGEROUS_HOST"; |
97 default: | 99 default: |
98 // Don't return a danger type string if it is NOT_DANGEROUS or | 100 // Don't return a danger type string if it is NOT_DANGEROUS or |
99 // MAYBE_DANGEROUS_CONTENT. | 101 // MAYBE_DANGEROUS_CONTENT. |
100 NOTREACHED(); | 102 NOTREACHED(); |
101 return ""; | 103 return ""; |
102 } | 104 } |
103 } | 105 } |
104 | 106 |
105 // Returns a JSON dictionary containing some of the attributes of |download|. | 107 // Returns a JSON dictionary containing some of the attributes of |download|. |
106 // The JSON dictionary will also have a field "id" set to |id|, and a field | 108 // The JSON dictionary will also have a field "id" set to |id|, and a field |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 if (download_item->IsDangerous()) { | 146 if (download_item->IsDangerous()) { |
145 file_value->SetString("state", "DANGEROUS"); | 147 file_value->SetString("state", "DANGEROUS"); |
146 // These are the only danger states that the UI is equipped to handle. | 148 // These are the only danger states that the UI is equipped to handle. |
147 DCHECK(download_item->GetDangerType() == | 149 DCHECK(download_item->GetDangerType() == |
148 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || | 150 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || |
149 download_item->GetDangerType() == | 151 download_item->GetDangerType() == |
150 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || | 152 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
151 download_item->GetDangerType() == | 153 download_item->GetDangerType() == |
152 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || | 154 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
153 download_item->GetDangerType() == | 155 download_item->GetDangerType() == |
154 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); | 156 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || |
| 157 download_item->GetDangerType() == |
| 158 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST); |
155 const char* danger_type_value = | 159 const char* danger_type_value = |
156 GetDangerTypeString(download_item->GetDangerType()); | 160 GetDangerTypeString(download_item->GetDangerType()); |
157 file_value->SetString("danger_type", danger_type_value); | 161 file_value->SetString("danger_type", danger_type_value); |
158 } else if (download_item->IsPaused()) { | 162 } else if (download_item->IsPaused()) { |
159 file_value->SetString("state", "PAUSED"); | 163 file_value->SetString("state", "PAUSED"); |
160 } else { | 164 } else { |
161 file_value->SetString("state", "IN_PROGRESS"); | 165 file_value->SetString("state", "IN_PROGRESS"); |
162 } | 166 } |
163 | 167 |
164 file_value->SetString("progress_status_text", | 168 file_value->SetString("progress_status_text", |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 513 } |
510 | 514 |
511 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 515 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
512 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 516 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
513 } | 517 } |
514 | 518 |
515 void DownloadsDOMHandler::CallDownloadUpdated( | 519 void DownloadsDOMHandler::CallDownloadUpdated( |
516 const base::ListValue& download_item) { | 520 const base::ListValue& download_item) { |
517 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 521 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
518 } | 522 } |
OLD | NEW |