diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-04 20:03:27 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-04 20:03:27 +0000 |
commit | 50cecbecc9a61ade39023e6bd8c2b8a7b1a6913e (patch) | |
tree | aa60461b8925fea950e387c4152e38423008333d /chrome/installer/setup/setup_main.cc | |
parent | 0562ead88e7cb03261577d0fdf01c33e9c166bfd (diff) | |
download | chromium_src-50cecbecc9a61ade39023e6bd8c2b8a7b1a6913e.zip chromium_src-50cecbecc9a61ade39023e6bd8c2b8a7b1a6913e.tar.gz chromium_src-50cecbecc9a61ade39023e6bd8c2b8a7b1a6913e.tar.bz2 |
Reverting 27880 which was itself a revert of 27876.Original codereview at http://codereview.chromium.org/235060/show.There was a small problem with a unittest EXPECT_TRUE condition being dependent on system state, which is now fixed. No other changes have been made from the original CL and now the trybots are up again, this looks to pass.TBR=tommi
Review URL: http://codereview.chromium.org/251079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/setup/setup_main.cc')
-rw-r--r-- | chrome/installer/setup/setup_main.cc | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 8b70a1b..3b5377d 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -5,6 +5,7 @@ #include <string> #include <windows.h> #include <msi.h> +#include <shellapi.h> #include <shlobj.h> #include "base/at_exit.h" @@ -13,6 +14,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/registry.h" +#include "base/scoped_handle_win.h" #include "base/string_util.h" #include "base/win_util.h" #include "chrome/installer/setup/install.h" @@ -413,7 +415,7 @@ bool HandleNonInstallCmdLineOptions(const CommandLine& cmd_line, exit_code = ShowEULADialog(inner_frame); if (installer_util::EULA_REJECTED != exit_code) GoogleUpdateSettings::SetEULAConsent(true); - return true;; + return true; } else if (cmd_line.HasSwitch( installer_util::switches::kRegisterChromeBrowser)) { // If --register-chrome-browser option is specified, register all @@ -464,6 +466,40 @@ bool HandleNonInstallCmdLineOptions(const CommandLine& cmd_line, return false; } +bool ShowRebootDialog() { + // Get a token for this process. + HANDLE token; + if (!OpenProcessToken(GetCurrentProcess(), + TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, + &token)) { + LOG(ERROR) << "Failed to open token."; + return false; + } + + // Use a ScopedHandle to keep track of and eventually close our handle. + // TODO(robertshield): Add a Receive() method to base's ScopedHandle. + ScopedHandle scoped_handle(token); + + // Get the LUID for the shutdown privilege. + TOKEN_PRIVILEGES tkp = {0}; + LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); + tkp.PrivilegeCount = 1; + tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + + // Get the shutdown privilege for this process. + AdjustTokenPrivileges(token, FALSE, &tkp, 0, + reinterpret_cast<PTOKEN_PRIVILEGES>(NULL), 0); + if (GetLastError() != ERROR_SUCCESS) { + LOG(ERROR) << "Unable to get shutdown privileges."; + return false; + } + + // Popup a dialog that will prompt to reboot using the default system message. + // TODO(robertshield): Add a localized, more specific string to the prompt. + RestartDialog(NULL, NULL, EWX_REBOOT | EWX_FORCEIFHUNG); + return true; +} + } // namespace int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, @@ -550,7 +586,15 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, prefs.get()); } + if (install_status == installer_util::UNINSTALL_REQUIRES_REBOOT) { + install_status = installer_util::UNINSTALL_SUCCESSFUL; +#if defined(CHROME_FRAME_BUILD) + ShowRebootDialog(); +#endif + } + CoUninitialize(); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); return dist->GetInstallReturnCode(install_status); } |