File: installer_api.cc

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (597 lines) | stat: -rw-r--r-- 22,076 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/updater/win/installer_api.h"

#include <algorithm>
#include <iterator>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "base/version.h"
#include "base/win/registry.h"
#include "chrome/updater/branded_constants.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/enum_traits.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
#include "components/update_client/update_client.h"

namespace updater {
namespace {

// Creates or opens the registry ClientState subkey for the `app_id`. `regsam`
// must contain the KEY_WRITE access right for the creation of the subkey to
// succeed.
std::optional<base::win::RegKey> ClientStateAppKeyCreate(
    UpdaterScope updater_scope,
    const std::string& app_id,
    REGSAM regsam) {
  std::wstring subkey;
  if (!base::UTF8ToWide(app_id.c_str(), app_id.size(), &subkey)) {
    return std::nullopt;
  }
  base::win::RegKey key(UpdaterScopeToHKeyRoot(updater_scope), CLIENT_STATE_KEY,
                        Wow6432(regsam));
  if (!key.Valid() ||
      key.CreateKey(subkey.c_str(), Wow6432(regsam)) != ERROR_SUCCESS) {
    return std::nullopt;
  }
  return key;
}

bool RegCopyValue(base::win::RegKey& from_key,
                  const std::wstring& from_value_name,
                  base::win::RegKey& to_key,
                  const std::wstring& to_value_name) {
  DWORD size = 0;
  if (from_key.ReadValue(from_value_name.c_str(), nullptr, &size, nullptr) !=
      ERROR_SUCCESS) {
    return false;
  }

  std::vector<char> raw_value(size);
  DWORD dtype = 0;
  if (from_key.ReadValue(from_value_name.c_str(), raw_value.data(), &size,
                         &dtype) != ERROR_SUCCESS) {
    return false;
  }

  if (to_key.WriteValue(to_value_name.c_str(), raw_value.data(), size, dtype) !=
      ERROR_SUCCESS) {
    PLOG(WARNING) << "could not write: " << to_value_name;
    return false;
  }
  return true;
}

bool RegRenameValue(base::win::RegKey& key,
                    const std::wstring& from_value_name,
                    const std::wstring& to_value_name) {
  if (!RegCopyValue(key, from_value_name, key, to_value_name)) {
    return false;
  }
  key.DeleteValue(from_value_name.c_str());
  return true;
}

void PersistLastInstallerResultValues(UpdaterScope updater_scope,
                                      const std::string& app_id) {
  std::optional<base::win::RegKey> key =
      ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ | KEY_WRITE);
  if (!key) {
    return;
  }

  // Rename `InstallerResultXXX` values to `LastXXX`.
  for (const auto& [rename_from, rename_to] : {
           std::make_pair(kRegValueInstallerResult,
                          kRegValueLastInstallerResult),
           std::make_pair(kRegValueInstallerError, kRegValueLastInstallerError),
           std::make_pair(kRegValueInstallerExtraCode1,
                          kRegValueLastInstallerExtraCode1),
           std::make_pair(kRegValueInstallerResultUIString,
                          kRegValueLastInstallerResultUIString),
           std::make_pair(kRegValueInstallerSuccessLaunchCmdLine,
                          kRegValueLastInstallerSuccessLaunchCmdLine),
       }) {
    RegRenameValue(key.value(), rename_from, rename_to);
  }

