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.
4
5#include "chrome/browser/first_run/upgrade_util.h"
6
7#include "base/base_paths.h"
8#include "base/command_line.h"
9#include "base/file_path.h"
10#include "base/file_util.h"
11#include "base/logging.h"
12#include "base/path_service.h"
13#include "base/platform_file.h"
14#include "base/process_util.h"
15#include "chrome/browser/first_run/upgrade_util_linux.h"
16
17namespace {
18
19double saved_last_modified_time_of_exe = 0;
20
21}  // namespace
22
23namespace upgrade_util {
24
25bool RelaunchChromeBrowser(const CommandLine& command_line) {
26  return base::LaunchApp(command_line, false, false, NULL);
27}
28
29bool IsUpdatePendingRestart() {
30  return saved_last_modified_time_of_exe != GetLastModifiedTimeOfExe();
31}
32
33void SaveLastModifiedTimeOfExe() {
34  saved_last_modified_time_of_exe = GetLastModifiedTimeOfExe();
35}
36
37double GetLastModifiedTimeOfExe() {
38  FilePath exe_file_path;
39  if (!PathService::Get(base::FILE_EXE, &exe_file_path)) {
40    LOG(WARNING) << "Failed to get FilePath object for FILE_EXE.";
41    return saved_last_modified_time_of_exe;
42  }
43  base::PlatformFileInfo exe_file_info;
44  if (!file_util::GetFileInfo(exe_file_path, &exe_file_info)) {
45    LOG(WARNING) << "Failed to get FileInfo object for FILE_EXE - "
46                 << exe_file_path.value();
47    return saved_last_modified_time_of_exe;
48  }
49  return exe_file_info.last_modified.ToDoubleT();
50}
51
52}  // namespace upgrade_util
53