diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chrome_browser_main_extra_parts_ash.cc | 5 | ||||
-rw-r--r-- | chrome/browser/tab_closeable_state_watcher.cc | 18 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list.cc | 48 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list.h | 14 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list_aura.cc | 19 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list_mac.mm | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list_stub.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list_win.cc | 4 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 4 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 8 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/test/automation/proxy_launcher.cc | 3 | ||||
-rw-r--r-- | chrome/test/base/in_process_browser_test.cc | 3 |
15 files changed, 92 insertions, 48 deletions
diff --git a/chrome/browser/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/chrome_browser_main_extra_parts_ash.cc index c2238e1..1b75154 100644 --- a/chrome/browser/chrome_browser_main_extra_parts_ash.cc +++ b/chrome/browser/chrome_browser_main_extra_parts_ash.cc @@ -9,6 +9,7 @@ #include "ash/shell.h" #include "base/command_line.h" #include "chrome/common/chrome_switches.h" +#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/views/ash/caps_lock_handler.h" #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" #include "chrome/browser/ui/views/ash/screen_orientation_listener.h" @@ -62,6 +63,10 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { scoped_ptr<ash::ImeControlDelegate>(new ImeController).Pass()); shell->accelerator_controller()->SetVolumeControlDelegate( scoped_ptr<ash::VolumeControlDelegate>(new VolumeController).Pass()); + + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableZeroBrowsersOpenForTests)) + BrowserList::StartKeepAlive(); #endif // Make sure the singleton ScreenOrientationListener object is created. diff --git a/chrome/browser/tab_closeable_state_watcher.cc b/chrome/browser/tab_closeable_state_watcher.cc index 8952542..e600298 100644 --- a/chrome/browser/tab_closeable_state_watcher.cc +++ b/chrome/browser/tab_closeable_state_watcher.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,25 +7,11 @@ #include "base/command_line.h" #include "chrome/common/chrome_switches.h" -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/tab_closeable_state_watcher.h" -#endif // defined(OS_CHROMEOS) - //////////////////////////////////////////////////////////////////////////////// // TabCloseableStateWatcher, static: ::TabCloseableStateWatcher* ::TabCloseableStateWatcher::Create() { - ::TabCloseableStateWatcher* watcher = NULL; -#if defined(OS_CHROMEOS) - // We only watch closeable state of tab on chromeos, and only when it's not - // disabled (tests will have the disable switch). - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableTabCloseableStateWatcher)) - watcher = new chromeos::TabCloseableStateWatcher(); -#endif // OS_CHROMEOS - if (!watcher) - watcher = new ::TabCloseableStateWatcher(); - return watcher; + return new ::TabCloseableStateWatcher(); } bool TabCloseableStateWatcher::CanCloseTab(const Browser* browser) const { diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc index c6c08fe..83343de0 100644 --- a/chrome/browser/ui/browser_list.cc +++ b/chrome/browser/ui/browser_list.cc @@ -344,24 +344,46 @@ void BrowserList::NotifyAndTerminate(bool fast_path) { content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&BrowserList::ExitCleanly)); } -#else - AllBrowsersClosedAndAppExiting(); #endif } +void BrowserList::OnAppExiting() { + static bool notified = false; + if (notified) + return; + notified = true; + + delete activity_observer; + activity_observer = NULL; + HandleAppExitingForPlatform(); +} + // static void BrowserList::RemoveBrowser(Browser* browser) { RemoveBrowserFrom(browser, &last_active_browsers()); - // Closing all windows does not indicate quitting the application on the Mac, - // however, many UI tests rely on this behavior so leave it be for now and - // simply ignore the behavior on the Mac outside of unit tests. - // TODO(andybons): Fix the UI tests to Do The Right Thing. - bool closing_last_browser = (browsers().size() == 1); + // Many UI tests rely on closing the last browser window quitting the + // application. + // Mac: Closing all windows does not indicate quitting the application. Lie + // for now and ignore behavior outside of unit tests. + // ChromeOS: Force closing last window to close app with flag. + // TODO(andybons | pkotwicz): Fix the UI tests to Do The Right Thing. +#if defined(OS_CHROMEOS) + bool closing_app; + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableZeroBrowsersOpenForTests)) + closing_app = (browsers().size() == 1); + else + closing_app = (browsers().size() == 1 && + browser_shutdown::IsTryingToQuit()); +#else + bool closing_app = (browsers().size() == 1); +#endif // OS_CHROMEOS + content::NotificationService::current()->Notify( chrome::NOTIFICATION_BROWSER_CLOSED, content::Source<Browser>(browser), - content::Details<bool>(&closing_last_browser)); + content::Details<bool>(&closing_app)); RemoveBrowserFrom(browser, &browsers()); @@ -372,13 +394,6 @@ void BrowserList::RemoveBrowser(Browser* browser) { DCHECK_EQ(original_count, observers().size()) << "observer list modified during notification"; - // If the last Browser object was destroyed, make sure we try to close any - // remaining dependent windows too. - if (browsers().empty()) { - delete activity_observer; - activity_observer = NULL; - } - g_browser_process->ReleaseModule(); // If we're exiting, send out the APP_TERMINATING notification to allow other @@ -392,7 +407,7 @@ void BrowserList::RemoveBrowser(Browser* browser) { // shutdown, because Browser::WindowClosing() already makes sure that the // SessionService is created and notified. NotifyAppTerminating(); - AllBrowsersClosedAndAppExiting(); + OnAppExiting(); } } @@ -422,6 +437,7 @@ void BrowserList::CloseAllBrowsers() { if (browser_shutdown::ShuttingDownWithoutClosingBrowsers() || browsers().empty()) { NotifyAndTerminate(true); + OnAppExiting(); return; } diff --git a/chrome/browser/ui/browser_list.h b/chrome/browser/ui/browser_list.h index 6874d0b..1a568ba 100644 --- a/chrome/browser/ui/browser_list.h +++ b/chrome/browser/ui/browser_list.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -111,7 +111,7 @@ class BrowserList { // Starts a user initiated exit process. Called from Browser::Exit. // On platforms other than ChromeOS, this is equivalent to - // CloseAllBrowsersAndExit. On ChromeOS, this tells session manager + // CloseAllBrowsers() On ChromeOS, this tells session manager // that chrome is signing out, which lets session manager send // SIGTERM to start actual exit process. static void AttemptUserExit(); @@ -134,7 +134,7 @@ class BrowserList { #if defined(OS_CHROMEOS) // This is equivalent to AttemptUserExit, except that it always set - // exit cleanly bit. ChroemOS checks if it can exit without user + // exit cleanly bit. ChromeOS checks if it can exit without user // interactions, so it will always exit the browser. This is used to // handle SIGTERM on chromeos which is a signal to force shutdown // the chrome. @@ -202,8 +202,12 @@ class BrowserList { // 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(); + // Called once the application is exiting. + static void OnAppExiting(); + + // Called once the application is exiting to do any platform specific + // processing required. + static void HandleAppExitingForPlatform(); private: // Helper method to remove a browser instance from a list of browsers diff --git a/chrome/browser/ui/browser_list_aura.cc b/chrome/browser/ui/browser_list_aura.cc new file mode 100644 index 0000000..fca6134 --- /dev/null +++ b/chrome/browser/ui/browser_list_aura.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2012 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/ui/browser_list.h" + +#include "base/command_line.h" +#include "chrome/common/chrome_switches.h" + +// static +void BrowserList::HandleAppExitingForPlatform() { +#if defined(OS_CHROMEOS) + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableZeroBrowsersOpenForTests)) { + // App is exiting, call EndKeepAlive() on behalf of Aura Shell. + BrowserList::EndKeepAlive(); + } +#endif // OS_CHROMEOS +} diff --git a/chrome/browser/ui/browser_list_gtk.cc b/chrome/browser/ui/browser_list_gtk.cc index 3934345..79da49d 100644 --- a/chrome/browser/ui/browser_list_gtk.cc +++ b/chrome/browser/ui/browser_list_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,7 +7,7 @@ #include <gtk/gtk.h> // static -void BrowserList::AllBrowsersClosedAndAppExiting() { +void BrowserList::HandleAppExitingForPlatform() { // Close non-browser windows. GList* window_list = gtk_window_list_toplevels(); g_list_foreach(window_list, (GFunc)g_object_ref, NULL); diff --git a/chrome/browser/ui/browser_list_mac.mm b/chrome/browser/ui/browser_list_mac.mm index 9540dbd..c0b703d 100644 --- a/chrome/browser/ui/browser_list_mac.mm +++ b/chrome/browser/ui/browser_list_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -8,7 +8,7 @@ #import "chrome/browser/chrome_browser_application_mac.h" // static -void BrowserList::AllBrowsersClosedAndAppExiting() { +void BrowserList::HandleAppExitingForPlatform() { // Last browser is closed, so call back to controller to shutdown the app. chrome_browser_application_mac::Terminate(); } diff --git a/chrome/browser/ui/browser_list_stub.cc b/chrome/browser/ui/browser_list_stub.cc index 33e1e39..29e24f2 100644 --- a/chrome/browser/ui/browser_list_stub.cc +++ b/chrome/browser/ui/browser_list_stub.cc @@ -1,9 +1,9 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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/ui/browser_list.h" // static -void BrowserList::AllBrowsersClosedAndAppExiting() { +void BrowserList::HandleAppExitingForPlatform() { } diff --git a/chrome/browser/ui/browser_list_win.cc b/chrome/browser/ui/browser_list_win.cc index 10554ad..d4edbb3 100644 --- a/chrome/browser/ui/browser_list_win.cc +++ b/chrome/browser/ui/browser_list_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,7 +7,7 @@ #include "ui/views/widget/widget.h" // static -void BrowserList::AllBrowsersClosedAndAppExiting() { +void BrowserList::HandleAppExitingForPlatform() { #if !defined(USE_AURA) views::Widget::CloseAllSecondaryWidgets(); #endif diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index a64f93f..570628c 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -868,8 +868,6 @@ 'browser/chromeos/system/udev_info_provider.h', 'browser/chromeos/system_key_event_listener.cc', 'browser/chromeos/system_key_event_listener.h', - 'browser/chromeos/tab_closeable_state_watcher.cc', - 'browser/chromeos/tab_closeable_state_watcher.h', 'browser/chromeos/ui/brightness_bubble.cc', 'browser/chromeos/ui/brightness_bubble.h', 'browser/chromeos/ui/idle_logout_dialog_view.cc', @@ -2295,6 +2293,7 @@ 'browser/ui/browser_init.h', 'browser/ui/browser_list.cc', 'browser/ui/browser_list.h', + 'browser/ui/browser_list_aura.cc', 'browser/ui/browser_list_gtk.cc', 'browser/ui/browser_list_mac.mm', 'browser/ui/browser_list_stub.cc', @@ -4273,6 +4272,7 @@ ['exclude', '^browser/renderer_host/render_widget_host_view_views*'], ['exclude', '^browser/tab_contents/chrome_web_contents_view_delegate_win.cc'], ['exclude', '^browser/tab_contents/chrome_web_contents_view_delegate_win.h'], + ['exclude', '^browser/ui/browser_list_stub.cc'], ['exclude', '^browser/ui/gesture_prefs.cc'], ['exclude', '^browser/ui/panels/display_settings_provider_win.cc'], ['exclude', '^browser/ui/tabs/dock_info_win.cc'], diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 81f85ba..053d068 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2619,7 +2619,6 @@ 'browser/chromeos/login/wizard_in_process_browser_test.h', 'browser/chromeos/media/media_player_browsertest.cc', 'browser/chromeos/process_proxy/process_proxy_browsertest.cc', - 'browser/chromeos/tab_closeable_state_watcher_browsertest.cc', 'browser/content_settings/content_settings_browsertest.cc', 'browser/crash_recovery_browsertest.cc', 'browser/custom_handlers/protocol_handler_registry_browsertest.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index f54410d..3cd7ec4 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -416,6 +416,14 @@ const char kDisableUberPage[] = "disable-uber-page"; // Disables the backend service for web resources. const char kDisableWebResources[] = "disable-web-resources"; +// Some tests seem to require the application to close when the last +// browser window is closed. Thus, we need a switch to force this behavior +// for ChromeOS Aura, disable "zero window mode". +// TODO(pkotwicz): Investigate if this bug can be removed. +// (http://crbug.com/119175) +extern const char kDisableZeroBrowsersOpenForTests[] = + "disable-zero-browsers-open-for-tests"; + // Use a specific disk cache location, rather than one derived from the // UserDatadir. const char kDiskCacheDir[] = "disk-cache-dir"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 7f39d856..8d81db9 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -123,6 +123,7 @@ extern const char kDisableTLS1[]; extern const char kDisableTranslate[]; extern const char kDisableUberPage[]; extern const char kDisableWebResources[]; +extern const char kDisableZeroBrowsersOpenForTests[]; extern const char kDiskCacheDir[]; extern const char kDiskCacheSize[]; extern const char kDnsLogDetails[]; diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc index 088636d..a2b9f16 100644 --- a/chrome/test/automation/proxy_launcher.cc +++ b/chrome/test/automation/proxy_launcher.cc @@ -437,6 +437,9 @@ void ProxyLauncher::PrepareTestCommandline(CommandLine* command_line, // Disable TabCloseableStateWatcher for tests. command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher); + // Force the app to always exit when the last browser window is closed. + command_line->AppendSwitch(switches::kDisableZeroBrowsersOpenForTests); + // Allow file:// access on ChromeOS. command_line->AppendSwitch(switches::kAllowFileAccess); } diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 4cce317..ba8bfbc 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc @@ -169,6 +169,9 @@ void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { if (!tab_closeable_state_watcher_enabled_) command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher); + // TODO(pkotwicz): Investigate if we can remove this switch. + command_line->AppendSwitch(switches::kDisableZeroBrowsersOpenForTests); + command_line->AppendSwitch(switches::kDisableUberPage); } |