Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc

Issue 1968703002: MD User Manager: Creates new browser window for last active profile if one is not available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc
diff --git a/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc b/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc
index a7db3100c2138f515ef9f321d9a8a6491c7be5c2..c7eb3a4b86be19be15d3b03f3d046d840202b12c 100644
--- a/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc
+++ b/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc
@@ -32,6 +32,7 @@
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_manager.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/referrer.h"
#include "grit/theme_resources.h"
@@ -93,12 +94,30 @@ void SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser(
NEW_FOREGROUND_TAB,
ui::PAGE_TRANSITION_LINK,
false);
- // Get the browser owned by the last used profile.
- Browser* browser =
- chrome::FindLastActiveWithProfile(ProfileManager::GetLastUsedProfile());
- DCHECK(browser);
- if (browser)
+ // ProfileManager::GetLastUsedProfile() will attempt to load the default
+ // profile if there is no last used profile. If the default profile is not
+ // fully loaded and initialized, it will attempt to do so synchronously.
+ // Therefore we cannot use that method here. If the last used profile is not
+ // loaded, we do nothing. This is an edge case and should not happen often.
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ base::FilePath last_used_profile_dir =
+ profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir());
+ Profile* last_used_profile =
+ profile_manager->GetProfileByPath(last_used_profile_dir);
+
+ if (last_used_profile) {
+ // Last used profile may be the Guest Profile.
+ if (ProfileManager::IncognitoModeForced(last_used_profile))
+ last_used_profile = last_used_profile->GetOffTheRecordProfile();
+
+ // Get the browser owned by the last used profile or create a new one if
+ // it doesn't exist.
+ Browser* browser = chrome::FindLastActiveWithProfile(last_used_profile);
+ if (!browser)
+ browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED,
+ last_used_profile));
browser->OpenURL(params);
+ }
}
void SigninSupervisedUserImportHandler::GetExistingSupervisedUsers(
« no previous file with comments | « chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698