  // The updater copies and retains the last installer result values as a backup
  // under the `UPDATER_KEY`, and the values under the `UPDATER_KEY` are not
  // deleted when the updater uninstalls itself. The MSI installer uses this
  // information to display the installer result in cases where an error occurs
  // during app installation and no other apps are installed, and the updater
  // immediately uninstalls itself and deletes the `ClientState` registry key
  // under which the last installer results are usually stored.
  if (base::win::RegKey updater_key(UpdaterScopeToHKeyRoot(updater_scope),
                                    UPDATER_KEY, Wow6432(KEY_WRITE));
      updater_key.Valid()) {
    for (const wchar_t* const reg_value_last_installer :
         kRegValuesLastInstaller) {
      RegCopyValue(key.value(), reg_value_last_installer, updater_key,
                   reg_value_last_installer);
    }
  }
}

bool ClientStateAppKeyExists(UpdaterScope updater_scope,
                             const std::string& app_id) {
  return base::win::RegKey(UpdaterScopeToHKeyRoot(updater_scope),
                           GetAppClientStateKey(app_id).c_str(),
                           Wow6432(KEY_QUERY_VALUE))
      .Valid();
}

std::optional<InstallerOutcome> GetLastInstallerOutcome(
    std::optional<base::win::RegKey> key) {
  if (!key) {
    return std::nullopt;
  }
  InstallerOutcome installer_outcome;
  {
    DWORD val = 0;
    if (key->ReadValueDW(kRegValueLastInstallerResult, &val) == ERROR_SUCCESS) {
      installer_outcome.installer_result =
          *CheckedCastToEnum<InstallerApiResult>(val);
    }
    if (key->ReadValueDW(kRegValueLastInstallerError, &val) == ERROR_SUCCESS) {
      installer_outcome.installer_error = val;
    }
    if (key->ReadValueDW(kRegValueLastInstallerExtraCode1, &val) ==
        ERROR_SUCCESS) {
      installer_outcome.installer_extracode1 = val;
    }
  }
  {
    std::wstring val;
    if (key->ReadValue(kRegValueLastInstallerResultUIString, &val) ==
        ERROR_SUCCESS) {
      std::string installer_text;
      if (base::WideToUTF8(val.c_str(), val.size(), &installer_text)) {
        installer_outcome.installer_text = installer_text;
      }
    }
    if (key->ReadValue(kRegValueLastInstallerSuccessLaunchCmdLine, &val) ==
        ERROR_SUCCESS) {
      std::string installer_cmd_line;
      if (base::WideToUTF8(val.c_str(), val.size(), &installer_cmd_line)) {
        installer_outcome.installer_cmd_line = installer_cmd_line;
      }
    }
  }

  return installer_outcome;
}

}  // namespace

InstallerOutcome::InstallerOutcome() = default;
InstallerOutcome::InstallerOutcome(const InstallerOutcome&) = default;
InstallerOutcome& InstallerOutcome::operator=(const InstallerOutcome&) =
    default;
InstallerOutcome::~InstallerOutcome() = default;

std::optional<base::win::RegKey> ClientStateAppKeyOpen(
    UpdaterScope updater_scope,
    const std::string& app_id,
    REGSAM regsam) {
  std::wstring subkey;
  if (!base::UTF8ToWide(app_id.c_str(), app_id.size(), &subkey)) {
    return std::nullopt;
  }
  base::win::RegKey key(UpdaterScopeToHKeyRoot(updater_scope), CLIENT_STATE_KEY,
                        Wow6432(regsam));
  if (!key.Valid() ||
      key.OpenKey(subkey.c_str(), Wow6432(regsam)) != ERROR_SUCCESS) {
    return std::nullopt;
  }
  return key;
}

bool ClientStateAppKeyDelete(UpdaterScope updater_scope,
                             const std::string& app_id) {
  std::wstring subkey;
  if (!base::UTF8ToWide(app_id.c_str(), app_id.size(), &subkey)) {
    return false;
  }
  return base::win::RegKey(UpdaterScopeToHKeyRoot(updater_scope),
                           CLIENT_STATE_KEY, Wow6432(DELETE))
             .DeleteKey(subkey.c_str()) == ERROR_SUCCESS;
}

// Reads the installer progress from the registry value at:
// {HKLM|HKCU}\Software\Google\Update\ClientState\<appid>\InstallerProgress.
int GetInstallerProgress(UpdaterScope updater_scope,
                         const std::string& app_id) {
  std::optional<base::win::RegKey> key =
      ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ);
  DWORD progress = 0;
  if (!key || key->ReadValueDW(kRegValueInstallerProgress, &progress) !=
                  ERROR_SUCCESS) {
    return -1;
  }
  return std::clamp(progress, DWORD{0}, DWORD{100});
}

bool SetInstallerProgressForTesting(UpdaterScope updater_scope,
                                    const std::string& app_id,
                                    int value) {
  std::optional<base::win::RegKey> key =
      ClientStateAppKeyCreate(updater_scope, app_id, KEY_WRITE);
  return key && key->WriteValue(kRegValueInstallerProgress,
                                static_cast<DWORD>(value)) == ERROR_SUCCESS;
}

bool DeleteInstallerProgress(UpdaterScope updater_scope,
                             const std::string& app_id) {
  if (!ClientStateAppKeyExists(updater_scope, app_id)) {
    return false;
  }
  std::optional<base::win::RegKey> key =
      ClientStateAppKeyOpen(updater_scope, app_id, KEY_SET_VALUE);
  return key && key->DeleteValue(kRegValueInstallerProgress) == ERROR_SUCCESS;
}

