| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 download_item->GetDangerType() == | 178 download_item->GetDangerType() == |
| 178 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || | 179 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
| 179 download_item->GetDangerType() == | 180 download_item->GetDangerType() == |
| 180 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || | 181 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
| 181 download_item->GetDangerType() == | 182 download_item->GetDangerType() == |
| 182 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || | 183 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || |
| 183 download_item->GetDangerType() == | 184 download_item->GetDangerType() == |
| 184 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST || | 185 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST || |
| 185 download_item->GetDangerType() == | 186 download_item->GetDangerType() == |
| 186 content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED); | 187 content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED); |
| 188 std::string trial_condition = |
| 189 base::FieldTrialList::FindFullName(download_util::kFinchTrialName); |
| 187 const char* danger_type_value = | 190 const char* danger_type_value = |
| 188 GetDangerTypeString(download_item->GetDangerType()); | 191 GetDangerTypeString(download_item->GetDangerType()); |
| 189 file_value->SetString("danger_type", danger_type_value); | 192 file_value->SetString("danger_type", danger_type_value); |
| 193 if (!trial_condition.empty()) { |
| 194 base::string16 finch_string; |
| 195 content::DownloadDangerType danger_type = |
| 196 download_item->GetDangerType(); |
| 197 if (danger_type == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
| 198 danger_type == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
| 199 danger_type == content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST) { |
| 200 finch_string = download_util::AssembleMalwareFinchString( |
| 201 trial_condition, file_name); |
| 202 } |
| 203 file_value->SetString("finch_string", finch_string); |
| 204 } |
| 190 } else if (download_item->IsPaused()) { | 205 } else if (download_item->IsPaused()) { |
| 191 file_value->SetString("state", "PAUSED"); | 206 file_value->SetString("state", "PAUSED"); |
| 192 } else { | 207 } else { |
| 193 file_value->SetString("state", "IN_PROGRESS"); | 208 file_value->SetString("state", "IN_PROGRESS"); |
| 194 } | 209 } |
| 195 | 210 |
| 196 file_value->SetString("progress_status_text", | 211 file_value->SetString("progress_status_text", |
| 197 download_util::GetProgressStatusText(download_item)); | 212 download_util::GetProgressStatusText(download_item)); |
| 198 | 213 |
| 199 file_value->SetInteger("percent", | 214 file_value->SetInteger("percent", |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 597 } |
| 583 | 598 |
| 584 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 599 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
| 585 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 600 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
| 586 } | 601 } |
| 587 | 602 |
| 588 void DownloadsDOMHandler::CallDownloadUpdated( | 603 void DownloadsDOMHandler::CallDownloadUpdated( |
| 589 const base::ListValue& download_item) { | 604 const base::ListValue& download_item) { |
| 590 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 605 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
| 591 } | 606 } |
| OLD | NEW |