diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 21:37:46 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 21:37:46 +0000 |
commit | 68c921f8b5d6454307645d4017a3cbf2646904bc (patch) | |
tree | fdd0d0138a4ce706e052de4bab66fa3c4b28b8d4 /chrome/browser/browser_main.cc | |
parent | 9c6c3065723227dee6bca91df24bb6863ac123f9 (diff) | |
download | chromium_src-68c921f8b5d6454307645d4017a3cbf2646904bc.zip chromium_src-68c921f8b5d6454307645d4017a3cbf2646904bc.tar.gz chromium_src-68c921f8b5d6454307645d4017a3cbf2646904bc.tar.bz2 |
Add a check in Chrome to not run user level mode if machine level Chrome
is already installed.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_main.cc')
-rw-r--r-- | chrome/browser/browser_main.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 758d261..049a402 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -49,6 +49,9 @@ #include "chrome/common/pref_service.h" #include "chrome/common/win_util.h" #include "chrome/installer/util/google_update_settings.h" +#include "chrome/installer/util/helper.h" +#include "chrome/installer/util/install_util.h" +#include "chrome/installer/util/version.h" #include "chrome/views/accelerator_handler.h" #include "net/base/net_module.h" #include "net/base/net_resources.h" @@ -221,6 +224,39 @@ bool CreateUniqueChromeEvent() { return already_running; } +// Check if there is any machine level Chrome installed on the current +// machine. If yes and the current Chrome process is user level, we do not +// allow the user level Chrome to run. So we notify the user and uninstall +// user level Chrome. +bool CheckMachineLevelInstall() { + scoped_ptr<installer::Version> version(InstallUtil::GetChromeVersion(true)); + if (version.get()) { + std::wstring exe; + PathService::Get(base::DIR_EXE, &exe); + std::transform(exe.begin(), exe.end(), exe.begin(), tolower); + std::wstring user_exe_path = installer::GetChromeInstallPath(false); + std::transform(user_exe_path.begin(), user_exe_path.end(), + user_exe_path.begin(), tolower); + if (exe == user_exe_path) { + const std::wstring text = + l10n_util::GetString(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); + const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME); + const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; + win_util::MessageBox(NULL, text, caption, flags); + std::wstring uninstall_cmd = InstallUtil::GetChromeUninstallCmd(false); + if (!uninstall_cmd.empty()) { + uninstall_cmd.append(L" --"); + uninstall_cmd.append(installer_util::switches::kForceUninstall); + uninstall_cmd.append(L" --"); + uninstall_cmd.append(installer_util::switches::kDoNotRemoveSharedItems); + process_util::LaunchApp(uninstall_cmd, false, false, NULL); + } + return true; + } + } + return false; +} + // We record in UMA the conditions that can prevent breakpad from generating // and sending crash reports. Namely that the crash reporting registration // failed and that the process is being debugged. @@ -400,6 +436,16 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, return ResultCodes::NORMAL_EXIT; } + // Check if there is any machine level Chrome installed on the current + // machine. If yes and the current Chrome process is user level, we do not + // allow the user level Chrome to run. So we notify the user and uninstall + // user level Chrome. + // Note this check should only happen here, after all the checks above + // (uninstall, resource bundle initialization, other chrome browser + // processes etc). + if (CheckMachineLevelInstall()) + return ResultCodes::MACHINE_LEVEL_INSTALL_EXISTS; + message_window.Create(); // Show the First Run UI if this is the first time Chrome has been run on |