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

Unified Diff: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm

Issue 2552473002: Display error message when user try to open a locked supervised user profile when force-sign-in is … (Closed)
Patch Set: refactor Created 4 years 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
Index: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
diff --git a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
index fb6095915eff3d51a2fbcbf823a0478bf2f19f3a..a7142f632cc473d870dc22c9e1b274f81c6730e9 100644
--- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
+++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
@@ -56,7 +56,7 @@ BOOL instance_under_construction_ = NO;
void CloseInstanceReauthDialog() {
DCHECK(instance_);
- instance_->CloseReauthDialog();
+ instance_->CloseDialog();
}
// The modal dialog host the User Manager uses to display the reauth dialog.
@@ -177,15 +177,15 @@ class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate,
: NSWindowController <NSWindowDelegate> {
@private
std::string emailAddress_;
+ GURL url_;
content::WebContents* webContents_;
- signin_metrics::Reason reason_;
std::unique_ptr<ReauthDialogDelegate> webContentsDelegate_;
std::unique_ptr<ConstrainedWindowMac> constrained_window_;
std::unique_ptr<content::WebContents> reauthWebContents_;
}
- (id)initWithProfile:(Profile*)profile
email:(std::string)email
- reason:(signin_metrics::Reason)reason
+ url:(GURL)url
webContents:(content::WebContents*)webContents;
- (void)showURL:(const GURL&)url;
- (void)close;
@@ -195,11 +195,11 @@ class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate,
- (id)initWithProfile:(Profile*)profile
email:(std::string)email
- reason:(signin_metrics::Reason)reason
+ url:(GURL)url
webContents:(content::WebContents*)webContents {
webContents_ = webContents;
emailAddress_ = email;
- reason_ = reason;
+ url_ = url;
NSRect frame = NSMakeRect(
0, 0, UserManager::kReauthDialogWidth, UserManager::kReauthDialogHeight);
@@ -242,10 +242,7 @@ class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate,
}
- (void)show {
- GURL url = signin::GetReauthURLWithEmail(
- signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, reason_,
- emailAddress_);
- [self showURL:url];
+ [self showURL:url_];
}
- (void)closeButtonClicked:(NSButton*)button {
@@ -281,11 +278,11 @@ class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate,
- (void)show;
- (void)close;
- (BOOL)isVisible;
-- (void)showReauthDialogWithProfile:(Profile*)profile
- email:(std::string)email
- reason:(signin_metrics::Reason)reason;
+- (void)showDialogWithProfile:(Profile*)profile
+ email:(std::string)email
+ url:(GURL)url;
- (void)displayErrorMessage;
-- (void)closeReauthDialog;
+- (void)closeDialog;
@end
@implementation UserManagerWindowController
@@ -390,13 +387,13 @@ class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate,
userManagerObserver_->WindowWasClosed();
}
-- (void)showReauthDialogWithProfile:(Profile*)profile
- email:(std::string)email
- reason:(signin_metrics::Reason)reason {
+- (void)showDialogWithProfile:(Profile*)profile
+ email:(std::string)email
+ url:(GURL)url {
reauth_window_controller_.reset([[ReauthDialogWindowController alloc]
initWithProfile:profile
email:email
- reason:reason
+ url:url
webContents:webContents_.get()]);
}
@@ -404,7 +401,7 @@ class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate,
[reauth_window_controller_ showURL:GURL(chrome::kChromeUISigninErrorURL)];
}
-- (void)closeReauthDialog {
+- (void)closeDialog {
[reauth_window_controller_ close];
}
@@ -477,17 +474,18 @@ void UserManager::ShowReauthDialog(content::BrowserContext* browser_context,
// This method should only be called if the user manager is already showing.
if (!IsShowing())
return;
-
- instance_->ShowReauthDialog(browser_context, email, reason);
+ GURL url = signin::GetReauthURLWithEmail(
+ signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, reason, email);
+ instance_->ShowDialog(browser_context, email, url);
}
// static
-void UserManager::HideReauthDialog() {
+void UserManager::HideDialog() {
// This method should only be called if the user manager is already showing.
if (!IsShowing())
return;
- instance_->CloseReauthDialog();
+ instance_->CloseDialog();
}
// static
@@ -504,8 +502,10 @@ void UserManager::ShowSigninDialog(content::BrowserContext* browser_context,
if (!IsShowing())
return;
instance_->SetSigninProfilePath(profile_path);
- ShowReauthDialog(browser_context, std::string(),
- signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT);
+ GURL url = signin::GetPromoURL(
+ signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER,
+ signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, true, true);
+ instance_->ShowDialog(browser_context, std::string(), url);
}
// static
@@ -515,21 +515,29 @@ void UserManager::DisplayErrorMessage() {
}
// static
+void UserManager::ShowDialogAndDisplayErrorMessage(
+ content::BrowserContext* browser_context) {
+ DCHECK(instance_);
+ instance_->ShowDialog(browser_context, std::string(),
+ GURL(chrome::kChromeUISigninErrorURL));
+}
+
+// static
base::FilePath UserManager::GetSigninProfilePath() {
return instance_->GetSigninProfilePath();
}
-void UserManagerMac::ShowReauthDialog(content::BrowserContext* browser_context,
- const std::string& email,
- signin_metrics::Reason reason) {
+void UserManagerMac::ShowDialog(content::BrowserContext* browser_context,
+ const std::string& email,
+ const GURL& url) {
[window_controller_
- showReauthDialogWithProfile:Profile::FromBrowserContext(browser_context)
- email:email
- reason:reason];
+ showDialogWithProfile:Profile::FromBrowserContext(browser_context)
+ email:email
+ url:url];
}
-void UserManagerMac::CloseReauthDialog() {
- [window_controller_ closeReauthDialog];
+void UserManagerMac::CloseDialog() {
+ [window_controller_ closeDialog];
}
UserManagerMac::UserManagerMac(Profile* profile) {
@@ -561,7 +569,7 @@ void UserManagerMac::LogTimeToOpen() {
}
void UserManagerMac::WindowWasClosed() {
- CloseReauthDialog();
+ CloseDialog();
instance_ = NULL;
delete this;
}

Powered by Google App Engine
This is Rietveld 408576698