| Index: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
|
| diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
|
| index 5bd6b062699552bc62f748a4a5d665ae35c0d1e4..d950a17e5470da8ebd89abfc600f263ec46521a3 100644
|
| --- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
|
| +++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
|
| @@ -22,6 +22,8 @@
|
| #include "chrome/browser/signin/local_auth.h"
|
| #include "chrome/browser/ui/browser_dialogs.h"
|
| #include "chrome/browser/ui/browser_finder.h"
|
| +#include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/browser/ui/chrome_pages.h"
|
| #include "chrome/browser/ui/singleton_tabs.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| @@ -84,18 +86,6 @@ void OpenNewWindowForProfile(
|
| false);
|
| }
|
|
|
| -// This callback is run after switching to a new profile has finished. This
|
| -// means either a new browser window has been opened, or an existing one
|
| -// has been found, which means we can safely close the User Manager without
|
| -// accidentally terminating the browser process. The task needs to be posted,
|
| -// as HideUserManager will end up destroying its WebContents, which will
|
| -// destruct the UserManagerScreenHandler as well.
|
| -void OnSwitchToProfileComplete() {
|
| - base::MessageLoop::current()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&chrome::HideUserManager));
|
| -}
|
| -
|
| std::string GetAvatarImageAtIndex(
|
| size_t index, const ProfileInfoCache& info_cache) {
|
| bool is_gaia_picture =
|
| @@ -287,6 +277,11 @@ void UserManagerScreenHandler::Unlock(const std::string& user_email) {
|
| }
|
|
|
| void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) {
|
| + // If the URL has a hash parameter, store it for later.
|
| + base::string16 url_hash;
|
| + if (args->GetString(0, &url_hash))
|
| + url_hash_ = url_hash;
|
| +
|
| SendUserList();
|
| web_ui()->CallJavascriptFunction("cr.ui.Oobe.showUserManagerScreen",
|
| base::FundamentalValue(IsGuestModeEnabled()));
|
| @@ -297,9 +292,11 @@ void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) {
|
| }
|
|
|
| void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) {
|
| - profiles::CreateAndSwitchToNewProfile(desktop_type_,
|
| - base::Bind(&OnSwitchToProfileComplete),
|
| - ProfileMetrics::ADD_NEW_USER_MANAGER);
|
| + profiles::CreateAndSwitchToNewProfile(
|
| + desktop_type_,
|
| + base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
|
| + base::Unretained(this)),
|
| + ProfileMetrics::ADD_NEW_USER_MANAGER);
|
| }
|
|
|
| void UserManagerScreenHandler::HandleAuthenticatedLaunchUser(
|
| @@ -378,8 +375,10 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) {
|
|
|
| void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) {
|
| if (IsGuestModeEnabled()) {
|
| - profiles::SwitchToGuestProfile(desktop_type_,
|
| - base::Bind(&OnSwitchToProfileComplete));
|
| + profiles::SwitchToGuestProfile(
|
| + desktop_type_,
|
| + base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
|
| + base::Unretained(this)));
|
| ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST);
|
| } else {
|
| // The UI should have prevented the user from allowing the selection of
|
| @@ -418,11 +417,13 @@ void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
|
| ProfileMetrics::LogProfileAuthResult(ProfileMetrics::AUTH_UNNECESSARY);
|
|
|
| base::FilePath path = info_cache.GetPathOfProfileAtIndex(profile_index);
|
| - profiles::SwitchToProfile(path,
|
| - desktop_type_,
|
| - false, /* reuse any existing windows */
|
| - base::Bind(&OnSwitchToProfileComplete),
|
| - ProfileMetrics::SWITCH_PROFILE_MANAGER);
|
| + profiles::SwitchToProfile(
|
| + path,
|
| + desktop_type_,
|
| + false, /* reuse any existing windows */
|
| + base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
|
| + base::Unretained(this)),
|
| + ProfileMetrics::SWITCH_PROFILE_MANAGER);
|
| }
|
|
|
| void UserManagerScreenHandler::HandleAttemptUnlock(
|
| @@ -666,9 +667,13 @@ void UserManagerScreenHandler::ReportAuthenticationResult(
|
| authenticating_profile_index_, false);
|
| base::FilePath path = info_cache.GetPathOfProfileAtIndex(
|
| authenticating_profile_index_);
|
| - profiles::SwitchToProfile(path, desktop_type_, true,
|
| - base::Bind(&OnSwitchToProfileComplete),
|
| - ProfileMetrics::SWITCH_PROFILE_UNLOCK);
|
| + profiles::SwitchToProfile(
|
| + path,
|
| + desktop_type_,
|
| + true,
|
| + base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
|
| + base::Unretained(this)),
|
| + ProfileMetrics::SWITCH_PROFILE_UNLOCK);
|
| } else {
|
| web_ui()->CallJavascriptFunction(
|
| "cr.ui.Oobe.showSignInError",
|
| @@ -679,3 +684,32 @@ void UserManagerScreenHandler::ReportAuthenticationResult(
|
| base::FundamentalValue(0));
|
| }
|
| }
|
| +
|
| +// This callback is run after switching to a new profile has finished. This
|
| +// means either a new browser window has been opened, or an existing one
|
| +// has been found, which means we can safely close the User Manager without
|
| +// accidentally terminating the browser process. The task needs to be posted,
|
| +// as HideUserManager will end up destroying its WebContents, which will
|
| +// destruct the UserManagerScreenHandler as well.
|
| +void UserManagerScreenHandler::OnSwitchToProfileComplete(
|
| + Profile* profile, Profile::CreateStatus profile_create_status) {
|
| + base::MessageLoop::current()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&chrome::HideUserManager));
|
| + if (url_hash_ ==
|
| + base::UTF8ToUTF16(profiles::kUserManagerSelectProfileTaskManager)) {
|
| + Browser* browser = BrowserList::GetInstance(desktop_type_)->get(0);
|
| + base::MessageLoop::current()->PostTask(
|
| + FROM_HERE, base::Bind(&chrome::ShowTaskManager, browser));
|
| + } else if (url_hash_ ==
|
| + base::UTF8ToUTF16(profiles::kUserManagerSelectProfileAboutChrome)) {
|
| + // The new browser window may not have been created. Make a new one.
|
| + Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_);
|
| + if (browser) {
|
| + base::MessageLoop::current()->PostTask(
|
| + FROM_HERE, base::Bind(&chrome::ShowAboutChrome, browser));
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| + }
|
| +}
|
|
|