bool DeleteInstallerOutput(UpdaterScope updater_scope,
                           const std::string& app_id) {
  if (!ClientStateAppKeyExists(updater_scope, app_id)) {
    return false;
  }
  std::optional<base::win::RegKey> key = ClientStateAppKeyOpen(
      updater_scope, app_id, KEY_SET_VALUE | KEY_QUERY_VALUE);
  if (!key) {
    return false;
  }
  auto delete_value = [&key](const wchar_t* value) {
    return !key->HasValue(value) || key->DeleteValue(value) == ERROR_SUCCESS;
  };
  const bool results[] = {
      delete_value(kRegValueInstallerProgress),
      delete_value(kRegValueInstallerResult),
      delete_value(kRegValueInstallerError),
      delete_value(kRegValueInstallerExtraCode1),
      delete_value(kRegValueInstallerResultUIString),
      delete_value(kRegValueInstallerSuccessLaunchCmdLine),
  };
  return !base::Contains(results, false);
}

std::optional<InstallerOutcome> GetInstallerOutcome(UpdaterScope updater_scope,
                                                    const std::string& app_id) {
  std::optional<base::win::RegKey> key =
      ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ);
  if (!key) {
    return std::nullopt;
  }
  InstallerOutcome installer_outcome;
  {
    DWORD val = 0;
    if (key->ReadValueDW(kRegValueInstallerResult, &val) == ERROR_SUCCESS) {
      installer_outcome.installer_result =
          *CheckedCastToEnum<InstallerApiResult>(val);
    }
    if (key->ReadValueDW(kRegValueInstallerError, &val) == ERROR_SUCCESS) {
      installer_outcome.installer_error = val;
      VLOG_IF(1, !installer_outcome.installer_result)
          << "No `InstallerResult` found in the registry. `InstallerError` "
             "will be ignored: "
          << val;
    }
    if (key->ReadValueDW(kRegValueInstallerExtraCode1, &val) == ERROR_SUCCESS) {
      installer_outcome.installer_extracode1 = val;
      VLOG_IF(1, !installer_outcome.installer_result)
          << "No `InstallerResult` found in the registry. "
             "`InstallerExtraCode1` will be ignored: "
          << val;
    }
  }
  {
    std::wstring val;
    if (key->ReadValue(kRegValueInstallerResultUIString, &val) ==
        ERROR_SUCCESS) {
      std::string installer_text;
      if (base::WideToUTF8(val.c_str(), val.size(), &installer_text)) {
        installer_outcome.installer_text = installer_text;
        VLOG_IF(1, !installer_outcome.installer_result)
            << "No `InstallerResult` found in the registry. "
               "`InstallerResultUIString` will be ignored: "
            << installer_text;
      }
    }
    if (key->ReadValue(kRegValueInstallerSuccessLaunchCmdLine, &val) ==
        ERROR_SUCCESS) {
      std::string installer_cmd_line;
      if (base::WideToUTF8(val.c_str(), val.size(), &installer_cmd_line)) {
        installer_outcome.installer_cmd_line = installer_cmd_line;
        VLOG_IF(1, !installer_outcome.installer_result)
            << "No `InstallerResult` found in the registry. "
               "`InstallerSuccessLaunchCmdLine` will be ignored: "
            << installer_cmd_line;
      }
    }
  }

  PersistLastInstallerResultValues(updater_scope, app_id);

  return installer_outcome;
}

std::optional<InstallerOutcome> GetClientStateKeyLastInstallerOutcome(
    UpdaterScope updater_scope,
    const std::string& app_id) {
  return GetLastInstallerOutcome(
      ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ));
}

std::optional<InstallerOutcome> GetUpdaterKeyLastInstallerOutcome(
    UpdaterScope updater_scope) {
  return GetLastInstallerOutcome(
      [&updater_scope]() -> std::optional<base::win::RegKey> {
        if (base::win::RegKey updater_key(UpdaterScopeToHKeyRoot(updater_scope),
                                          UPDATER_KEY, Wow6432(KEY_READ));
            updater_key.Valid()) {
          return updater_key;
        }
        return {};
      }());
}

