Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / first_run / upgrade_util_linux.cc
blob65e4f95285719801e214874d71e9b66d501d8c65
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/first_run/upgrade_util.h"
7 #include "base/base_paths.h"
8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h"
11 #include "base/logging.h"
12 #include "base/path_service.h"
13 #include "base/process/launch.h"
14 #include "chrome/browser/first_run/upgrade_util_linux.h"
16 namespace {
18 double saved_last_modified_time_of_exe = 0;
20 } // namespace
22 namespace upgrade_util {
24 bool RelaunchChromeBrowser(const base::CommandLine& command_line) {
25 base::LaunchOptions options;
26 // Don't set NO_NEW_PRIVS on the relaunched browser process.
27 options.allow_new_privs = true;
28 return base::LaunchProcess(command_line, options).IsValid();
31 bool IsUpdatePendingRestart() {
32 return saved_last_modified_time_of_exe != GetLastModifiedTimeOfExe();
35 void SaveLastModifiedTimeOfExe() {
36 saved_last_modified_time_of_exe = GetLastModifiedTimeOfExe();
39 double GetLastModifiedTimeOfExe() {
40 base::FilePath exe_file_path;
41 if (!PathService::Get(base::FILE_EXE, &exe_file_path)) {
42 LOG(WARNING) << "Failed to get base::FilePath object for FILE_EXE.";
43 return saved_last_modified_time_of_exe;
45 base::File::Info exe_file_info;
46 if (!base::GetFileInfo(exe_file_path, &exe_file_info)) {
47 LOG(WARNING) << "Failed to get FileInfo object for FILE_EXE - "
48 << exe_file_path.value();
49 return saved_last_modified_time_of_exe;
51 return exe_file_info.last_modified.ToDoubleT();
54 } // namespace upgrade_util