diff options
author | prasadt@chromium.org <prasadt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 00:57:48 +0000 |
---|---|---|
committer | prasadt@chromium.org <prasadt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 00:57:48 +0000 |
commit | 2ce1d31d6c4c46ad185c49fbe8496396694f57c7 (patch) | |
tree | 63cb38f8c0cea76664ebc2d4f5e08237d5ef33df /chrome/browser/first_run_gtk.cc | |
parent | cd92d9ae828e3054af4582e3da8302cf6ad19e2e (diff) | |
download | chromium_src-2ce1d31d6c4c46ad185c49fbe8496396694f57c7.zip chromium_src-2ce1d31d6c4c46ad185c49fbe8496396694f57c7.tar.gz chromium_src-2ce1d31d6c4c46ad185c49fbe8496396694f57c7.tar.bz2 |
Detect new instance of the browser when running in the background in persistent
mode, shutdown and restart the new instance. This is already done for Windows,
this CL enables the functionality for Linux.
We don't yet have a unit test for this. Local testing is done by:
1) Reducing the timer to 30 seconds.
2) Changing BrowserList::IsInPersistentMode to return true.
3) Setting BrowserProcessImpl::autoupdate_timer_ to 30 seconds interval.
4) Running "touch" command on chrome exe to pretend there is an update.
BUG=40975
TEST=none
Review URL: http://codereview.chromium.org/1633021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/first_run_gtk.cc')
-rw-r--r-- | chrome/browser/first_run_gtk.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/first_run_gtk.cc b/chrome/browser/first_run_gtk.cc index a424d60..0755a7f 100644 --- a/chrome/browser/first_run_gtk.cc +++ b/chrome/browser/first_run_gtk.cc @@ -20,6 +20,8 @@ #include "chrome/installer/util/util_constants.h" #include "googleurl/src/gurl.h" +CommandLine* Upgrade::new_command_line_ = NULL; + bool OpenFirstRunDialog(Profile* profile, bool homepage_defined, int import_items, int dont_import_items, @@ -139,3 +141,47 @@ bool FirstRun::ImportBookmarks(const std::wstring& import_bookmarks_path) { // for the process to return. return base::LaunchApp(import_cmd, true, false, NULL); } + +#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) +double Upgrade::saved_last_modified_time_of_exe_ = 0; + +// static +bool Upgrade::IsUpdatePendingRestart() { + return saved_last_modified_time_of_exe_ != + Upgrade::GetLastModifiedTimeOfExe(); +} + +// static +void Upgrade::SaveLastModifiedTimeOfExe() { + saved_last_modified_time_of_exe_ = Upgrade::GetLastModifiedTimeOfExe(); +} + +// static +void Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded() { + if (new_command_line_) { + if (!base::LaunchApp(*new_command_line_, false, false, NULL)) { + DLOG(ERROR) << "Launching a new instance of the browser failed."; + } else { + DLOG(WARNING) << "Launched a new instance of the browser."; + } + delete new_command_line_; + new_command_line_ = NULL; + } +} + +// static +double Upgrade::GetLastModifiedTimeOfExe() { + FilePath exe_file_path; + if (!PathService::Get(base::FILE_EXE, &exe_file_path)) { + LOG(WARNING) << "Failed to get FilePath object for FILE_EXE."; + return saved_last_modified_time_of_exe_; + } + file_util::FileInfo exe_file_info; + if (!file_util::GetFileInfo(exe_file_path, &exe_file_info)) { + LOG(WARNING) << "Failed to get FileInfo object for FILE_EXE - " + << exe_file_path.value(); + return saved_last_modified_time_of_exe_; + } + return exe_file_info.last_modified.ToDoubleT(); +} +#endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |