summaryrefslogtreecommitdiffstats
path: root/chrome/browser/session_restore.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 00:29:05 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 00:29:05 +0000
commit15952e462a8d6ef6d555219d0af62ceae093a173 (patch)
tree530c1a3e238e3ca7488b5589c49480df51f7378d /chrome/browser/session_restore.cc
parentd6dfe0d2402e2dbf997833f2deaf5b4a55b9b40a (diff)
downloadchromium_src-15952e462a8d6ef6d555219d0af62ceae093a173.zip
chromium_src-15952e462a8d6ef6d555219d0af62ceae093a173.tar.gz
chromium_src-15952e462a8d6ef6d555219d0af62ceae093a173.tar.bz2
Re-do the way browser windows are shown:
- Remove the path from WinMain to the Browser object passing the show_command. For the Browser object, this is a problem since this value isn't portable. For the code in general it involves a lot of ugly wiring. It's completely unnecessary since the value is obtainable via GetStartupInfo. - Remove show_command plumbing from all over the place (session restore, web app launcher, etc) Change the way browser windows are constructed: - The browser constructor now takes just a type and a profile, and simply initializes the object. - Some configuration that used to be part of the constructor that was only used in one or two use cases (initial bounds, maximized state, web app name) are split into separate setters. - Window creation is split out into a separate step to be called post configuration. - Assorted static helper functions added to Browser to make construction of common types easy. - Remove Browser::Show in favor of BrowserWindow::Show - Adjust all callers to use the new helpers. Change the way ChromeViews restores window placement: - Split restored size determination from restored maximized determination. They are needed by the code at different times. Size restoration happens when the window is constructed and Window::SetInitialBounds is called. Maximized state restoration happens when the window is shown for the first time and SW_SHOWMAXIMIZED or SW_SHOWNORMAL is needed. Thus, replace WindowDelegate::RestoreWindowPosition with WindowDelegate::RestoreWindowBounds and WindowDelegate::RestoreMaximizedState. - Window::SetInitialBounds calls WindowDelegate::RestoreWindowBounds - Window::Show calls WindowDelegate::RestoreMaximizedState - Adjusts all WindowDelegate implementations that override RestoreWindowPosition to implement these new methods instead. - Move "playback/record" mode window size setting from browser_init to Browser::RestoreWindowBounds. - Provide a virtual function on Window called GetShowState that determines the default show state to be used when Window::Show is called. For most windows and dialogs this is SW_SHOWNORMAL. AeroGlassFrame/OpaqueFrame (the browser window frames) override this since they're the app's main windows to return the value provided by GetStartupInfo which gives the value from the app shortcut. http://crbug.com/3557 Review URL: http://codereview.chromium.org/10896 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/session_restore.cc')
-rw-r--r--chrome/browser/session_restore.cc32
1 files changed, 11 insertions, 21 deletions
diff --git a/chrome/browser/session_restore.cc b/chrome/browser/session_restore.cc
index dba5334ff..b8ec569 100644
--- a/chrome/browser/session_restore.cc
+++ b/chrome/browser/session_restore.cc
@@ -182,14 +182,12 @@ class SessionRestoreImpl : public NotificationObserver {
SessionRestoreImpl(Profile* profile,
Browser* browser,
bool use_saved_session,
- int show_command,
bool synchronous,
bool clobber_existing_window,
bool always_create_tabbed_browser,
const std::vector<GURL>& urls_to_open)
: profile_(profile),
browser_(browser),
- show_command_(show_command),
use_saved_session_(use_saved_session),
synchronous_(synchronous),
clobber_existing_window_(clobber_existing_window),
@@ -240,9 +238,7 @@ class SessionRestoreImpl : public NotificationObserver {
// have been loaded.
void FinishedTabCreation(bool succeeded, bool created_tabbed_browser) {
if (!created_tabbed_browser && always_create_tabbed_browser_) {
- Browser* browser = new Browser(gfx::Rect(), show_command_, profile_,
- BrowserType::TABBED_BROWSER,
- std::wstring());
+ Browser* browser = Browser::Create(profile_);
if (urls_to_open_.empty()) {
// No tab browsers were created and no URLs were supplied on the command
// line. Add an empty URL, which is treated as opening the users home
@@ -250,7 +246,7 @@ class SessionRestoreImpl : public NotificationObserver {
urls_to_open_.push_back(GURL());
}
AppendURLsToBrowser(browser, urls_to_open_);
- browser->Show();
+ browser->window()->Show();
}
if (synchronous_)
@@ -303,10 +299,10 @@ class SessionRestoreImpl : public NotificationObserver {
}
}
if (!browser) {
- const int show_command =
- (*i)->is_maximized ? SW_SHOWMAXIMIZED : show_command_;
- browser = new Browser((*i)->bounds, show_command, profile_, (*i)->type,
- std::wstring());
+ browser = new Browser((*i)->type, profile_);
+ browser->set_override_bounds((*i)->bounds);
+ browser->set_override_maximized((*i)->is_maximized);
+ browser->CreateBrowserWindow();
}
if ((*i)->type == BrowserType::TABBED_BROWSER)
last_browser = browser;
@@ -363,7 +359,7 @@ class SessionRestoreImpl : public NotificationObserver {
browser->SelectTabContentsAt(
std::min(initial_tab_count + std::max(0, selected_session_index),
browser->tab_count() - 1), true);
- browser->Show();
+ browser->window()->Show();
}
void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) {
@@ -387,9 +383,6 @@ class SessionRestoreImpl : public NotificationObserver {
// The first browser to restore to, may be null.
Browser* browser_;
- // Used when creating windows. Passed to the window.
- const int show_command_;
-
// Whether we're restoring the saved session (true) or the last session
// (false).
const bool use_saved_session_;
@@ -427,7 +420,6 @@ size_t SessionRestore::num_tabs_to_load_ = 0;
static void Restore(Profile* profile,
Browser* browser,
bool use_saved_session,
- int show_command,
bool synchronous,
bool clobber_existing_window,
bool always_create_tabbed_browser,
@@ -437,7 +429,7 @@ static void Restore(Profile* profile,
return;
// SessionRestoreImpl takes care of deleting itself when done.
SessionRestoreImpl* restorer =
- new SessionRestoreImpl(profile, browser, use_saved_session, show_command,
+ new SessionRestoreImpl(profile, browser, use_saved_session,
synchronous, clobber_existing_window,
always_create_tabbed_browser,
urls_to_open);
@@ -451,16 +443,14 @@ void SessionRestore::RestoreSession(Profile* profile,
bool clobber_existing_window,
bool always_create_tabbed_browser,
const std::vector<GURL>& urls_to_open) {
- Restore(profile, browser, use_saved_session, SW_SHOW, false,
- clobber_existing_window, always_create_tabbed_browser, urls_to_open);
+ Restore(profile, browser, use_saved_session, false, clobber_existing_window,
+ always_create_tabbed_browser, urls_to_open);
}
// static
void SessionRestore::RestoreSessionSynchronously(
Profile* profile,
bool use_saved_session,
- int show_command,
const std::vector<GURL>& urls_to_open) {
- Restore(profile, NULL, use_saved_session, SW_SHOW, true, false, true,
- urls_to_open);
+ Restore(profile, NULL, use_saved_session, true, false, true, urls_to_open);
}