summaryrefslogtreecommitdiffstats
path: root/chrome/browser/first_run/upgrade_util.h
blob: 322073c65badd9e610a9cea12a7fdf71ef42e580 (plain)
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
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_FIRST_RUN_UPGRADE_UTIL_H_
#define CHROME_BROWSER_FIRST_RUN_UPGRADE_UTIL_H_
#pragma once

#include "build/build_config.h"

class CommandLine;

#if defined(OS_WIN)
class ProcessSingleton;
#endif

namespace upgrade_util {

void SetNewCommandLine(CommandLine* new_command_line);

// Launches a new instance of the browser if the current instance in persistent
// mode an upgrade is detected.
void RelaunchChromeBrowserWithNewCommandLineIfNeeded();

// Launches chrome again simulating a 'user' launch. If chrome could not be
// launched the return is false.
bool RelaunchChromeBrowser(const CommandLine& command_line);

// Windows:
//  Checks if chrome_new.exe is present in the current instance's install.
// Linux:
//  Checks if the last modified time of chrome is newer than that of the current
//  running instance.
bool IsUpdatePendingRestart();

#if defined(OS_WIN)
// Check if current chrome.exe is already running as a browser process by
// trying to create a Global event with name same as full path of chrome.exe.
// This method caches the handle to this event so on subsequent calls also
// it can first close the handle and check for any other process holding the
// handle to the event.
bool IsBrowserAlreadyRunning();

// If the new_chrome.exe exists (placed by the installer then is swapped
// to chrome.exe and the old chrome is renamed to old_chrome.exe. If there
// is no new_chrome.exe or the swap fails the return is false;
bool SwapNewChromeExeIfPresent();

// Combines the two methods, RelaunchChromeBrowser and
// SwapNewChromeExeIfPresent, to perform the rename and relaunch of
// the browser. Note that relaunch does NOT exit the existing browser process.
// If this is called before message loop is executed, simply exit the main
// function. If browser is already running, you will need to exit it.
bool DoUpgradeTasks(const CommandLine& command_line);

#endif  // OS_WIN

#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
void SaveLastModifiedTimeOfExe();

double GetLastModifiedTimeOfExe();
#endif

}  // namespace upgrade_util

#endif  // CHROME_BROWSER_FIRST_RUN_UPGRADE_UTIL_H_