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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 92 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
93 return "DANGEROUS_FILE"; | 93 return "DANGEROUS_FILE"; |
94 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | 94 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
95 return "DANGEROUS_URL"; | 95 return "DANGEROUS_URL"; |
96 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 96 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
97 return "DANGEROUS_CONTENT"; | 97 return "DANGEROUS_CONTENT"; |
98 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | 98 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
99 return "UNCOMMON_CONTENT"; | 99 return "UNCOMMON_CONTENT"; |
100 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: | 100 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: |
101 return "DANGEROUS_HOST"; | 101 return "DANGEROUS_HOST"; |
| 102 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: |
| 103 return "POTENTIALLY_UNWANTED"; |
102 default: | 104 default: |
103 // Don't return a danger type string if it is NOT_DANGEROUS or | 105 // Don't return a danger type string if it is NOT_DANGEROUS or |
104 // MAYBE_DANGEROUS_CONTENT. | 106 // MAYBE_DANGEROUS_CONTENT. |
105 NOTREACHED(); | 107 NOTREACHED(); |
106 return ""; | 108 return ""; |
107 } | 109 } |
108 } | 110 } |
109 | 111 |
110 // Returns a JSON dictionary containing some of the attributes of |download|. | 112 // Returns a JSON dictionary containing some of the attributes of |download|. |
111 // The JSON dictionary will also have a field "id" set to |id|, and a field | 113 // The JSON dictionary will also have a field "id" set to |id|, and a field |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // These are the only danger states that the UI is equipped to handle. | 156 // These are the only danger states that the UI is equipped to handle. |
155 DCHECK(download_item->GetDangerType() == | 157 DCHECK(download_item->GetDangerType() == |
156 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || | 158 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || |
157 download_item->GetDangerType() == | 159 download_item->GetDangerType() == |
158 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || | 160 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
159 download_item->GetDangerType() == | 161 download_item->GetDangerType() == |
160 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || | 162 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
161 download_item->GetDangerType() == | 163 download_item->GetDangerType() == |
162 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || | 164 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || |
163 download_item->GetDangerType() == | 165 download_item->GetDangerType() == |
164 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST); | 166 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST || |
| 167 download_item->GetDangerType() == |
| 168 content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED); |
165 const char* danger_type_value = | 169 const char* danger_type_value = |
166 GetDangerTypeString(download_item->GetDangerType()); | 170 GetDangerTypeString(download_item->GetDangerType()); |
167 file_value->SetString("danger_type", danger_type_value); | 171 file_value->SetString("danger_type", danger_type_value); |
168 } else if (download_item->IsPaused()) { | 172 } else if (download_item->IsPaused()) { |
169 file_value->SetString("state", "PAUSED"); | 173 file_value->SetString("state", "PAUSED"); |
170 } else { | 174 } else { |
171 file_value->SetString("state", "IN_PROGRESS"); | 175 file_value->SetString("state", "IN_PROGRESS"); |
172 } | 176 } |
173 | 177 |
174 file_value->SetString("progress_status_text", | 178 file_value->SetString("progress_status_text", |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 562 } |
559 | 563 |
560 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 564 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
561 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 565 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
562 } | 566 } |
563 | 567 |
564 void DownloadsDOMHandler::CallDownloadUpdated( | 568 void DownloadsDOMHandler::CallDownloadUpdated( |
565 const base::ListValue& download_item) { | 569 const base::ListValue& download_item) { |
566 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 570 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
567 } | 571 } |
OLD | NEW |