diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 18:34:09 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-08 18:34:09 +0000 |
commit | d28c47739c67f572946537b8d008a81eb2c96e6c (patch) | |
tree | 0679afd2d74900f766e34f0f90648b353bd34193 | |
parent | 47a047d26cd3a931148f59b2b035aa1deddc153c (diff) | |
download | chromium_src-d28c47739c67f572946537b8d008a81eb2c96e6c.zip chromium_src-d28c47739c67f572946537b8d008a81eb2c96e6c.tar.gz chromium_src-d28c47739c67f572946537b8d008a81eb2c96e6c.tar.bz2 |
[cros] Show release notes in app window + restore sesssion.
This covers special case of "Release notes" in ChromeOS.
All existing users would be shown new Getting Started Guide in app window in addition to their restored session when they would sign in after next update.
Just passing --app=[GSG URL] is not enough as session would not be restored.
Also using --app-restore-session + chrome://newtab for new user case so that user won't end up with empty desktop after closing GSG window.
Not adding --app-restore-session switch to ChromeOS only switches so that it won't complicate BrowserInit code with ifdefs.
BUG=126098, 1260025
TEST=Manual. Sign in with existing user after update and see GSG in app window + restored session.
Review URL: https://chromiumcodereview.appspot.com/10332024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135882 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/login/existing_user_controller.cc | 9 | ||||
-rw-r--r-- | chrome/browser/defaults.cc | 6 | ||||
-rw-r--r-- | chrome/browser/defaults.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/browser_init.cc | 12 |
4 files changed, 28 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index cfa6afd8..241d778 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -42,6 +42,7 @@ #include "chrome/common/chrome_version_info.h" #include "chrome/common/net/gaia/google_service_auth_error.h" #include "chrome/common/pref_names.h" +#include "chrome/common/url_constants.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/session_manager_client.h" #include "content/public/browser/browser_thread.h" @@ -740,6 +741,9 @@ void ExistingUserController::InitializeStartUrls() const { if (!guide_url.empty()) { CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kApp, guide_url); + // NTP would open in the background, app window with GSG would be focused + // so that user won't have an empty desktop after GSG is closed. + CommandLine::ForCurrentProcess()->AppendArg(chrome::kChromeUINewTabURL); } else { // We should not be adding any start URLs if guide // is defined as it launches as a standalone app window. @@ -819,9 +823,8 @@ void ExistingUserController::OptionallyShowReleaseNotes( if (current_version.components()[0] > prev_version.components()[0]) { std::string release_notes_url = GetGettingStartedGuideURL(); if (!release_notes_url.empty()) { - // TODO(nkostylev): Ideally we'd want to show this in app window - // but passing --app=<url> would ignore session restore. - CommandLine::ForCurrentProcess()->AppendArg(release_notes_url); + CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kApp, + release_notes_url); prefs->SetString(prefs::kChromeOSReleaseNotesVersion, current_version.GetString()); } diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc index 0e4e057..ef1c128 100644 --- a/chrome/browser/defaults.cc +++ b/chrome/browser/defaults.cc @@ -104,6 +104,12 @@ const bool kPasswordEchoEnabled = true; const bool kPasswordEchoEnabled = false; #endif +#if defined(OS_CHROMEOS) +const bool kAppRestoreSession = true; +#else +const bool kAppRestoreSession = false; +#endif + bool bookmarks_enabled = true; bool enable_help_app = true; diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h index ab69313..f96bca3 100644 --- a/chrome/browser/defaults.h +++ b/chrome/browser/defaults.h @@ -86,6 +86,11 @@ extern const int kInfoBarBorderPaddingVertical; // Last character display for passwords. extern const bool kPasswordEchoEnabled; +// Changes how browser is initialized when executed in app mode. +// If true after app window is opened continue with regular startup path +// i.e. session restore, load URLs from cmd line plus focus app window. +extern const bool kAppRestoreSession; + //============================================================================= // Runtime "const" - set only once after parsing command line option and should // never be modified after that. diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 0de3697..626af94 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -898,9 +898,16 @@ bool BrowserInit::LaunchWithProfile::Launch( // opened an app shortcut. Don't restore tabs or open initial // URLs in that case. The user should see the window as an app, // not as chrome. - if (OpenApplicationWindow(profile)) { + // Special case is when app switches are passed but we do want to restore + // session. In that case open app window + focus it after session is restored. + if (OpenApplicationWindow(profile) && !browser_defaults::kAppRestoreSession) { RecordLaunchModeHistogram(LM_AS_WEBAPP); } else { + Browser* browser_to_focus = NULL; + // In case of app mode + session restore we want to focus that app. + if (browser_defaults::kAppRestoreSession) + browser_to_focus = BrowserList::GetLastActive(); + RecordLaunchModeHistogram(urls_to_open.empty()? LM_TO_BE_DECIDED : LM_WITH_URLS); @@ -914,6 +921,9 @@ bool BrowserInit::LaunchWithProfile::Launch( // be an app tab. OpenApplicationTab(profile); + if (browser_to_focus) + browser_to_focus->GetSelectedWebContents()->GetView()->SetInitialFocus(); + if (process_startup) { if (browser_defaults::kOSSupportsOtherBrowsers && !command_line_.HasSwitch(switches::kNoDefaultBrowserCheck)) { |