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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/i18n/time_formatting.h" | 14 #include "base/i18n/time_formatting.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/metrics/field_trial.h" | |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
18 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
21 #include "base/value_conversions.h" | 22 #include "base/value_conversions.h" |
22 #include "base/values.h" | 23 #include "base/values.h" |
23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/download/download_crx_util.h" | 25 #include "chrome/browser/download/download_crx_util.h" |
25 #include "chrome/browser/download/download_danger_prompt.h" | 26 #include "chrome/browser/download/download_danger_prompt.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 file_value->SetString("file_name", file_name); | 161 file_value->SetString("file_name", file_name); |
161 file_value->SetString("url", download_item->GetURL().spec()); | 162 file_value->SetString("url", download_item->GetURL().spec()); |
162 file_value->SetBoolean("otr", incognito); | 163 file_value->SetBoolean("otr", incognito); |
163 file_value->SetInteger("total", static_cast<int>( | 164 file_value->SetInteger("total", static_cast<int>( |
164 download_item->GetTotalBytes())); | 165 download_item->GetTotalBytes())); |
165 file_value->SetBoolean("file_externally_removed", | 166 file_value->SetBoolean("file_externally_removed", |
166 download_item->GetFileExternallyRemoved()); | 167 download_item->GetFileExternallyRemoved()); |
167 file_value->SetBoolean("retry", false); // Overridden below if needed. | 168 file_value->SetBoolean("retry", false); // Overridden below if needed. |
168 file_value->SetBoolean("resume", download_item->CanResume()); | 169 file_value->SetBoolean("resume", download_item->CanResume()); |
169 | 170 |
171 std::string trialCondition = | |
Dan Beam
2013/08/09 18:54:05
trial_condition (cpp_vars_like_this, jsVarsLikeThi
felt
2013/08/09 19:13:15
Done here & elsewhere
| |
172 base::FieldTrialList::FindFullName(download_util::kFinchTrialName); | |
173 | |
170 switch (download_item->GetState()) { | 174 switch (download_item->GetState()) { |
171 case content::DownloadItem::IN_PROGRESS: | 175 case content::DownloadItem::IN_PROGRESS: |
172 if (download_item->IsDangerous()) { | 176 if (download_item->IsDangerous()) { |
173 file_value->SetString("state", "DANGEROUS"); | 177 file_value->SetString("state", "DANGEROUS"); |
174 // These are the only danger states that the UI is equipped to handle. | 178 // These are the only danger states that the UI is equipped to handle. |
175 DCHECK(download_item->GetDangerType() == | 179 DCHECK(download_item->GetDangerType() == |
176 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || | 180 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || |
177 download_item->GetDangerType() == | 181 download_item->GetDangerType() == |
178 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || | 182 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
179 download_item->GetDangerType() == | 183 download_item->GetDangerType() == |
180 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || | 184 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
181 download_item->GetDangerType() == | 185 download_item->GetDangerType() == |
182 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || | 186 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || |
183 download_item->GetDangerType() == | 187 download_item->GetDangerType() == |
184 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST || | 188 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST || |
185 download_item->GetDangerType() == | 189 download_item->GetDangerType() == |
186 content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED); | 190 content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED); |
187 const char* danger_type_value = | 191 const char* danger_type_value = |
188 GetDangerTypeString(download_item->GetDangerType()); | 192 GetDangerTypeString(download_item->GetDangerType()); |
189 file_value->SetString("danger_type", danger_type_value); | 193 file_value->SetString("danger_type", danger_type_value); |
194 if ((trialCondition != "") && | |
Dan Beam
2013/08/09 18:54:05
if (!trial_condition.empty()) {
std::string finc
felt
2013/08/09 19:13:15
Done, thanks
| |
195 (download_item->GetDangerType() == | |
196 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || | |
197 download_item->GetDangerType() == | |
198 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || | |
199 download_item->GetDangerType() == | |
200 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST)) { | |
201 file_value->SetString( | |
202 "finch_string", | |
203 download_util::AssembleMalwareFinchString(trialCondition, | |
204 file_name)); | |
205 } else { | |
206 file_value->SetString("finch_string", ""); | |
207 } | |
190 } else if (download_item->IsPaused()) { | 208 } else if (download_item->IsPaused()) { |
191 file_value->SetString("state", "PAUSED"); | 209 file_value->SetString("state", "PAUSED"); |
192 } else { | 210 } else { |
193 file_value->SetString("state", "IN_PROGRESS"); | 211 file_value->SetString("state", "IN_PROGRESS"); |
194 } | 212 } |
195 | 213 |
196 file_value->SetString("progress_status_text", | 214 file_value->SetString("progress_status_text", |
197 download_util::GetProgressStatusText(download_item)); | 215 download_util::GetProgressStatusText(download_item)); |
198 | 216 |
199 file_value->SetInteger("percent", | 217 file_value->SetInteger("percent", |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 } | 600 } |
583 | 601 |
584 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 602 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
585 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 603 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
586 } | 604 } |
587 | 605 |
588 void DownloadsDOMHandler::CallDownloadUpdated( | 606 void DownloadsDOMHandler::CallDownloadUpdated( |
589 const base::ListValue& download_item) { | 607 const base::ListValue& download_item) { |
590 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 608 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
591 } | 609 } |
OLD | NEW |