diff options
author | zturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 20:21:24 +0000 |
---|---|---|
committer | zturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-13 20:21:24 +0000 |
commit | 8393c30362716313ccc200e7c11c761eb0a42982 (patch) | |
tree | 27c8bb5fc0766ab8633d34d20b319ed0d32451f5 /chrome/browser/lifetime | |
parent | 4ad3b4428e3fbcff048cc514f761a51dd2652e86 (diff) | |
download | chromium_src-8393c30362716313ccc200e7c11c761eb0a42982.zip chromium_src-8393c30362716313ccc200e7c11c761eb0a42982.tar.gz chromium_src-8393c30362716313ccc200e7c11c761eb0a42982.tar.bz2 |
Show the download cancellation confirmation on relaunch to desktop.
The issue is that previously, in response to the menu click
handler, we were attempting to show the Confirmation dialog
(which is asynchronous), and then sending a message to the
metro viewer to activate the desktop. This notification
would terminate the metro viewer process, so the dialog
would never be displayed.
The fix is to only send the message to the metro viewer
after we determine that it's safe to close (either because
the user clicked yes on the cancel dialog, or because there
were no pending downloads to begin with).
It was necessary for me to remove a DCHECK from the
StartPageService::ProfileDestroyObserver. The service's
profile member was non NULL and the the one being passed in
as the notification details was null. I suspect I will need
to fix this, but I spent a while looking over the code and
it was not obvious to me how this shutdown flow works, or
even if this was a valid DCHECK(), so I would like to get
some input from apps people on this point.
BUG=315924
R=ananta@chromium.org, jschuh@chromium.org, sky@chromium.org, tapted@chromium.org
Review URL: https://codereview.chromium.org/108773002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/lifetime')
-rw-r--r-- | chrome/browser/lifetime/application_lifetime.h | 14 | ||||
-rw-r--r-- | chrome/browser/lifetime/application_lifetime_win.cc | 24 | ||||
-rw-r--r-- | chrome/browser/lifetime/browser_close_manager.cc | 22 |
3 files changed, 32 insertions, 28 deletions
diff --git a/chrome/browser/lifetime/application_lifetime.h b/chrome/browser/lifetime/application_lifetime.h index 8172e55..51638cd 100644 --- a/chrome/browser/lifetime/application_lifetime.h +++ b/chrome/browser/lifetime/application_lifetime.h @@ -31,13 +31,6 @@ void StartShutdownTracing(); void AttemptRestart(); #if defined(OS_WIN) -// Windows 8 specific: Like AttemptRestart but if chrome is running -// in desktop mode it starts in metro mode and vice-versa. The switching like -// the restarting is controlled by a preference. -void AttemptRestartWithModeSwitch(); -void AttemptRestartToDesktopMode(); -void AttemptRestartToMetroMode(); - enum AshExecutionStatus { ASH_KEEP_RUNNING, ASH_TERMINATE, @@ -47,6 +40,13 @@ enum AshExecutionStatus { // |ash_execution_status| parameter indicates if we should exit Ash after // activating desktop. void ActivateDesktopHelper(AshExecutionStatus ash_execution_status); + +// Windows 8 specific: Like AttemptRestart but if chrome is running +// in desktop mode it starts in metro mode and vice-versa. The switching like +// the restarting is controlled by a preference. +void AttemptRestartWithModeSwitch(); +void AttemptRestartToDesktopMode(); +void AttemptRestartToMetroMode(); #endif // Attempt to exit by closing all browsers. This is equivalent to diff --git a/chrome/browser/lifetime/application_lifetime_win.cc b/chrome/browser/lifetime/application_lifetime_win.cc index 74615e9..a245e73 100644 --- a/chrome/browser/lifetime/application_lifetime_win.cc +++ b/chrome/browser/lifetime/application_lifetime_win.cc @@ -7,8 +7,10 @@ #include "base/bind.h" #include "base/prefs/pref_service.h" #include "base/win/metro.h" +#include "base/win/windows_version.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/first_run/upgrade_util.h" +#include "chrome/browser/ui/browser_finder.h" #include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "ui/views/widget/widget.h" @@ -62,12 +64,6 @@ void AttemptRestartWithModeSwitch() { } #if defined(USE_AURA) -void ActivateDesktopHelperReply() { - AttemptRestart(); -} - -void ActivateDesktopIgnore() {} - void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) { scoped_ptr<base::Environment> env(base::Environment::Create()); std::string version_str; @@ -90,15 +86,10 @@ void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) { path = path.Append(installer::kDelegateExecuteExe); - bool ash_exit = ash_execution_status == ASH_TERMINATE; // Actually launching the process needs to happen in the metro viewer, // otherwise it won't automatically transition to desktop. So we have // to send an IPC to the viewer to do the ShellExecute. - aura::HandleActivateDesktop( - path, - ash_exit, - ash_exit ? base::Bind(ActivateDesktopHelperReply) : - base::Bind(ActivateDesktopIgnore)); + aura::HandleActivateDesktop(path, ash_execution_status == ASH_TERMINATE); } #endif @@ -107,16 +98,7 @@ void AttemptRestartToDesktopMode() { prefs->SetString(prefs::kRelaunchMode, upgrade_util::kRelaunchModeDesktop); -#if defined(USE_AURA) - - // We need to PostTask as there is some IO involved. - content::BrowserThread::PostTask( - content::BrowserThread::PROCESS_LAUNCHER, FROM_HERE, - base::Bind(&ActivateDesktopHelper, ASH_TERMINATE)); - -#else AttemptRestart(); -#endif } void AttemptRestartToMetroMode() { diff --git a/chrome/browser/lifetime/browser_close_manager.cc b/chrome/browser/lifetime/browser_close_manager.cc index 13982f1..0f46a01 100644 --- a/chrome/browser/lifetime/browser_close_manager.cc +++ b/chrome/browser/lifetime/browser_close_manager.cc @@ -4,11 +4,14 @@ #include "chrome/browser/lifetime/browser_close_manager.h" +#include "base/prefs/pref_service.h" #include "chrome/browser/background/background_mode_manager.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" +#include "chrome/browser/first_run/upgrade_util.h" +#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_iterator.h" @@ -17,8 +20,14 @@ #include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/common/pref_names.h" #include "content/public/browser/web_contents.h" +#if defined(OS_WIN) +#include "base/win/windows_version.h" +#include "chrome/browser/first_run/upgrade_util_win.h" +#endif + BrowserCloseManager::BrowserCloseManager() : current_browser_(NULL) {} BrowserCloseManager::~BrowserCloseManager() {} @@ -160,4 +169,17 @@ void BrowserCloseManager::CloseBrowsers() { } } } + +#if defined(OS_WIN) + if (base::win::GetVersion() >= base::win::VERSION_WIN8) { + PrefService* pref_service = g_browser_process->local_state(); + bool is_relaunch = pref_service->GetBoolean(prefs::kWasRestarted); + if (is_relaunch) { + upgrade_util::RelaunchMode mode = upgrade_util::RelaunchModeStringToEnum( + pref_service->GetString(prefs::kRelaunchMode)); + if (mode == upgrade_util::RELAUNCH_MODE_DESKTOP) + chrome::ActivateDesktopHelper(chrome::ASH_TERMINATE); + } + } +#endif } |