bool SetInstallerOutcomeForTesting(UpdaterScope updater_scope,
                                   const std::string& app_id,
                                   const InstallerOutcome& installer_outcome) {
  std::optional<base::win::RegKey> key =
      ClientStateAppKeyCreate(updater_scope, app_id, KEY_WRITE);
  if (!key) {
    return false;
  }
  if (installer_outcome.installer_result) {
    if (key->WriteValue(
            kRegValueInstallerResult,
            static_cast<DWORD>(*installer_outcome.installer_result)) !=
        ERROR_SUCCESS) {
      return false;
    }
  }
  if (installer_outcome.installer_error) {
    if (key->WriteValue(kRegValueInstallerError,
                        *installer_outcome.installer_error) != ERROR_SUCCESS) {
      return false;
    }
  }
  if (installer_outcome.installer_extracode1) {
    if (key->WriteValue(kRegValueInstallerExtraCode1,
                        *installer_outcome.installer_extracode1) !=
        ERROR_SUCCESS) {
      return false;
    }
  }
  if (installer_outcome.installer_text) {
    if (key->WriteValue(
            kRegValueInstallerResultUIString,
            base::UTF8ToWide(*installer_outcome.installer_text).c_str()) !=
        ERROR_SUCCESS) {
      return false;
    }
  }
  if (installer_outcome.installer_cmd_line) {
    if (key->WriteValue(
            kRegValueInstallerSuccessLaunchCmdLine,
            base::UTF8ToWide(*installer_outcome.installer_cmd_line).c_str()) !=
        ERROR_SUCCESS) {
      return false;
    }
  }
  return true;
}

// As much as possible, the implementation of this function is intended to be
// backward compatible with the implementation of the Installer API in
// Omaha/Google Update. Some edge cases could be missing.
Installer::Result MakeInstallerResult(
    std::optional<InstallerOutcome> installer_outcome,
    int exit_code) {
  InstallerOutcome outcome;
  if (installer_outcome && installer_outcome->installer_result) {
    outcome = *installer_outcome;
    if (*outcome.installer_result == InstallerApiResult::kExitCode &&
        !exit_code) {
      outcome.installer_result = InstallerApiResult::kSuccess;
    }
  } else {
    // Set the installer result based on whether this is a success or an error.
    if (!exit_code) {
      outcome.installer_result = InstallerApiResult::kSuccess;
    } else {
      outcome.installer_result = InstallerApiResult::kExitCode;
      outcome.installer_error = exit_code;
    }
  }

  Installer::Result result;

  // Read and set the installer extra code in all cases if available. Installers
  // can use the `installer_extracode1` to transmit a custom value even in the
  // case of success.
  if (outcome.installer_extracode1) {
    result.result.extra = *outcome.installer_extracode1;
  }

  switch (*outcome.installer_result) {
    case InstallerApiResult::kSuccess:
      // This is unconditional success:
      // - use the command line if available, and ignore everything else.
      if (outcome.installer_cmd_line) {
        result.installer_cmd_line = *outcome.installer_cmd_line;
      }
      break;

    case InstallerApiResult::kCustomError:
    case InstallerApiResult::kMsiError:
    case InstallerApiResult::kSystemError:
    case InstallerApiResult::kExitCode:
      // These are usually unconditional errors:
      // - use the installer error, or the exit code, or report a generic
      //   error.
      // - use the installer extra code if available.
      // - use the text description of the error if available.
      result.result.code = outcome.installer_error.value_or(exit_code);
      if (!result.result.code) {
        result.result.code = kErrorApplicationInstallerFailed;
      }

      // `update_client` needs to view the below codes as a success, otherwise
      // it will consider the app as not installed; set the error category to
      // kNone in this case.
      result.result.category =
          result.result.code == ERROR_SUCCESS_REBOOT_INITIATED ||
                  result.result.code == ERROR_SUCCESS_REBOOT_REQUIRED ||
                  result.result.code == ERROR_SUCCESS_RESTART_REQUIRED
              ? update_client::ErrorCategory::kNone
              : update_client::ErrorCategory::kInstaller;
      result.installer_text = outcome.installer_text.value_or("");
      CHECK_NE(result.result.code, 0);
      break;
  }

  return result;
}

