Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: chrome/browser/component_updater/sw_reporter_installer_win.cc

Issue 590333002: Replace usage of basictypes.h with a combination of stdint.h and base/macros.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/base_paths.h" 11 #include "base/base_paths.h"
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 57
57 // The maximum number of times to retry a download on startup. 58 // The maximum number of times to retry a download on startup.
58 const int kMaxRetry = 20; 59 const int kMaxRetry = 20;
59 60
60 // The number of days to wait before triggering another sw reporter run. 61 // The number of days to wait before triggering another sw reporter run.
61 const int kDaysBetweenSwReporterRuns = 7; 62 const int kDaysBetweenSwReporterRuns = 7;
62 63
63 // CRX hash. The extension id is: gkmgaooipdjhmangpemjhigmamcehddo. The hash was 64 // CRX hash. The extension id is: gkmgaooipdjhmangpemjhigmamcehddo. The hash was
64 // generated in Python with something like this: 65 // generated in Python with something like this:
65 // hashlib.sha256().update(open("<file>.crx").read()[16:16+294]).digest(). 66 // hashlib.sha256().update(open("<file>.crx").read()[16:16+294]).digest().
66 const uint8 kSha256Hash[] = {0x6a, 0xc6, 0x0e, 0xe8, 0xf3, 0x97, 0xc0, 0xd6, 67 const uint8_t kSha256Hash[] = {0x6a, 0xc6, 0x0e, 0xe8, 0xf3, 0x97, 0xc0, 0xd6,
67 0xf4, 0xc9, 0x78, 0x6c, 0x0c, 0x24, 0x73, 0x3e, 68 0xf4, 0xc9, 0x78, 0x6c, 0x0c, 0x24, 0x73, 0x3e,
68 0x05, 0xa5, 0x62, 0x4b, 0x2e, 0xc7, 0xb7, 0x1c, 69 0x05, 0xa5, 0x62, 0x4b, 0x2e, 0xc7, 0xb7, 0x1c,
69 0x5f, 0xea, 0xf0, 0x88, 0xf6, 0x97, 0x9b, 0xc7}; 70 0x5f, 0xea, 0xf0, 0x88, 0xf6, 0x97, 0x9b, 0xc7};
70 71
71 const base::FilePath::CharType kSwReporterExeName[] = 72 const base::FilePath::CharType kSwReporterExeName[] =
72 FILE_PATH_LITERAL("software_reporter_tool.exe"); 73 FILE_PATH_LITERAL("software_reporter_tool.exe");
73 74
74 // Where to fetch the reporter exit code in the registry. 75 // Where to fetch the reporter exit code in the registry.
75 const wchar_t kSoftwareRemovalToolRegistryKey[] = 76 const wchar_t kSoftwareRemovalToolRegistryKey[] =
76 L"Software\\Google\\Software Removal Tool"; 77 L"Software\\Google\\Software Removal Tool";
77 const wchar_t kExitCodeRegistryValueName[] = L"ExitCode"; 78 const wchar_t kExitCodeRegistryValueName[] = L"ExitCode";
78 79
79 void ReportUmaStep(SwReporterUmaValue value) { 80 void ReportUmaStep(SwReporterUmaValue value) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 g_browser_process->local_state()->SetInt64( 180 g_browser_process->local_state()->SetInt64(
180 prefs::kSwReporterLastTimeTriggered, 181 prefs::kSwReporterLastTimeTriggered,
181 base::Time::Now().ToInternalValue()); 182 base::Time::Now().ToInternalValue());
182 183
183 ExecuteReporter(install_dir); 184 ExecuteReporter(install_dir);
184 } 185 }
185 } 186 }
186 187
187 virtual base::FilePath GetBaseDirectory() const { return install_dir(); } 188 virtual base::FilePath GetBaseDirectory() const { return install_dir(); }
188 189
189 virtual void GetHash(std::vector<uint8>* hash) const { GetPkHash(hash); } 190 virtual void GetHash(std::vector<uint8_t>* hash) const { GetPkHash(hash); }
190 191
191 virtual std::string GetName() const { return "Software Reporter Tool"; } 192 virtual std::string GetName() const { return "Software Reporter Tool"; }
192 193
193 static base::FilePath install_dir() { 194 static base::FilePath install_dir() {
194 // The base directory on windows looks like: 195 // The base directory on windows looks like:
195 // <profile>\AppData\Local\Google\Chrome\User Data\SwReporter\. 196 // <profile>\AppData\Local\Google\Chrome\User Data\SwReporter\.
196 base::FilePath result; 197 base::FilePath result;
197 PathService::Get(DIR_SW_REPORTER, &result); 198 PathService::Get(DIR_SW_REPORTER, &result);
198 return result; 199 return result;
199 } 200 }
200 201
201 static std::string ID() { 202 static std::string ID() {
202 CrxComponent component; 203 CrxComponent component;
203 component.version = Version("0.0.0.0"); 204 component.version = Version("0.0.0.0");
204 GetPkHash(&component.pk_hash); 205 GetPkHash(&component.pk_hash);
205 return component_updater::GetCrxComponentID(component); 206 return component_updater::GetCrxComponentID(component);
206 } 207 }
207 208
208 static base::FilePath VersionPath() { return base::FilePath(version_dir_); } 209 static base::FilePath VersionPath() { return base::FilePath(version_dir_); }
209 210
210 private: 211 private:
211 static void GetPkHash(std::vector<uint8>* hash) { 212 static void GetPkHash(std::vector<uint8_t>* hash) {
212 DCHECK(hash); 213 DCHECK(hash);
213 hash->assign(kSha256Hash, kSha256Hash + sizeof(kSha256Hash)); 214 hash->assign(kSha256Hash, kSha256Hash + sizeof(kSha256Hash));
214 } 215 }
215 216
216 PrefService* prefs_; 217 PrefService* prefs_;
217 static wchar_t version_dir_[_MAX_PATH]; 218 static wchar_t version_dir_[_MAX_PATH];
218 }; 219 };
219 220
220 wchar_t SwReporterInstallerTraits::version_dir_[] = {}; 221 wchar_t SwReporterInstallerTraits::version_dir_[] = {};
221 222
(...skipping 12 matching lines...) Expand all
234 DefaultComponentInstaller* installer = 235 DefaultComponentInstaller* installer =
235 new DefaultComponentInstaller(traits.Pass()); 236 new DefaultComponentInstaller(traits.Pass());
236 installer->Register(cus); 237 installer->Register(cus);
237 } 238 }
238 239
239 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) { 240 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry) {
240 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0); 241 registry->RegisterInt64Pref(prefs::kSwReporterLastTimeTriggered, 0);
241 } 242 }
242 243
243 } // namespace component_updater 244 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698