| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/component_updater/sw_reporter_installer_win.h" | 5 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/files/file_util.h" | 22 #include "base/files/file_util.h" |
| 23 #include "base/logging.h" | 23 #include "base/logging.h" |
| 24 #include "base/metrics/histogram_macros.h" | 24 #include "base/metrics/histogram_macros.h" |
| 25 #include "base/metrics/sparse_histogram.h" | 25 #include "base/metrics/sparse_histogram.h" |
| 26 #include "base/path_service.h" | 26 #include "base/path_service.h" |
| 27 #include "base/rand_util.h" | 27 #include "base/rand_util.h" |
| 28 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
| 29 #include "base/strings/string_tokenizer.h" | 29 #include "base/strings/string_tokenizer.h" |
| 30 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
| 31 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
| 32 #include "base/task_scheduler/post_task.h" | |
| 33 #include "base/threading/thread_task_runner_handle.h" | 32 #include "base/threading/thread_task_runner_handle.h" |
| 34 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 35 #include "base/win/registry.h" | 34 #include "base/win/registry.h" |
| 36 #include "base/win/windows_version.h" | 35 #include "base/win/windows_version.h" |
| 37 #include "chrome/browser/browser_process.h" | 36 #include "chrome/browser/browser_process.h" |
| 38 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" | 37 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
| 39 #include "chrome/browser/safe_browsing/srt_field_trial_win.h" | 38 #include "chrome/browser/safe_browsing/srt_field_trial_win.h" |
| 40 #include "components/component_updater/component_updater_paths.h" | 39 #include "components/component_updater/component_updater_paths.h" |
| 41 #include "components/component_updater/component_updater_service.h" | 40 #include "components/component_updater/component_updater_service.h" |
| 42 #include "components/component_updater/pref_names.h" | 41 #include "components/component_updater/pref_names.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 130 |
| 132 // Once the Software Reporter is downloaded, schedules it to run sometime after | 131 // Once the Software Reporter is downloaded, schedules it to run sometime after |
| 133 // the current browser startup is complete. (This is the default | 132 // the current browser startup is complete. (This is the default |
| 134 // |reporter_runner| function passed to the |SwReporterInstallerTraits| | 133 // |reporter_runner| function passed to the |SwReporterInstallerTraits| |
| 135 // constructor in |RegisterSwReporterComponent| below.) | 134 // constructor in |RegisterSwReporterComponent| below.) |
| 136 void RunSwReportersAfterStartup( | 135 void RunSwReportersAfterStartup( |
| 137 const safe_browsing::SwReporterQueue& invocations, | 136 const safe_browsing::SwReporterQueue& invocations, |
| 138 const base::Version& version) { | 137 const base::Version& version) { |
| 139 content::BrowserThread::PostAfterStartupTask( | 138 content::BrowserThread::PostAfterStartupTask( |
| 140 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), | 139 FROM_HERE, base::ThreadTaskRunnerHandle::Get(), |
| 141 base::Bind(&safe_browsing::RunSwReporters, invocations, version, | 140 base::Bind(&safe_browsing::RunSwReporters, invocations, version)); |
| 142 base::ThreadTaskRunnerHandle::Get(), | |
| 143 // Runs LaunchAndWaitForExit() which creates (MayBlock()) and | |
| 144 // joins (WithBaseSyncPrimitives()) a process. | |
| 145 base::CreateTaskRunnerWithTraits( | |
| 146 base::TaskTraits() | |
| 147 .WithShutdownBehavior( | |
| 148 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | |
| 149 .WithPriority(base::TaskPriority::BACKGROUND) | |
| 150 .MayBlock() | |
| 151 .WithBaseSyncPrimitives()))); | |
| 152 } | 141 } |
| 153 | 142 |
| 154 // Ensures |str| contains only alphanumeric characters and characters from | 143 // Ensures |str| contains only alphanumeric characters and characters from |
| 155 // |extras|, and is not longer than |max_length|. | 144 // |extras|, and is not longer than |max_length|. |
| 156 bool ValidateString(const std::string& str, | 145 bool ValidateString(const std::string& str, |
| 157 const std::string& extras, | 146 const std::string& extras, |
| 158 size_t max_length) { | 147 size_t max_length) { |
| 159 return str.size() <= max_length && | 148 return str.size() <= max_length && |
| 160 std::all_of(str.cbegin(), str.cend(), [&extras](char c) { | 149 std::all_of(str.cbegin(), str.cend(), [&extras](char c) { |
| 161 return base::IsAsciiAlpha(c) || base::IsAsciiDigit(c) || | 150 return base::IsAsciiAlpha(c) || base::IsAsciiDigit(c) || |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 496 } |
| 508 | 497 |
| 509 void RegisterProfilePrefsForSwReporter( | 498 void RegisterProfilePrefsForSwReporter( |
| 510 user_prefs::PrefRegistrySyncable* registry) { | 499 user_prefs::PrefRegistrySyncable* registry) { |
| 511 registry->RegisterStringPref(prefs::kSwReporterPromptVersion, ""); | 500 registry->RegisterStringPref(prefs::kSwReporterPromptVersion, ""); |
| 512 | 501 |
| 513 registry->RegisterStringPref(prefs::kSwReporterPromptSeed, ""); | 502 registry->RegisterStringPref(prefs::kSwReporterPromptSeed, ""); |
| 514 } | 503 } |
| 515 | 504 |
| 516 } // namespace component_updater | 505 } // namespace component_updater |
| OLD | NEW |