summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 14:15:33 +0000
committersiggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 14:15:33 +0000
commit7688e3b9aa44d3b7f455cd8a8ec8c1b9ee16a4a0 (patch)
tree6875549a37cb19d59e61a7485739c3e2ac2910ba
parentd55cedb42908a385195ea8502ed252893129a951 (diff)
downloadchromium_src-7688e3b9aa44d3b7f455cd8a8ec8c1b9ee16a4a0.zip
chromium_src-7688e3b9aa44d3b7f455cd8a8ec8c1b9ee16a4a0.tar.gz
chromium_src-7688e3b9aa44d3b7f455cd8a8ec8c1b9ee16a4a0.tar.bz2
Broke ARM compile.
Revert 81409 - first-run: Refactor Upgrade class into a common upgrade_util API.BUG=79203TEST=NoneR=jhawkins@chromium.orgReview URL: http://codereview.chromium.org/6840003 TBR=tfarina@chromium.org Review URL: http://codereview.chromium.org/6835022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81412 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chrome_exe_main_gtk.cc4
-rw-r--r--chrome/browser/browser_main.cc20
-rw-r--r--chrome/browser/browser_main_win.cc4
-rw-r--r--chrome/browser/browser_process_impl.cc6
-rw-r--r--chrome/browser/browser_shutdown.cc8
-rw-r--r--chrome/browser/first_run/try_chrome_dialog_view.cc20
-rw-r--r--chrome/browser/first_run/try_chrome_dialog_view.h6
-rw-r--r--chrome/browser/first_run/upgrade.cc21
-rw-r--r--chrome/browser/first_run/upgrade.h96
-rw-r--r--chrome/browser/first_run/upgrade_gtk.cc (renamed from chrome/browser/first_run/upgrade_util_linux.cc)36
-rw-r--r--chrome/browser/first_run/upgrade_util.cc34
-rw-r--r--chrome/browser/first_run/upgrade_util.h83
-rw-r--r--chrome/browser/first_run/upgrade_win.cc (renamed from chrome/browser/first_run/upgrade_util_win.cc)57
-rw-r--r--chrome/browser/process_singleton.h3
-rw-r--r--chrome/chrome_browser.gypi24
-rw-r--r--chrome/installer/setup/install_worker.cc4
16 files changed, 217 insertions, 209 deletions
diff --git a/chrome/app/chrome_exe_main_gtk.cc b/chrome/app/chrome_exe_main_gtk.cc
index 1e3fa0e..bf9589d 100644
--- a/chrome/app/chrome_exe_main_gtk.cc
+++ b/chrome/app/chrome_exe_main_gtk.cc
@@ -6,7 +6,7 @@
#include "build/build_config.h"
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#endif
// The entry point for all invocations of Chromium, browser and renderer. On
@@ -51,7 +51,7 @@ int main(int argc, const char** argv) {
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Launch a new instance if we're shutting down because we detected an
// upgrade in the persistent mode.
- upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
+ Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
#endif
return return_code;
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index e252687..746ae30 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -41,7 +41,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extensions_startup.h"
#include "chrome/browser/first_run/first_run.h"
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#include "chrome/browser/gpu_data_manager.h"
#include "chrome/browser/jankometer.h"
#include "chrome/browser/metrics/histogram_synchronizer.h"
@@ -1052,7 +1052,7 @@ DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
// deletions. We need this new instance because, the old instance created
// in ChromeMain() got destructed when the function returned.
base::AtExitManager exit_manager;
- upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
+ Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
}
#endif
@@ -1234,15 +1234,15 @@ int BrowserMain(const MainFunctionParams& parameters) {
// It seems that we don't need to run the experiment since chrome
// in the same profile is already running.
VLOG(1) << "Retention experiment not required";
- return upgrade_util::NOT_NOW;
+ return Upgrade::NOT_NOW;
}
int try_chrome_int;
base::StringToInt(try_chrome, &try_chrome_int);
- upgrade_util::TryResult answer =
- upgrade_util::ShowTryChromeDialog(try_chrome_int, &process_singleton);
- if (answer == upgrade_util::NOT_NOW)
+ Upgrade::TryResult answer =
+ Upgrade::ShowTryChromeDialog(try_chrome_int, &process_singleton);
+ if (answer == Upgrade::NOT_NOW)
return ResultCodes::NORMAL_EXIT_CANCEL;
- if (answer == upgrade_util::UNINSTALL_CHROME)
+ if (answer == Upgrade::UNINSTALL_CHROME)
return ResultCodes::NORMAL_EXIT_EXP2;
#else
// We don't support retention experiments on Mac or Linux.
@@ -1342,7 +1342,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
// On Windows, we use our startup as an opportunity to do upgrade/uninstall
// tasks. Those care whether the browser is already running. On Linux/Mac,
// upgrade/uninstall happen separately.
- bool already_running = upgrade_util::IsBrowserAlreadyRunning();
+ bool already_running = Upgrade::IsBrowserAlreadyRunning();
// If the command line specifies 'uninstall' then we need to work here
// unless we detect another chrome browser running.
@@ -1485,7 +1485,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
#if defined(OS_WIN)
// Do the tasks if chrome has been upgraded while it was last running.
- if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line))
+ if (!already_running && Upgrade::DoUpgradeTasks(parsed_command_line))
return ResultCodes::NORMAL_EXIT;
#endif
@@ -1803,7 +1803,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
// available while the browser is running. We need to save the last
// modified time of the exe, so we can compare to determine if there is
// an upgrade while the browser is kept alive by a persistent extension.
- upgrade_util::SaveLastModifiedTimeOfExe();
+ Upgrade::SaveLastModifiedTimeOfExe();
#endif
// Record now as the last successful chrome start.
diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc
index fc69fcd..ee8f9eb 100644
--- a/chrome/browser/browser_main_win.cc
+++ b/chrome/browser/browser_main_win.cc
@@ -21,7 +21,7 @@
#include "base/win/windows_version.h"
#include "base/win/wrapped_window_proc.h"
#include "chrome/browser/first_run/first_run.h"
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/uninstall_view.h"
@@ -110,7 +110,7 @@ int DoUninstallTasks(bool chrome_still_running) {
return ResultCodes::UNINSTALL_CHROME_ALIVE;
}
int ret = AskForUninstallConfirmation();
- if (upgrade_util::IsBrowserAlreadyRunning()) {
+ if (Upgrade::IsBrowserAlreadyRunning()) {
ShowCloseBrowserFirstMessageBox();
return ResultCodes::UNINSTALL_CHROME_ALIVE;
}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index f45f30c..c521e11 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -26,7 +26,7 @@
#include "chrome/browser/extensions/extension_event_router_forwarder.h"
#include "chrome/browser/extensions/extension_tab_id_map.h"
#include "chrome/browser/extensions/user_script_listener.h"
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#include "chrome/browser/google/google_url_tracker.h"
#include "chrome/browser/gpu_process_host_ui_shim.h"
#include "chrome/browser/icon_manager.h"
@@ -1000,7 +1000,7 @@ bool BrowserProcessImpl::CanAutorestartForUpdate() const {
// Check if browser is in the background and if it needs to be restarted to
// apply a pending update.
return BrowserList::size() == 0 && BrowserList::WillKeepAlive() &&
- upgrade_util::IsUpdatePendingRestart();
+ Upgrade::IsUpdatePendingRestart();
}
// Switches to add when auto-restarting Chrome.
@@ -1039,7 +1039,7 @@ void BrowserProcessImpl::RestartPersistentInstance() {
BrowserList::CloseAllBrowsersAndExit();
// Transfer ownership to Upgrade.
- upgrade_util::SetNewCommandLine(new_cl.release());
+ Upgrade::SetNewCommandLine(new_cl.release());
}
void BrowserProcessImpl::OnAutoupdateTimer() {
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index f5b5906..6c6d4fd 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -22,7 +22,7 @@
#include "build/build_config.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#include "chrome/browser/jankometer.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -189,9 +189,9 @@ void Shutdown() {
ResourceBundle::CleanupSharedInstance();
#if defined(OS_WIN)
- if (!upgrade_util::IsBrowserAlreadyRunning() &&
+ if (!Upgrade::IsBrowserAlreadyRunning() &&
shutdown_type_ != browser_shutdown::END_SESSION) {
- upgrade_util::SwapNewChromeExeIfPresent();
+ Upgrade::SwapNewChromeExeIfPresent();
}
#endif
@@ -225,7 +225,7 @@ void Shutdown() {
new_cl->AppendSwitch(switches::kRestoreLastSession);
#if defined(OS_WIN) || defined(OS_LINUX)
- upgrade_util::RelaunchChromeBrowser(*new_cl.get());
+ Upgrade::RelaunchChromeBrowser(*new_cl.get());
#endif // defined(OS_WIN) || defined(OS_LINUX)
#if defined(OS_MACOSX)
diff --git a/chrome/browser/first_run/try_chrome_dialog_view.cc b/chrome/browser/first_run/try_chrome_dialog_view.cc
index 6669887..5fa9aa2 100644
--- a/chrome/browser/first_run/try_chrome_dialog_view.cc
+++ b/chrome/browser/first_run/try_chrome_dialog_view.cc
@@ -36,13 +36,13 @@ TryChromeDialogView::TryChromeDialogView(size_t version)
popup_(NULL),
try_chrome_(NULL),
kill_chrome_(NULL),
- result_(upgrade_util::COUNT) {
+ result_(Upgrade::COUNT) {
}
TryChromeDialogView::~TryChromeDialogView() {
}
-upgrade_util::TryResult TryChromeDialogView::ShowModal(
+Upgrade::TryResult TryChromeDialogView::ShowModal(
ProcessSingleton* process_singleton) {
using views::GridLayout;
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -57,7 +57,7 @@ upgrade_util::TryResult TryChromeDialogView::ShowModal(
popup_ = views::Widget::CreateWidget(params);
if (!popup_) {
NOTREACHED();
- return upgrade_util::DIALOG_ERROR;
+ return Upgrade::DIALOG_ERROR;
}
gfx::Rect pos(310, 160);
@@ -71,7 +71,7 @@ upgrade_util::TryResult TryChromeDialogView::ShowModal(
views::GridLayout* layout = views::GridLayout::CreatePanel(root_view);
if (!layout) {
NOTREACHED();
- return upgrade_util::DIALOG_ERROR;
+ return Upgrade::DIALOG_ERROR;
}
root_view->SetLayoutManager(layout);
@@ -121,13 +121,13 @@ upgrade_util::TryResult TryChromeDialogView::ShowModal(
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
if (!dist) {
NOTREACHED() << "Cannot determine browser distribution";
- return upgrade_util::DIALOG_ERROR;
+ return Upgrade::DIALOG_ERROR;
}
BrowserDistribution::UserExperiment experiment;
if (!dist->GetExperimentDetails(&experiment, version_) ||
!experiment.heading) {
NOTREACHED() << "Cannot determine which headline to show.";
- return upgrade_util::DIALOG_ERROR;
+ return Upgrade::DIALOG_ERROR;
}
string16 heading = l10n_util::GetStringUTF16(experiment.heading);
views::Label* label = new views::Label(heading);
@@ -202,14 +202,14 @@ void TryChromeDialogView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender->tag() == BT_CLOSE_BUTTON) {
// The user pressed cancel or the [x] button.
- result_ = upgrade_util::NOT_NOW;
+ result_ = Upgrade::NOT_NOW;
} else if (!try_chrome_) {
// We don't have radio buttons, the user pressed ok.
- result_ = upgrade_util::TRY_CHROME;
+ result_ = Upgrade::TRY_CHROME;
} else {
// The outcome is according to the selected ratio button.
- result_ = try_chrome_->checked() ? upgrade_util::TRY_CHROME :
- upgrade_util::UNINSTALL_CHROME;
+ result_ = try_chrome_->checked() ? Upgrade::TRY_CHROME :
+ Upgrade::UNINSTALL_CHROME;
}
popup_->Close();
MessageLoop::current()->Quit();
diff --git a/chrome/browser/first_run/try_chrome_dialog_view.h b/chrome/browser/first_run/try_chrome_dialog_view.h
index 6abe776..a2fb243 100644
--- a/chrome/browser/first_run/try_chrome_dialog_view.h
+++ b/chrome/browser/first_run/try_chrome_dialog_view.h
@@ -8,7 +8,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#include "views/controls/button/button.h"
#include "views/controls/link.h"
#include "ui/gfx/native_widget_types.h"
@@ -47,7 +47,7 @@ class TryChromeDialogView : public views::ButtonListener,
// Shows the modal dialog asking the user to try chrome. Note that the dialog
// has no parent and it will position itself in a lower corner of the screen.
// The dialog does not steal focus and does not have an entry in the taskbar.
- upgrade_util::TryResult ShowModal(ProcessSingleton* process_singleton);
+ Upgrade::TryResult ShowModal(ProcessSingleton* process_singleton);
protected:
// views::ButtonListener:
@@ -87,7 +87,7 @@ class TryChromeDialogView : public views::ButtonListener,
views::Widget* popup_;
views::RadioButton* try_chrome_;
views::RadioButton* kill_chrome_;
- upgrade_util::TryResult result_;
+ Upgrade::TryResult result_;
DISALLOW_COPY_AND_ASSIGN(TryChromeDialogView);
};
diff --git a/chrome/browser/first_run/upgrade.cc b/chrome/browser/first_run/upgrade.cc
new file mode 100644
index 0000000..778f491
--- /dev/null
+++ b/chrome/browser/first_run/upgrade.cc
@@ -0,0 +1,21 @@
+// 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.
+
+#include "chrome/browser/first_run/upgrade.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+
+// static
+void Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
+ if (new_command_line_) {
+ if (!RelaunchChromeBrowser(*new_command_line_)) {
+ 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;
+ }
+}
diff --git a/chrome/browser/first_run/upgrade.h b/chrome/browser/first_run/upgrade.h
new file mode 100644
index 0000000..265e094
--- /dev/null
+++ b/chrome/browser/first_run/upgrade.h
@@ -0,0 +1,96 @@
+// 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_H_
+#define CHROME_BROWSER_FIRST_RUN_UPGRADE_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "build/build_config.h"
+
+class CommandLine;
+
+#if defined(OS_WIN)
+class ProcessSingleton;
+#endif
+
+// This class contains the actions that need to be performed when an upgrade
+// is required. This involves mainly swapping the chrome exe and relaunching
+// the new browser.
+class Upgrade {
+ public:
+#if defined(OS_WIN)
+ // Possible results of ShowTryChromeDialog().
+ enum TryResult {
+ TRY_CHROME, // Launch chrome right now.
+ NOT_NOW, // Don't launch chrome. Exit now.
+ UNINSTALL_CHROME, // Initiate chrome uninstall and exit.
+ DIALOG_ERROR, // An error occurred creating the dialog.
+ COUNT
+ };
+
+ // 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.
+ static 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;
+ static 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.
+ static bool DoUpgradeTasks(const CommandLine& command_line);
+
+ // Shows a modal dialog asking the user to give chrome another try. See
+ // above for the possible outcomes of the function. This is an experimental,
+ // non-localized dialog.
+ // |version| can be 0, 1 or 2 and selects what strings to present.
+ // |process_singleton| needs to be valid and it will be locked while
+ // the dialog is shown.
+ static TryResult ShowTryChromeDialog(size_t version,
+ ProcessSingleton* process_singleton);
+#endif // OS_WIN
+
+ // Launches chrome again simulating a 'user' launch. If chrome could not
+ // be launched the return is false.
+ static bool RelaunchChromeBrowser(const CommandLine& command_line);
+
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ static void SaveLastModifiedTimeOfExe();
+#endif
+
+ static void SetNewCommandLine(CommandLine* new_command_line) {
+ // Takes ownership of the pointer.
+ new_command_line_ = new_command_line;
+ }
+
+ // Launches a new instance of the browser if the current instance in
+ // persistent mode an upgrade is detected.
+ static void RelaunchChromeBrowserWithNewCommandLineIfNeeded();
+
+ // 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.
+ static bool IsUpdatePendingRestart();
+
+ private:
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ static double GetLastModifiedTimeOfExe();
+ static double saved_last_modified_time_of_exe_;
+#endif
+ static CommandLine* new_command_line_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(Upgrade);
+};
+
+#endif // CHROME_BROWSER_FIRST_RUN_UPGRADE_H_
diff --git a/chrome/browser/first_run/upgrade_util_linux.cc b/chrome/browser/first_run/upgrade_gtk.cc
index 6c3fb88..419e58f 100644
--- a/chrome/browser/first_run/upgrade_util_linux.cc
+++ b/chrome/browser/first_run/upgrade_gtk.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#include "base/base_paths.h"
#include "base/command_line.h"
@@ -13,39 +13,43 @@
#include "base/platform_file.h"
#include "base/process_util.h"
-namespace {
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// static
+CommandLine* Upgrade::new_command_line_ = NULL;
-double saved_last_modified_time_of_exe = 0;
+// static
+double Upgrade::saved_last_modified_time_of_exe_ = 0;
-} // namespace
-
-namespace upgrade_util {
-
-bool RelaunchChromeBrowser(const CommandLine& command_line) {
+// static
+bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) {
return base::LaunchApp(command_line, false, false, NULL);
}
-bool IsUpdatePendingRestart() {
- return saved_last_modified_time_of_exe != GetLastModifiedTimeOfExe();
+// static
+void Upgrade::SaveLastModifiedTimeOfExe() {
+ saved_last_modified_time_of_exe_ = Upgrade::GetLastModifiedTimeOfExe();
}
-void SaveLastModifiedTimeOfExe() {
- saved_last_modified_time_of_exe = GetLastModifiedTimeOfExe();
+// static
+bool Upgrade::IsUpdatePendingRestart() {
+ return saved_last_modified_time_of_exe_ !=
+ Upgrade::GetLastModifiedTimeOfExe();
}
-double GetLastModifiedTimeOfExe() {
+// 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;
+ return saved_last_modified_time_of_exe_;
}
base::PlatformFileInfo 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 saved_last_modified_time_of_exe_;
}
return exe_file_info.last_modified.ToDoubleT();
}
-} // namespace upgrade_util
+#endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
diff --git a/chrome/browser/first_run/upgrade_util.cc b/chrome/browser/first_run/upgrade_util.cc
deleted file mode 100644
index 7e700aa..0000000
--- a/chrome/browser/first_run/upgrade_util.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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.
-
-#include "chrome/browser/first_run/upgrade_util.h"
-
-#include "base/command_line.h"
-#include "base/logging.h"
-
-namespace {
-
-CommandLine* command_line;
-
-} // namespace
-
-namespace upgrade_util {
-
-void SetNewCommandLine(CommandLine* new_command_line) {
- command_line = new_command_line;
-}
-
-void RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
- if (command_line) {
- if (!RelaunchChromeBrowser(*command_line)) {
- DLOG(ERROR) << "Launching a new instance of the browser failed.";
- } else {
- DLOG(WARNING) << "Launched a new instance of the browser.";
- }
- delete command_line;
- command_line = NULL;
- }
-}
-
-} // namespace upgrade_util
diff --git a/chrome/browser/first_run/upgrade_util.h b/chrome/browser/first_run/upgrade_util.h
deleted file mode 100644
index c5b4c6e..0000000
--- a/chrome/browser/first_run/upgrade_util.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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)
-// Possible results of ShowTryChromeDialog().
-enum TryResult {
- TRY_CHROME, // Launch chrome right now.
- NOT_NOW, // Don't launch chrome. Exit now.
- UNINSTALL_CHROME, // Initiate chrome uninstall and exit.
- DIALOG_ERROR, // An error occurred creating the dialog.
- COUNT
-};
-
-// 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);
-
-// Shows a modal dialog asking the user to give chrome another try. See
-// above for the possible outcomes of the function. This is an experimental,
-// non-localized dialog.
-// |version| can be 0, 1 or 2 and selects what strings to present.
-// |process_singleton| needs to be valid and it will be locked while
-// the dialog is shown.
-TryResult ShowTryChromeDialog(size_t version,
- ProcessSingleton* process_singleton);
-#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_
diff --git a/chrome/browser/first_run/upgrade_util_win.cc b/chrome/browser/first_run/upgrade_win.cc
index ee01ffe..42f3b74 100644
--- a/chrome/browser/first_run/upgrade_util_win.cc
+++ b/chrome/browser/first_run/upgrade_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/first_run/upgrade_util.h"
+#include "chrome/browser/first_run/upgrade.h"
#include <algorithm>
#include <string>
@@ -60,24 +60,11 @@ bool InvokeGoogleUpdateForRename() {
} // namespace
+// static
+CommandLine* Upgrade::new_command_line_ = NULL;
-namespace upgrade_util {
-
-bool RelaunchChromeBrowser(const CommandLine& command_line) {
- scoped_ptr<base::Environment> env(base::Environment::Create());
- env->UnSetVar(chrome::kChromeVersionEnvVar);
- return base::LaunchApp(
- command_line.command_line_string(), false, false, NULL);
-}
-
-bool IsUpdatePendingRestart() {
- FilePath new_chrome_exe;
- if (!GetNewerChromeFile(&new_chrome_exe))
- return false;
- return file_util::PathExists(new_chrome_exe);
-}
-
-bool IsBrowserAlreadyRunning() {
+// static
+bool Upgrade::IsBrowserAlreadyRunning() {
static HANDLE handle = NULL;
FilePath exe_path;
PathService::Get(base::FILE_EXE, &exe_path);
@@ -92,7 +79,8 @@ bool IsBrowserAlreadyRunning() {
return (error == ERROR_ALREADY_EXISTS || error == ERROR_ACCESS_DENIED);
}
-bool SwapNewChromeExeIfPresent() {
+// static
+bool Upgrade::SwapNewChromeExeIfPresent() {
FilePath new_chrome_exe;
if (!GetNewerChromeFile(&new_chrome_exe))
return false;
@@ -127,26 +115,43 @@ bool SwapNewChromeExeIfPresent() {
return InvokeGoogleUpdateForRename();
}
-bool DoUpgradeTasks(const CommandLine& command_line) {
- if (!SwapNewChromeExeIfPresent())
+// static
+bool Upgrade::DoUpgradeTasks(const CommandLine& command_line) {
+ if (!Upgrade::SwapNewChromeExeIfPresent())
return false;
// At this point the chrome.exe has been swapped with the new one.
- if (!RelaunchChromeBrowser(command_line)) {
+ if (!Upgrade::RelaunchChromeBrowser(command_line)) {
// The re-launch fails. Feel free to panic now.
NOTREACHED();
}
return true;
}
-TryResult ShowTryChromeDialog(size_t version,
- ProcessSingleton* process_singleton) {
+// static
+Upgrade::TryResult Upgrade::ShowTryChromeDialog(
+ size_t version,
+ ProcessSingleton* process_singleton) {
if (version > 10000) {
// This is a test value. We want to make sure we exercise
// returning this early. See EarlyReturnTest test harness.
- return NOT_NOW;
+ return Upgrade::NOT_NOW;
}
TryChromeDialogView dialog(version);
return dialog.ShowModal(process_singleton);
}
-} // namespace upgrade_util
+// static
+bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) {
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ env->UnSetVar(chrome::kChromeVersionEnvVar);
+ return base::LaunchApp(
+ command_line.command_line_string(), false, false, NULL);
+}
+
+// static
+bool Upgrade::IsUpdatePendingRestart() {
+ FilePath new_chrome_exe;
+ if (!GetNewerChromeFile(&new_chrome_exe))
+ return false;
+ return file_util::PathExists(new_chrome_exe);
+}
diff --git a/chrome/browser/process_singleton.h b/chrome/browser/process_singleton.h
index 5d6da98..cba8abd 100644
--- a/chrome/browser/process_singleton.h
+++ b/chrome/browser/process_singleton.h
@@ -82,8 +82,7 @@ class ProcessSingleton : public base::NonThreadSafe {
// Used in specific cases to let us know that there is an existing instance
// of Chrome running with this profile. In general, you should not use this
// function. Instead consider using NotifyOtherProcessOrCreate().
- // For non profile-specific method, use
- // upgrade_util::IsBrowserAlreadyRunning().
+ // For non profile-specific method, use Upgrade::IsBrowserAlreadyRunning().
bool FoundOtherProcessWindow() const {
return (NULL != remote_window_);
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index f288a04..3a639ea 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1062,10 +1062,10 @@
'browser/first_run/first_run_gtk.cc',
'browser/first_run/first_run_mac.mm',
'browser/first_run/first_run_win.cc',
- 'browser/first_run/upgrade_util.cc',
- 'browser/first_run/upgrade_util.h',
- 'browser/first_run/upgrade_util_linux.cc',
- 'browser/first_run/upgrade_util_win.cc',
+ 'browser/first_run/upgrade.cc',
+ 'browser/first_run/upgrade.h',
+ 'browser/first_run/upgrade_gtk.cc',
+ 'browser/first_run/upgrade_win.cc',
'browser/first_run/try_chrome_dialog_view.cc',
'browser/first_run/try_chrome_dialog_view.h',
'browser/fullscreen.h',
@@ -3418,8 +3418,8 @@
['chromeos==1', {
'sources!': [
'browser/background_mode_manager_linux.cc',
- 'browser/first_run/upgrade_util.cc',
- 'browser/first_run/upgrade_util.h',
+ 'browser/first_run/upgrade.cc',
+ 'browser/first_run/upgrade.h',
'browser/password_manager/native_backend_gnome_x.cc',
'browser/password_manager/native_backend_gnome_x.h',
'browser/password_manager/native_backend_kwallet_x.cc',
@@ -3487,8 +3487,8 @@
],
'sources': [
'browser/crash_handler_host_linux.h',
- 'browser/first_run/upgrade_util.cc',
- 'browser/first_run/upgrade_util.h',
+ 'browser/first_run/upgrade.cc',
+ 'browser/first_run/upgrade.h',
],
'conditions': [
['use_gnome_keyring==1', {
@@ -3552,8 +3552,8 @@
'browser/automation/automation_provider_list_generic.cc',
'browser/bookmarks/bookmark_context_menu.cc',
'browser/bookmarks/bookmark_drop_info.cc',
- 'browser/first_run/upgrade_util.cc',
- 'browser/first_run/upgrade_util.h',
+ 'browser/first_run/upgrade.cc',
+ 'browser/first_run/upgrade.h',
'browser/importer/nss_decryptor_system_nss.cc',
'browser/importer/nss_decryptor_system_nss.h',
'browser/jankometer.cc',
@@ -3714,8 +3714,8 @@
}
},
'sources': [
- 'browser/first_run/upgrade_util.cc',
- 'browser/first_run/upgrade_util.h',
+ 'browser/first_run/upgrade.cc',
+ 'browser/first_run/upgrade.h',
# Using built-in rule in vstudio for midl.
'browser/history/history_indexer.idl',
'browser/ui/webui/conflicts_ui.cc',
diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc
index da91368..7bdc9e5 100644
--- a/chrome/installer/setup/install_worker.cc
+++ b/chrome/installer/setup/install_worker.cc
@@ -395,7 +395,7 @@ bool AppendPostInstallTasks(const InstallerState& installer_state,
// However, as it stands, we don't have a way to know which distribution
// will check the key and run the command, so we add it for all.
// After the first run, the subsequent runs should just be noops.
- // (see upgrade_utils::SwapNewChromeExeIfPresent).
+ // (see Upgrade::SwapNewChromeExeIfPresent).
CommandLine product_rename_cmd(rename);
products[i]->AppendProductFlags(&product_rename_cmd);
in_use_update_work_items->AddSetRegValueWorkItem(
@@ -416,7 +416,7 @@ bool AppendPostInstallTasks(const InstallerState& installer_state,
UTF8ToWide(current_version->GetString()),
true);
// TODO(tommi): We should move the rename command here. We also need to
- // update upgrade_utils::SwapNewChromeExeIfPresent.
+ // update Upgrade::SwapNewChromeExeIfPresent.
}
post_install_task_list->AddWorkItem(in_use_update_work_items.release());