Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 #ifndef CHROME_BROWSER_FIRST_RUN_UPGRADE_UTILS_H_ | |
| 6 #define CHROME_BROWSER_FIRST_RUN_UPGRADE_UTILS_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "build/build_config.h" | |
| 10 | |
| 11 class CommandLine; | |
| 12 | |
| 13 #if defined(OS_WIN) | |
| 14 class ProcessSingleton; | |
| 15 #endif | |
| 16 | |
| 17 namespace upgrade_utils { | |
| 18 | |
| 19 void SetNewCommandLine(CommandLine* new_command_line); | |
| 20 | |
| 21 // Launches a new instance of the browser if the current instance in persistent | |
| 22 // mode an upgrade is detected. | |
| 23 void RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | |
| 24 | |
| 25 // Launches chrome again simulating a 'user' launch. If chrome could not be | |
| 26 // launched the return is false. | |
| 27 bool RelaunchChromeBrowser(const CommandLine& command_line); | |
| 28 | |
| 29 // Windows: | |
| 30 // Checks if chrome_new.exe is present in the current instance's install. | |
| 31 // Linux: | |
| 32 // Checks if the last modified time of chrome is newer than that of the current | |
| 33 // running instance. | |
| 34 bool IsUpdatePendingRestart(); | |
| 35 | |
| 36 #if defined(OS_WIN) | |
| 37 // Possible results of ShowTryChromeDialog(). | |
| 38 enum TryResult { | |
| 39 TRY_CHROME, // Launch chrome right now. | |
| 40 NOT_NOW, // Don't launch chrome. Exit now. | |
| 41 UNINSTALL_CHROME, // Initiate chrome uninstall and exit. | |
| 42 DIALOG_ERROR, // An error occurred creating the dialog. | |
| 43 COUNT | |
| 44 }; | |
| 45 | |
| 46 // Check if current chrome.exe is already running as a browser process by | |
| 47 // trying to create a Global event with name same as full path of chrome.exe. | |
| 48 // This method caches the handle to this event so on subsequent calls also | |
| 49 // it can first close the handle and check for any other process holding the | |
| 50 // handle to the event. | |
| 51 bool IsBrowserAlreadyRunning(); | |
| 52 | |
| 53 // If the new_chrome.exe exists (placed by the installer then is swapped | |
| 54 // to chrome.exe and the old chrome is renamed to old_chrome.exe. If there | |
| 55 // is no new_chrome.exe or the swap fails the return is false; | |
| 56 bool SwapNewChromeExeIfPresent(); | |
| 57 | |
| 58 // Combines the two methods, RelaunchChromeBrowser and | |
| 59 // SwapNewChromeExeIfPresent, to perform the rename and relaunch of | |
| 60 // the browser. Note that relaunch does NOT exit the existing browser process. | |
| 61 // If this is called before message loop is executed, simply exit the main | |
| 62 // function. If browser is already running, you will need to exit it. | |
| 63 bool DoUpgradeTasks(const CommandLine& command_line); | |
| 64 | |
| 65 // Shows a modal dialog asking the user to give chrome another try. See | |
| 66 // above for the possible outcomes of the function. This is an experimental, | |
| 67 // non-localized dialog. | |
| 68 // |version| can be 0, 1 or 2 and selects what strings to present. | |
| 69 // |process_singleton| needs to be valid and it will be locked while | |
| 70 // the dialog is shown. | |
| 71 TryResult ShowTryChromeDialog(size_t version, | |
|
James Hawkins
2011/04/13 00:49:08
Further refactoring of this file is needed. I'm no
tfarina
2011/04/13 01:06:37
Sure, I'll move that function out with the TryResu
| |
| 72 ProcessSingleton* process_singleton); | |
| 73 #endif // OS_WIN | |
| 74 | |
| 75 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 76 void SaveLastModifiedTimeOfExe(); | |
| 77 | |
| 78 double GetLastModifiedTimeOfExe(); | |
| 79 #endif | |
| 80 | |
| 81 } // namespace upgrade_utils | |
| 82 | |
| 83 #endif // CHROME_BROWSER_FIRST_RUN_UPGRADE_UTILS_H_ | |
| OLD | NEW |