blob: 22b252cb75b2694c28655082372fb53e1f88fc65 [file] [log] [blame]
[email protected]7688e3b2011-04-13 14:15:331// 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
[email protected]815856722011-04-13 17:19:195#include "chrome/browser/first_run/upgrade_util.h"
[email protected]7688e3b2011-04-13 14:15:336
7#include "base/base_paths.h"
8#include "base/command_line.h"
[email protected]7688e3b2011-04-13 14:15:339#include "base/file_util.h"
[email protected]57999812013-02-24 05:40:5210#include "base/files/file_path.h"
[email protected]7688e3b2011-04-13 14:15:3311#include "base/logging.h"
12#include "base/path_service.h"
13#include "base/platform_file.h"
14#include "base/process_util.h"
[email protected]3e087992011-04-14 22:28:1215#include "chrome/browser/first_run/upgrade_util_linux.h"
[email protected]7688e3b2011-04-13 14:15:3316
[email protected]815856722011-04-13 17:19:1917namespace {
18
[email protected]815856722011-04-13 17:19:1919double saved_last_modified_time_of_exe = 0;
[email protected]7688e3b2011-04-13 14:15:3320
[email protected]815856722011-04-13 17:19:1921} // namespace
[email protected]7688e3b2011-04-13 14:15:3322
[email protected]815856722011-04-13 17:19:1923namespace upgrade_util {
24
25bool RelaunchChromeBrowser(const CommandLine& command_line) {
[email protected]e5992182011-07-15 16:47:0226 return base::LaunchProcess(command_line, base::LaunchOptions(), NULL);
[email protected]7688e3b2011-04-13 14:15:3327}
28
[email protected]815856722011-04-13 17:19:1929bool IsUpdatePendingRestart() {
30 return saved_last_modified_time_of_exe != GetLastModifiedTimeOfExe();
[email protected]7688e3b2011-04-13 14:15:3331}
32
[email protected]815856722011-04-13 17:19:1933void SaveLastModifiedTimeOfExe() {
34 saved_last_modified_time_of_exe = GetLastModifiedTimeOfExe();
[email protected]7688e3b2011-04-13 14:15:3335}
36
[email protected]815856722011-04-13 17:19:1937double GetLastModifiedTimeOfExe() {
[email protected]650b2d52013-02-10 03:41:4538 base::FilePath exe_file_path;
[email protected]7688e3b2011-04-13 14:15:3339 if (!PathService::Get(base::FILE_EXE, &exe_file_path)) {
[email protected]650b2d52013-02-10 03:41:4540 LOG(WARNING) << "Failed to get base::FilePath object for FILE_EXE.";
[email protected]815856722011-04-13 17:19:1941 return saved_last_modified_time_of_exe;
[email protected]7688e3b2011-04-13 14:15:3342 }
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();
[email protected]815856722011-04-13 17:19:1947 return saved_last_modified_time_of_exe;
[email protected]7688e3b2011-04-13 14:15:3348 }
49 return exe_file_info.last_modified.ToDoubleT();
50}
[email protected]815856722011-04-13 17:19:1951
52} // namespace upgrade_util