// Clears the previous installer output, runs the application installer,
// queries the installer progress, then collects the process exit code, if
// waiting for the installer does not time out.
//
// Reports the exit code of the installer process as -1 if waiting for the
// process to exit times out.
//
// The installer progress is written by the application installer as a value
// under the application's client state in the Windows registry and read by
// polling in a loop, while waiting for the installer to exit.
InstallerResult RunApplicationInstaller(
    const AppInfo& app_info,
    const base::FilePath& app_installer,
    const std::string& arguments,
    std::optional<base::FilePath> installer_data_file,
    bool usage_stats_enabled,
    base::TimeDelta timeout,
    InstallProgressCallback progress_callback) {
  if (!app_installer.MatchesExtension(L".exe") &&
      !app_installer.MatchesExtension(L".msi")) {
    return InstallerResult(GOOPDATEINSTALL_E_FILENAME_INVALID,
                           kErrorInvalidFileExtension);
  }

  DeleteInstallerOutput(app_info.scope, app_info.app_id);

  const std::wstring argsw = base::UTF8ToWide(arguments);
  const std::wstring cmdline =
      app_installer.MatchesExtension(L".msi")
          ? BuildMsiCommandLine(argsw, installer_data_file, app_installer)
          : BuildExeCommandLine(argsw, installer_data_file, app_installer);
  VLOG(1) << "Running application installer: " << cmdline;

  base::LaunchOptions options;
  options.start_hidden = true;
  options.environment = {
      {ENV_GOOGLE_UPDATE_IS_MACHINE,
       IsSystemInstall(app_info.scope) ? L"1" : L"0"},
      {base::UTF8ToWide(kUsageStatsEnabled),
       usage_stats_enabled ? base::UTF8ToWide(kUsageStatsEnabledValueEnabled)
                           : L"0"},
  };

  base::TimeDelta retry_delay = kAlreadyRunningRetryInitialDelay;
  const base::ElapsedTimer timer;
  for (int num_tries = 0;
       timer.Elapsed() < timeout && num_tries < kNumAlreadyRunningMaxTries;
       ++num_tries) {
    if (num_tries > 0) {
      VLOG(1) << "Retrying: " << num_tries;
      base::PlatformThread::Sleep(retry_delay);
      retry_delay *= 2;  // Double the retry delay each time.
    }

    int exit_code = -1;
    base::TerminationStatus final_status =
        base::TerminationStatus::TERMINATION_STATUS_MAX_ENUM;
    std::ignore = base::GetAppOutputWithExitCodeAndTimeout(
        cmdline, true, nullptr, &exit_code, timeout - timer.Elapsed(), options,
        [&](std::string_view partial_output) {
          if (!partial_output.empty()) {
            VLOG(1) << "Installer output: " << partial_output;
          }

          const int progress =
              GetInstallerProgress(app_info.scope, app_info.app_id);
          VLOG(3) << "installer progress: " << progress;
          progress_callback.Run(progress);
        },
        &final_status);

    if (final_status ==
        base::TerminationStatus::TERMINATION_STATUS_LAUNCH_FAILED) {
      VLOG(1) << "Installer failed to launch";
      return InstallerResult(GOOPDATEINSTALL_E_INSTALLER_FAILED_START,
                             HRESULTFromLastError());
    }
    if (final_status ==
        base::TerminationStatus::TERMINATION_STATUS_STILL_RUNNING) {
      VLOG(1) << "Installer timed out";
      return InstallerResult(GOOPDATEINSTALL_E_INSTALLER_TIMED_OUT);
    }

    const Installer::Result installer_result = MakeInstallerResult(
        GetInstallerOutcome(app_info.scope, app_info.app_id), exit_code);
    exit_code = installer_result.result.code;
    VLOG(1) << "Installer exit code: " << exit_code;
    if (exit_code != ERROR_INSTALL_ALREADY_RUNNING) {
      return installer_result;
    }
  }

  return InstallerResult(GOOPDATEINSTALL_E_INSTALL_ALREADY_RUNNING);
}

std::string LookupString(const base::FilePath& path,
                         const std::string& keyname,
                         const std::string& default_value) {
  return default_value;
}

base::Version LookupVersion(UpdaterScope scope,
                            const std::string& app_id,
                            const base::FilePath& /*version_path*/,
                            const std::string& /*version_key*/,
                            const base::Version& default_value) {
  std::wstring pv;
  if (base::win::RegKey(UpdaterScopeToHKeyRoot(scope),
                        GetAppClientsKey(app_id).c_str(), Wow6432(KEY_READ))
          .ReadValue(kRegValuePV, &pv) == ERROR_SUCCESS) {
    const base::Version value_version = base::Version(base::WideToUTF8(pv));
    return value_version.IsValid() ? value_version : default_value;
  }
  return default_value;
}

}  // namespace updater