summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 19:35:06 +0000
committerachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 19:35:06 +0000
commit481acef9c8eef81c8e7f02a51602987348d42e2c (patch)
tree16c3d9f2d56e7bff1da589aa5376ce69deaf5d3e /chrome
parentcb01cd6e91282f52a26d5b70a42b57c8cf322cce (diff)
downloadchromium_src-481acef9c8eef81c8e7f02a51602987348d42e2c.zip
chromium_src-481acef9c8eef81c8e7f02a51602987348d42e2c.tar.gz
chromium_src-481acef9c8eef81c8e7f02a51602987348d42e2c.tar.bz2
Restart instead of signout when there are pending updates.
BUG=chromium-os:9782 TEST=Install an update, signout. With this change, we will reboot (installing the update). Review URL: http://codereview.chromium.org/6312111 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_shutdown.cc6
-rw-r--r--chrome/browser/chromeos/login/update_screen_browsertest.cc10
-rw-r--r--chrome/browser/ui/browser_list.cc60
-rw-r--r--chrome/browser/ui/browser_list.h11
4 files changed, 52 insertions, 35 deletions
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index 5e906c5..82298a7 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/browser_shutdown.h"
+#include <map>
#include <string>
#include "base/command_line.h"
@@ -32,6 +33,7 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
#include "chrome/browser/service/service_process_control_manager.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -251,9 +253,7 @@ void Shutdown() {
UnregisterURLRequestChromeJob();
#if defined(OS_CHROMEOS)
- if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
- chromeos::CrosLibrary::Get()->GetLoginLibrary()->StopSession("");
- }
+ BrowserList::NotifyAndTerminate(false);
#endif
// Clean up data sources before the UI thread is removed.
diff --git a/chrome/browser/chromeos/login/update_screen_browsertest.cc b/chrome/browser/chromeos/login/update_screen_browsertest.cc
index 5fa4eb1..16f45f8 100644
--- a/chrome/browser/chromeos/login/update_screen_browsertest.cc
+++ b/chrome/browser/chromeos/login/update_screen_browsertest.cc
@@ -65,6 +65,14 @@ class UpdateScreenTest : public WizardInProcessBrowserTest {
WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
}
+ void ExpectUpdateStatusCheck() {
+ // browser_list::NotifyAndTerminate calls status().
+ UpdateLibrary::Status status;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ }
+
MockLoginLibrary* mock_login_library_;
MockUpdateLibrary* mock_update_library_;
MockNetworkLibrary* mock_network_library_;
@@ -82,6 +90,7 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestBasic) {
ASSERT_EQ(controller()->current_screen(), update_screen);
UpdateView* update_view = update_screen->view();
ASSERT_TRUE(update_view != NULL);
+ ExpectUpdateStatusCheck();
controller()->set_observer(NULL);
}
@@ -193,6 +202,7 @@ IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) {
.Times(1);
update_screen->StartUpdate();
+ ExpectUpdateStatusCheck();
controller()->set_observer(NULL);
}
diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc
index d68365c..c37b91c 100644
--- a/chrome/browser/ui/browser_list.cc
+++ b/chrome/browser/ui/browser_list.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/login_library.h"
+#include "chrome/browser/chromeos/cros/update_library.h"
#include "chrome/browser/chromeos/wm_ipc.h"
#endif
@@ -160,10 +161,6 @@ Browser* FindBrowserMatching(const T& begin,
BrowserList::BrowserVector BrowserList::browsers_;
ObserverList<BrowserList::Observer> BrowserList::observers_;
-#if defined(OS_CHROMEOS)
-bool BrowserList::notified_window_manager_about_signout_ = false;
-#endif
-
// static
void BrowserList::AddBrowser(Browser* browser) {
DCHECK(browser);
@@ -194,20 +191,41 @@ void BrowserList::MarkAsCleanShutdown() {
}
}
+#if defined(OS_CHROMEOS)
+// static
+void BrowserList::NotifyWindowManagerAboutSignout() {
+ static bool notified = false;
+ if (!notified) {
+ // Let the window manager know that we're going away before we start closing
+ // windows so it can display a graceful transition to a black screen.
+ chromeos::WmIpc::instance()->NotifyAboutSignout();
+ notified = true;
+ }
+}
+#endif
+
// static
-void BrowserList::NotifyAndTerminate() {
+void BrowserList::NotifyAndTerminate(bool fast_path) {
#if defined(OS_CHROMEOS)
- // Let the window manager know that we're going away before we start closing
- // windows so it can display a graceful transition to a black screen.
- chromeos::WmIpc::instance()->NotifyAboutSignout();
- notified_window_manager_about_signout_ = true;
+ NotifyWindowManagerAboutSignout();
#endif
- NotificationService::current()->Notify(NotificationType::APP_TERMINATING,
- NotificationService::AllSources(),
- NotificationService::NoDetails());
+
+ if (fast_path) {
+ NotificationService::current()->Notify(NotificationType::APP_TERMINATING,
+ NotificationService::AllSources(),
+ NotificationService::NoDetails());
+ }
+
#if defined(OS_CHROMEOS)
- if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
- chromeos::CrosLibrary::Get()->GetLoginLibrary()->StopSession("");
+ chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get();
+ if (cros_library->EnsureLoaded()) {
+ // If update has been installed, reboot, otherwise, sign out.
+ if (cros_library->GetUpdateLibrary()->status().status ==
+ chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
+ cros_library->GetUpdateLibrary()->RebootAfterUpdate();
+ } else {
+ cros_library->GetLoginLibrary()->StopSession("");
+ }
return;
}
// If running the Chrome OS build, but we're not on the device, fall through
@@ -251,16 +269,6 @@ void BrowserList::RemoveBrowser(Browser* browser) {
if (browsers_.empty() &&
(browser_shutdown::IsTryingToQuit() ||
g_browser_process->IsShuttingDown())) {
-#if defined(OS_CHROMEOS)
- // We might've already notified the window manager before closing any
- // windows in NotifyAndTerminate() if we were able to take the
- // no-beforeunload-handlers-or-downloads fast path; no need to do it again
- // here.
- if (!notified_window_manager_about_signout_) {
- chromeos::WmIpc::instance()->NotifyAboutSignout();
- notified_window_manager_about_signout_ = true;
- }
-#endif
// Last browser has just closed, and this is a user-initiated quit or there
// is no module keeping the app alive, so send out our notification. No need
// to call ProfileManager::ShutdownSessionServices() as part of the
@@ -328,7 +336,7 @@ void BrowserList::CloseAllBrowsers() {
// If there are no browsers, send the APP_TERMINATING action here. Otherwise,
// it will be sent by RemoveBrowser() when the last browser has closed.
if (force_exit || browsers_.empty()) {
- NotifyAndTerminate();
+ NotifyAndTerminate(true);
return;
}
#if defined(OS_CHROMEOS)
@@ -368,7 +376,7 @@ void BrowserList::Exit() {
if (chromeos::CrosLibrary::Get()->EnsureLoaded()
&& !NeedBeforeUnloadFired()
&& !PendingDownloads()) {
- NotifyAndTerminate();
+ NotifyAndTerminate(true);
return;
}
#endif
diff --git a/chrome/browser/ui/browser_list.h b/chrome/browser/ui/browser_list.h
index 880bea8..05cd38e 100644
--- a/chrome/browser/ui/browser_list.h
+++ b/chrome/browser/ui/browser_list.h
@@ -161,6 +161,10 @@ class BrowserList {
// Returns true if at least one off the record session is active.
static bool IsOffTheRecordSessionActive();
+ // Send out notifications.
+ // For ChromeOS, also request session manager to end the session.
+ static void NotifyAndTerminate(bool fast_path);
+
// Called once there are no more browsers open and the application is exiting.
static void AllBrowsersClosedAndAppExiting();
@@ -168,10 +172,10 @@ class BrowserList {
// Helper method to remove a browser instance from a list of browsers
static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list);
static void MarkAsCleanShutdown();
- static void NotifyAndTerminate();
#if defined(OS_CHROMEOS)
static bool NeedBeforeUnloadFired();
static bool PendingDownloads();
+ static void NotifyWindowManagerAboutSignout();
#endif
static BrowserVector browsers_;
@@ -181,11 +185,6 @@ class BrowserList {
// Counter of calls to StartKeepAlive(). If non-zero, the application will
// continue running after the last browser has exited.
static int keep_alive_count_;
-
-#if defined(OS_CHROMEOS)
- // Have we already notified the window manager that we're signing out?
- static bool notified_window_manager_about_signout_;
-#endif
};
class TabContents;