16d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Copyright (c) 2014 The Chromium Authors. All rights reserved. 26d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 36d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// found in the LICENSE file. 46d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 56d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "chrome/browser/component_updater/sw_reporter_installer_win.h" 66d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 71320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include <stdint.h> 86d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include <string> 96d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include <vector> 106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 116d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/base_paths.h" 126d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/bind.h" 136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/bind_helpers.h" 146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/command_line.h" 156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/files/file_path.h" 161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/files/file_util.h" 176d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/logging.h" 181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/metrics/field_trial.h" 196d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/metrics/histogram.h" 206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/metrics/sparse_histogram.h" 216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/path_service.h" 226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/prefs/pref_registry_simple.h" 236d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/prefs/pref_service.h" 246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/process/kill.h" 256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/process/launch.h" 266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/task_runner_util.h" 276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/threading/worker_pool.h" 281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/time/time.h" 296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "base/win/registry.h" 306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "chrome/browser/browser_process.h" 311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/profiles/profile.h" 331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/safe_browsing/srt_global_error_win.h" 341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/ui/browser_finder.h" 351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/ui/global_error/global_error_service.h" 361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/browser/ui/global_error/global_error_service_factory.h" 371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "chrome/common/pref_names.h" 38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/component_updater/component_updater_paths.h" 3903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "components/component_updater/component_updater_service.h" 4003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "components/component_updater/component_updater_utils.h" 4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "components/component_updater/default_component_installer.h" 42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/component_updater/pref_names.h" 431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "components/pref_registry/pref_registry_syncable.h" 446d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "content/public/browser/browser_thread.h" 456d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)using content::BrowserThread; 476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)namespace component_updater { 496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)namespace { 516d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// These values are used to send UMA information and are replicated in the 536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// histograms.xml file, so the order MUST NOT CHANGE. 546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)enum SwReporterUmaValue { 551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci SW_REPORTER_EXPLICIT_REQUEST = 0, // Deprecated. 561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci SW_REPORTER_STARTUP_RETRY = 1, // Deprecated. 571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci SW_REPORTER_RETRIED_TOO_MANY_TIMES = 2, // Deprecated. 586d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) SW_REPORTER_START_EXECUTION = 3, 596d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) SW_REPORTER_FAILED_TO_START = 4, 606d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) SW_REPORTER_REGISTRY_EXIT_CODE = 5, 611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci SW_REPORTER_RESET_RETRIES = 6, // Deprecated. 626d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) SW_REPORTER_MAX, 636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}; 646d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 656d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// The maximum number of times to retry a download on startup. 66116680a4aac90f2aa7413d9095a592090648e557Ben Murdochconst int kMaxRetry = 20; 676d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// The number of days to wait before triggering another sw reporter run. 691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst int kDaysBetweenSwReporterRuns = 7; 701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 716d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// CRX hash. The extension id is: gkmgaooipdjhmangpemjhigmamcehddo. The hash was 726d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// generated in Python with something like this: 736d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// hashlib.sha256().update(open("<file>.crx").read()[16:16+294]).digest(). 741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst uint8_t kSha256Hash[] = {0x6a, 0xc6, 0x0e, 0xe8, 0xf3, 0x97, 0xc0, 0xd6, 751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 0xf4, 0xc9, 0x78, 0x6c, 0x0c, 0x24, 0x73, 0x3e, 761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 0x05, 0xa5, 0x62, 0x4b, 0x2e, 0xc7, 0xb7, 0x1c, 771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 0x5f, 0xea, 0xf0, 0x88, 0xf6, 0x97, 0x9b, 0xc7}; 786d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 796d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)const base::FilePath::CharType kSwReporterExeName[] = 806d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) FILE_PATH_LITERAL("software_reporter_tool.exe"); 816d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 826d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// Where to fetch the reporter exit code in the registry. 836d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)const wchar_t kSoftwareRemovalToolRegistryKey[] = 846d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) L"Software\\Google\\Software Removal Tool"; 8529b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdochconst wchar_t kCleanerSuffixRegistryKey[] = L"Cleaner"; 866d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)const wchar_t kExitCodeRegistryValueName[] = L"ExitCode"; 8729b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdochconst wchar_t kVersionRegistryValueName[] = L"Version"; 8829b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdochconst wchar_t kStartTimeRegistryValueName[] = L"StartTime"; 8929b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdochconst wchar_t kEndTimeRegistryValueName[] = L"EndTime"; 906d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Field trial strings. 921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst char kSRTPromptTrialName[] = "SRTPromptFieldTrial"; 931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst char kSRTPromptOnGroup[] = "On"; 941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Exit codes that identify that a cleanup is needed. 961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst int kCleanupNeeded = 0; 971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciconst int kPostRebootCleanupNeeded = 4; 981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 996d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)void ReportUmaStep(SwReporterUmaValue value) { 1006d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Step", value, SW_REPORTER_MAX); 1016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 1026d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 1031320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid ReportUmaVersion(const base::Version& version) { 1041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci DCHECK(!version.components().empty()); 1051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MinorVersion", 1061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci version.components().back()); 1071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // The major version uses the 1st component value (when there is more than 1081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // one, since the last one is always the minor version) as a hi word in a 1091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // double word. The low word is either the second component (when there are 1101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // only three) or the 3rd one if there are at least 4. E.g., for W.X.Y.Z, we 1111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // ignore X, and Z is the minor version. We compute the major version with W 1121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // as the hi word, and Y as the low word. For X.Y.Z, we use X and Y as hi and 1131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // low words, and if we would have Y.Z we would use Y as the hi word and 0 as 1141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // the low word. major version is 0 if the version only has one component. 1151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci uint32_t major_version = 0; 1161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (version.components().size() > 1) 1171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci major_version = 0x10000 * version.components()[0]; 1181320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (version.components().size() < 4 && version.components().size() > 2) 1191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci major_version += version.components()[1]; 1201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci else if (version.components().size() > 3) 1211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci major_version += version.components()[2]; 1221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.MajorVersion", major_version); 1231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 1241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// This function is called on the UI thread to report the SwReporter exit code 1266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// and then clear it from the registry as well as clear the execution state 1276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// from the local state. This could be called from an interruptible worker 1281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// thread so should be resilient to unexpected shutdown. |version| is provided 1291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// so the kSwReporterPromptVersion prefs can be set. 1301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid ReportAndClearExitCode(int exit_code, const std::string& version) { 1316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.ExitCode", exit_code); 1321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (g_browser_process && g_browser_process->local_state()) { 1331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci g_browser_process->local_state()->SetInteger(prefs::kSwReporterLastExitCode, 1341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci exit_code); 1351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if ((exit_code == kPostRebootCleanupNeeded || exit_code == kCleanupNeeded) && 1381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::FieldTrialList::FindFullName(kSRTPromptTrialName) == 1391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci kSRTPromptOnGroup) { 1401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Find the last active browser, which may be NULL, in which case we won't 1411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // show the prompt this time and will wait until the next run of the 1421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // reporter. We can't use other ways of finding a browser because we don't 1431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // have a profile. 1441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); 1451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); 1461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (browser) { 1471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci Profile* profile = browser->profile(); 1481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Don't show the prompt again if it's been shown before for this profile. 1491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci DCHECK(profile); 1501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const std::string prompt_version = 1511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci profile->GetPrefs()->GetString(prefs::kSwReporterPromptVersion); 1521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (prompt_version.empty()) { 1531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci profile->GetPrefs()->SetString(prefs::kSwReporterPromptVersion, 1541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci version); 1551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci profile->GetPrefs()->SetInteger(prefs::kSwReporterPromptReason, 1561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci exit_code); 1571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Now that we have a profile, make sure we have a tabbed browser since 1581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // we need to anchor the bubble to the toolbar's wrench menu. Create one 1591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // if none exist already. 1601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (browser->type() != Browser::TYPE_TABBED) { 1611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci browser = chrome::FindTabbedBrowser(profile, false, desktop_type); 1621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (!browser) 1631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci browser = new Browser(Browser::CreateParams(profile, desktop_type)); 1641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GlobalErrorService* global_error_service = 1661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GlobalErrorServiceFactory::GetForProfile(profile); 1671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci SRTGlobalError* global_error = new SRTGlobalError(global_error_service); 1681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // |global_error_service| takes ownership of |global_error| and keeps it 1691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // alive until RemoveGlobalError() is called, and even then, the object 1701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // is not destroyed, the caller of RemoveGlobalError is responsible to 1711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // destroy it, and in the case of the SRTGlobalError, it deletes itself 1721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // but only after the bubble has been interacted with. 1731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci global_error_service->AddGlobalError(global_error); 1741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 1751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Do not try to show bubble if another GlobalError is already showing 1761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // one. The bubble will be shown once the others have been dismissed. 1771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const GlobalErrorService::GlobalErrorList& global_errors( 1781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci global_error_service->errors()); 1791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GlobalErrorService::GlobalErrorList::const_iterator it; 1801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci for (it = global_errors.begin(); it != global_errors.end(); ++it) { 1811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if ((*it)->GetBubbleView()) 1821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci break; 1831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (it == global_errors.end()) 1851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci global_error->ShowBubbleView(browser); 1861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 1896d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 1906d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) base::win::RegKey srt_key( 1916d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) HKEY_CURRENT_USER, kSoftwareRemovalToolRegistryKey, KEY_WRITE); 1926d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) srt_key.DeleteValue(kExitCodeRegistryValueName); 1936d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 1946d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 1956d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// This function is called from a worker thread to launch the SwReporter and 1966d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// wait for termination to collect its exit code. This task could be interrupted 1976d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// by a shutdown at anytime, so it shouldn't depend on anything external that 1986d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)// could be shutdown beforehand. 1991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid LaunchAndWaitForExit(const base::FilePath& exe_path, 2001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const std::string& version) { 2016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const base::CommandLine reporter_command_line(exe_path); 2026d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) base::ProcessHandle scan_reporter_process = base::kNullProcessHandle; 2036d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) if (!base::LaunchProcess(reporter_command_line, 2046d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) base::LaunchOptions(), 2056d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) &scan_reporter_process)) { 2066d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ReportUmaStep(SW_REPORTER_FAILED_TO_START); 2076d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) return; 2086d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 2096d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) ReportUmaStep(SW_REPORTER_START_EXECUTION); 2106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2116d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) int exit_code = -1; 2126d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) bool success = base::WaitForExitCode(scan_reporter_process, &exit_code); 2136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DCHECK(success); 2146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) scan_reporter_process = base::kNullProcessHandle; 2156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // It's OK if this doesn't complete, the work will continue on next startup. 2161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci BrowserThread::PostTask( 2171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci BrowserThread::UI, 2186d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) FROM_HERE, 2191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Bind(&ReportAndClearExitCode, exit_code, version)); 2206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 2216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)class SwReporterInstallerTraits : public ComponentInstallerTraits { 2236d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) public: 2246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) explicit SwReporterInstallerTraits(PrefService* prefs) : prefs_(prefs) {} 2256d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2266d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual ~SwReporterInstallerTraits() {} 2276d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2286d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual bool VerifyInstallation(const base::FilePath& dir) const { 2296d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) return base::PathExists(dir.Append(kSwReporterExeName)); 2306d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 2316d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2326d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual bool CanAutoUpdate() const { return true; } 2336d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2346d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual bool OnCustomInstall(const base::DictionaryValue& manifest, 2356d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const base::FilePath& install_dir) { 2366d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) return true; 2376d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 2386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2396d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual void ComponentReady(const base::Version& version, 2406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) const base::FilePath& install_dir, 2416d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) scoped_ptr<base::DictionaryValue> manifest) { 2421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ReportUmaVersion(version); 2441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2456d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) wcsncpy_s(version_dir_, 2466d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) _MAX_PATH, 2476d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) install_dir.value().c_str(), 2486d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) install_dir.value().size()); 2491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // A previous run may have results in the registry, so check and report 2511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // them if present. 2521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci std::string version_string(version.GetString()); 2531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::win::RegKey srt_key( 2541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci HKEY_CURRENT_USER, kSoftwareRemovalToolRegistryKey, KEY_READ); 2551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci DWORD exit_code; 2561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (srt_key.Valid() && 2571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci srt_key.ReadValueDW(kExitCodeRegistryValueName, &exit_code) == 2581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ERROR_SUCCESS) { 2591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ReportUmaStep(SW_REPORTER_REGISTRY_EXIT_CODE); 2601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ReportAndClearExitCode(exit_code, version_string); 2611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 2621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // If we can't access local state, we can't see when we last ran, so 2641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // just exit without running. 2651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (!g_browser_process || !g_browser_process->local_state()) 2661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return; 2671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Run the reporter if it hasn't been triggered in the 2691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // kDaysBetweenSwReporterRuns days. 2701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const base::Time last_time_triggered = base::Time::FromInternalValue( 2711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci g_browser_process->local_state()->GetInt64( 2721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci prefs::kSwReporterLastTimeTriggered)); 2731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if ((base::Time::Now() - last_time_triggered).InDays() >= 2741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci kDaysBetweenSwReporterRuns) { 2751320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci g_browser_process->local_state()->SetInt64( 2761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci prefs::kSwReporterLastTimeTriggered, 2771320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Time::Now().ToInternalValue()); 2781320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 2791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::WorkerPool::PostTask( 2801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci FROM_HERE, 2811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::Bind(&LaunchAndWaitForExit, 2821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci install_dir.Append(kSwReporterExeName), 2831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci version_string), 2841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci true); 2851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 2866d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 2876d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2886d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual base::FilePath GetBaseDirectory() const { return install_dir(); } 2896d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void GetHash(std::vector<uint8_t>* hash) const { GetPkHash(hash); } 2916d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2926d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) virtual std::string GetName() const { return "Software Reporter Tool"; } 2936d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 2946d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) static base::FilePath install_dir() { 2956d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // The base directory on windows looks like: 2966d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // <profile>\AppData\Local\Google\Chrome\User Data\SwReporter\. 2976d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) base::FilePath result; 298116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch PathService::Get(DIR_SW_REPORTER, &result); 299116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return result; 3006d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3026d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) static std::string ID() { 3036d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) CrxComponent component; 3046d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) component.version = Version("0.0.0.0"); 3056d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) GetPkHash(&component.pk_hash); 3066d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) return component_updater::GetCrxComponentID(component); 3076d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3086d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3096d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) static base::FilePath VersionPath() { return base::FilePath(version_dir_); } 3106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3116d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) private: 3121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci static void GetPkHash(std::vector<uint8_t>* hash) { 3136d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DCHECK(hash); 3146d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) hash->assign(kSha256Hash, kSha256Hash + sizeof(kSha256Hash)); 3156d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) } 3166d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3176d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) PrefService* prefs_; 3186d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) static wchar_t version_dir_[_MAX_PATH]; 3196d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}; 3206d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3216d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)wchar_t SwReporterInstallerTraits::version_dir_[] = {}; 3226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} // namespace 3241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 3251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RegisterSwReporterComponent(ComponentUpdateService* cus, 3261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci PrefService* prefs) { 3271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // The Sw reporter doesn't need to run if the user isn't reporting metrics and 3281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // isn't in the SRTPrompt field trial "On" group. 3291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (!ChromeMetricsServiceAccessor::IsMetricsReportingEnabled() && 3301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::FieldTrialList::FindFullName(kSRTPromptTrialName) != 3311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci kSRTPromptOnGroup) { 3321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return; 3331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 3341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 33529b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch // Check if we have information from Cleaner and record UMA statistics. 33629b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch base::string16 cleaner_key_name(kSoftwareRemovalToolRegistryKey); 33729b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key_name.append(1, L'\\').append(kCleanerSuffixRegistryKey); 33829b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch base::win::RegKey cleaner_key( 33929b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch HKEY_CURRENT_USER, cleaner_key_name.c_str(), KEY_ALL_ACCESS); 34029b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch // Cleaner is assumed to have run if we have a start time. 34129b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch if (cleaner_key.Valid() && 34229b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.HasValue(kStartTimeRegistryValueName)) { 34329b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch // Get version number. 34429b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch if (cleaner_key.HasValue(kVersionRegistryValueName)) { 34529b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch DWORD version; 34629b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.ReadValueDW(kVersionRegistryValueName, &version); 34729b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.Cleaner.Version", version); 34829b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.DeleteValue(kVersionRegistryValueName); 34929b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch } 35029b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch // Get start & end time. If we don't have an end time, we can assume the 35129b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch // cleaner has crashed. 35229b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch bool completed = cleaner_key.HasValue(kEndTimeRegistryValueName); 35329b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch UMA_HISTOGRAM_BOOLEAN("SoftwareReporter.Cleaner.HasCompleted", completed); 35429b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch if (completed) { 35529b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch int64 start_time_value; 35629b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.ReadInt64(kStartTimeRegistryValueName, &start_time_value); 35729b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch int64 end_time_value; 35829b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.ReadInt64(kEndTimeRegistryValueName, &end_time_value); 35929b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.DeleteValue(kEndTimeRegistryValueName); 36029b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch base::TimeDelta run_time(base::Time::FromInternalValue(end_time_value) - 36129b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch base::Time::FromInternalValue(start_time_value)); 36229b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch UMA_HISTOGRAM_LONG_TIMES("SoftwareReporter.Cleaner.RunningTime", 36329b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch run_time); 36429b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch } 36529b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch // Get exit code. 36629b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch if (cleaner_key.HasValue(kExitCodeRegistryValueName)) { 36729b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch DWORD exit_code; 36829b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.ReadValueDW(kExitCodeRegistryValueName, &exit_code); 36929b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch UMA_HISTOGRAM_SPARSE_SLOWLY("SoftwareReporter.Cleaner.ExitCode", 37029b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch exit_code); 37129b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.DeleteValue(kExitCodeRegistryValueName); 37229b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch } 37329b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch cleaner_key.DeleteValue(kStartTimeRegistryValueName); 37429b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch } 37529b820f8d84e3bc97d62552e54923c42407f2f29Ben Murdoch 3761320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Install the component. 3776d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) scoped_ptr<ComponentInstallerTraits> traits( 3786d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) new SwReporterInstallerTraits(prefs)); 3796d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // |cus| will take ownership of |installer| during installer->Register(cus). 3806d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) DefaultComponentInstaller* installer = 3816d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) new DefaultComponentInstaller(traits.Pass()); 3826d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) installer->Register(cus); 3836d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 3846d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RegisterPrefsForSwReporter(PrefRegistrySimple* registry) { 3861320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0); 3871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci registry->RegisterIntegerPref(prefs::kSwReporterLastExitCode, -1); 3886d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 3896d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 3901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid RegisterProfilePrefsForSwReporter( 3911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci user_prefs::PrefRegistrySyncable* registry) { 3921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci registry->RegisterIntegerPref( 3931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci prefs::kSwReporterPromptReason, 3941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci -1, 3951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 3961320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 3971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci registry->RegisterStringPref( 3981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci prefs::kSwReporterPromptVersion, 3991320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci "", 4001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 4016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} 4026d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) 4036d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)} // namespace component_updater 404