summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 00:51:49 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 00:51:49 +0000
commitf98b8f85a4c56c155019312da24d2a77c5ddc64a (patch)
tree26d5dedf98f10e1389b8ea4677e65469ecbb3ebe
parent3313382ec12352d9c7f2458cd293ed9f901aa38f (diff)
downloadchromium_src-f98b8f85a4c56c155019312da24d2a77c5ddc64a.zip
chromium_src-f98b8f85a4c56c155019312da24d2a77c5ddc64a.tar.gz
chromium_src-f98b8f85a4c56c155019312da24d2a77c5ddc64a.tar.bz2
Fix --kiosk to work regardless of the startup pref setting or supplied URLs.
This also fixes a bug in Linux Views where calling BrowserWindow::Show() wouldn't synchronously call BrowserList::SetLastActive(). This happens naturally in Windows and was already explicitly done in BrowserWindowGtk and BrowserWindowCocoas, but missing it for Linux Views resulted in crashes when the kiosk code tried to get the last active window before the message loop had pumped the async activation change message. BUG=none TEST=Set Chrome to "open windows and tabs from last time", then run with --kiosk. Should start in kiosk mode (fullscreen, no status bubble). Review URL: http://codereview.chromium.org/2847090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54643 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_init.cc20
-rw-r--r--chrome/browser/browser_list.h7
-rw-r--r--chrome/browser/views/frame/browser_view.cc11
3 files changed, 23 insertions, 15 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 66c8b35..e5f7d23 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -552,14 +552,20 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
} else {
RecordLaunchModeHistogram(LM_AS_WEBAPP);
}
+ // After this point, BrowserList::GetLastActive() should be non-NULL on all
+ // platforms until there are no more Browsers.
+
+#if !defined(OS_MACOSX)
+ // In kiosk mode, we want to always be fullscreen, so switch to that now.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
+ BrowserList::GetLastActive()->ToggleFullscreenMode();
+#endif
#if defined(OS_WIN)
// Print the selected page if the command line switch exists. Note that the
// current selected tab would be the page which will be printed.
- if (command_line_.HasSwitch(switches::kPrint)) {
- Browser* browser = BrowserList::GetLastActive();
- browser->Print();
- }
+ if (command_line_.HasSwitch(switches::kPrint))
+ BrowserList::GetLastActive()->Print();
#endif
// If we're recording or playing back, startup the EventRecorder now
@@ -743,12 +749,6 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser(
#endif
}
-#if !defined(OS_MACOSX)
- // In kiosk mode, we want to always be fullscreen, so switch to that now.
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
- browser->ToggleFullscreenMode();
-#endif
-
bool first_tab = true;
for (size_t i = 0; i < tabs.size(); ++i) {
// We skip URLs that we'd have to launch an external protocol handler for.
diff --git a/chrome/browser/browser_list.h b/chrome/browser/browser_list.h
index 9e52aba..e709704 100644
--- a/chrome/browser/browser_list.h
+++ b/chrome/browser/browser_list.h
@@ -53,11 +53,8 @@ class BrowserList {
// most recently open Browser's window was closed, returns the first Browser
// in the list. If no Browsers exist, returns NULL.
//
- // WARNING: this is NULL until a browser becomes active. If during startup
- // a browser does not become active (perhaps the user launches Chrome, then
- // clicks on another app before the first browser window appears) then this
- // returns NULL.
- // WARNING #2: this will always be NULL in unit tests run on the bots.
+ // WARNING: This is NULL until a browser becomes active. That should happen
+ // during launch; see comment in BrowserInit::LaunchWithProfile::Launch().
static Browser* GetLastActive();
// Identical in behavior to GetLastActive(), except that the most recently
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 0e11eaa..3e9374c 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -675,6 +675,17 @@ void BrowserView::Show() {
RestoreFocus();
frame_->GetWindow()->Show();
+
+ // The following block also appears in BrowserWindowGtk::Show().
+#if !defined(OS_WIN)
+ // The Browser associated with this browser window must become the active
+ // browser at the time Show() is called. This is the natural behavior under
+ // Windows, but gtk_widget_show won't show the widget (and therefore won't
+ // call OnFocusIn()) until we return to the runloop. Therefore any calls to
+ // BrowserList::GetLastActive() (for example, in bookmark_util), will return
+ // the previous browser instead if we don't explicitly set it here.
+ BrowserList::SetLastActive(browser());
+#endif
}
void BrowserView::SetBounds(const gfx::Rect& bounds) {