Chromium Code Reviews| 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 89b70c6066cd7df77825a3397285c0bf6e83241d..392ccf58249cb9b6a304cd3faff16a134e07f36d 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm |
| @@ -21,6 +21,7 @@ |
| #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h" |
| #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
| #include "chrome/browser/ui/user_manager.h" |
| +#include "chrome/common/url_constants.h" |
| #include "chrome/grit/chromium_strings.h" |
| #include "components/signin/core/common/profile_management_switches.h" |
| #include "components/web_modal/web_contents_modal_dialog_host.h" |
| @@ -165,7 +166,7 @@ void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { |
| CloseReauthDialog(); |
| } |
| -private: |
| + private: |
| std::unique_ptr<UserManagerWebContentsDelegate> hotKeysWebContentsDelegate_; |
| DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); |
| @@ -186,6 +187,7 @@ - (id)initWithProfile:(Profile*)profile |
| email:(std::string)email |
| reason:(signin_metrics::Reason)reason |
| webContents:(content::WebContents*)webContents; |
| +- (void)showURL:(const GURL&)url; |
| - (void)close; |
| @end |
| @@ -233,13 +235,17 @@ - (id)initWithProfile:(Profile*)profile |
| return self; |
| } |
| +- (void)showURL:(const GURL&)url { |
| + reauthWebContents_->GetController().LoadURL(url, content::Referrer(), |
| + ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| + std::string()); |
| +} |
| + |
| - (void)show { |
| GURL url = signin::GetReauthURLWithEmail( |
| signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, reason_, |
| emailAddress_); |
| - reauthWebContents_->GetController().LoadURL(url, content::Referrer(), |
| - ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| - std::string()); |
| + [self showURL:url]; |
| } |
| - (void)closeButtonClicked:(NSButton*)button { |
| @@ -278,6 +284,7 @@ - (BOOL)isVisible; |
| - (void)showReauthDialogWithProfile:(Profile*)profile |
| email:(std::string)email |
| reason:(signin_metrics::Reason)reason; |
| +- (void)displayErrorMessage; |
| - (void)closeReauthDialog; |
| @end |
| @@ -393,6 +400,10 @@ - (void)showReauthDialogWithProfile:(Profile*)profile |
| webContents:webContents_.get()]); |
| } |
| +- (void)displayErrorMessage { |
| + [reauth_window_controller_ showURL:GURL(chrome::kChromeUISigninErrorURL)]; |
| +} |
| + |
| - (void)closeReauthDialog { |
| [reauth_window_controller_ close]; |
| } |
| @@ -487,6 +498,27 @@ - (void)closeReauthDialog { |
| user_manager_shown_callbacks_for_testing_->push_back(callback); |
| } |
| +// static |
| +void UserManager::ShowSigninDialog(content::BrowserContext* browser_context, |
| + const base::FilePath& profile_path) { |
| + if (!IsShowing()) |
| + return; |
| + instance_->SetSigninProfilePath(profile_path); |
| + ShowReauthDialog(browser_context, std::string(), |
| + signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT); |
| +} |
| + |
| +// static |
| +void UserManager::DisplayErrorMessage() { |
| + DCHECK(!instance_); |
| + instance_->DisplayErrorMessage(); |
|
michaelpg
2016/10/14 15:46:31
but you just DCHECK'd that instance_ is null...
zmin
2016/10/14 16:03:20
Oops, it should be "DCHECK(instance);" here. Thank
|
| +} |
| + |
| +// static |
| +base::FilePath UserManager::GetSigninProfilePath() { |
| + return instance_->GetSigninProfilePath(); |
| +} |
| + |
| void UserManagerMac::ShowReauthDialog(content::BrowserContext* browser_context, |
| const std::string& email, |
| signin_metrics::Reason reason) { |
| @@ -533,3 +565,15 @@ - (void)closeReauthDialog { |
| instance_ = NULL; |
| delete this; |
| } |
| + |
| +void UserManagerMac::DisplayErrorMessage() { |
| + [window_controller_ displayErrorMessage]; |
| +} |
| + |
| +void UserManagerMac::SetSigninProfilePath(const base::FilePath& profile_path) { |
| + signin_profile_path_ = profile_path; |
| +} |
| + |
| +base::FilePath UserManagerMac::GetSigninProfilePath() { |
| + return signin_profile_path_; |
| +} |