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

Unified Diff: chrome/browser/ui/webui/profile_helper.cc

Issue 2692863004: Supply signin dialog with credentials if available. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/profile_helper.cc
diff --git a/chrome/browser/ui/webui/profile_helper.cc b/chrome/browser/ui/webui/profile_helper.cc
index 2f4622fc9d7dcc7ec0a5116b72d6e39125883668..d381e2eb47185d2fe31ad3b78578f3125c93b139 100644
--- a/chrome/browser/ui/webui/profile_helper.cc
+++ b/chrome/browser/ui/webui/profile_helper.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/keep_alive_types.h"
#include "chrome/browser/lifetime/scoped_keep_alive.h"
@@ -24,6 +25,26 @@
namespace webui {
namespace {
+void ShowUserManager(const ProfileManager::CreateCallback& callback) {
+ if (!UserManager::IsShowing()) {
+ UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL,
+ profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
+ }
+
+ g_browser_process->profile_manager()->CreateProfileAsync(
+ ProfileManager::GetSystemProfilePath(), callback, base::string16(),
+ std::string(), std::string());
+}
+
+std::string GetProfileUserName(Profile* profile) {
+ ProfileAttributesEntry* entry;
+ if (!g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile->GetPath(), &entry))
+ return std::string();
+ return base::UTF16ToUTF8(entry->GetUserName());
+}
+
void ShowSigninDialog(base::FilePath signin_profile_path,
Profile* system_profile,
Profile::CreateStatus status) {
@@ -31,6 +52,13 @@ void ShowSigninDialog(base::FilePath signin_profile_path,
signin_profile_path);
}
+void ShowReauthDialog(const std::string& user_name,
+ Profile* system_profile,
+ Profile::CreateStatus status) {
+ UserManagerProfileDialog::ShowReauthDialog(
+ system_profile, user_name, signin_metrics::Reason::REASON_UNLOCK);
+}
+
void DeleteProfileCallback(std::unique_ptr<ScopedKeepAlive> keep_alive,
Profile* profile,
Profile::CreateStatus status) {
@@ -43,18 +71,10 @@ void DeleteProfileCallback(std::unique_ptr<ScopedKeepAlive> keep_alive,
} // namespace
void OpenNewWindowForProfile(Profile* profile) {
- if (signin::IsForceSigninEnabled() ||
- profiles::IsProfileLocked(profile->GetPath())) {
- if (!UserManager::IsShowing()) {
- UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL,
- profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
- }
-
- g_browser_process->profile_manager()->CreateProfileAsync(
- ProfileManager::GetSystemProfilePath(),
- base::Bind(&ShowSigninDialog, profile->GetPath()), base::string16(),
- std::string(), std::string());
-
+ if (signin::IsForceSigninEnabled()) {
+ ShowUserManager(base::Bind(&ShowSigninDialog, profile->GetPath()));
+ } else if (profiles::IsProfileLocked(profile->GetPath())) {
+ ShowUserManager(base::Bind(&ShowReauthDialog, GetProfileUserName(profile)));
} else {
profiles::FindOrCreateNewWindowForProfile(
profile, chrome::startup::IS_PROCESS_STARTUP,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698