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

Side by Side 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: refacotr 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" 5 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #import "chrome/browser/app_controller_mac.h" 10 #import "chrome/browser/app_controller_mac.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 [controller windowChangedToProfile:profile]; 47 [controller windowChangedToProfile:profile];
48 } 48 }
49 } 49 }
50 50
51 // An open User Manager window. There can only be one open at a time. This 51 // An open User Manager window. There can only be one open at a time. This
52 // is reset to NULL when the window is closed. 52 // is reset to NULL when the window is closed.
53 UserManagerMac* instance_ = nullptr; // Weak. 53 UserManagerMac* instance_ = nullptr; // Weak.
54 std::vector<base::Closure>* user_manager_shown_callbacks_for_testing_ = nullptr; 54 std::vector<base::Closure>* user_manager_shown_callbacks_for_testing_ = nullptr;
55 BOOL instance_under_construction_ = NO; 55 BOOL instance_under_construction_ = NO;
56 56
57 void CloseInstanceReauthDialog() { 57 void CloseInstanceDialog() {
58 DCHECK(instance_); 58 DCHECK(instance_);
59 instance_->CloseReauthDialog(); 59 instance_->CloseDialog();
60 } 60 }
61 61
62 // The modal dialog host the User Manager uses to display the reauth dialog. 62 // The modal dialog host the User Manager uses to display the dialog.
63 class UserManagerModalHost : public web_modal::WebContentsModalDialogHost { 63 class UserManagerModalHost : public web_modal::WebContentsModalDialogHost {
64 public: 64 public:
65 UserManagerModalHost(gfx::NativeView host_view) 65 UserManagerModalHost(gfx::NativeView host_view)
66 : host_view_(host_view) {} 66 : host_view_(host_view) {}
67 67
68 gfx::Size GetMaximumDialogSize() override { 68 gfx::Size GetMaximumDialogSize() override {
69 return switches::UsePasswordSeparatedSigninFlow() ? 69 return switches::UsePasswordSeparatedSigninFlow()
70 gfx::Size(UserManager::kReauthDialogWidth, 70 ? gfx::Size(UserManagerDialog::kDialogWidth,
71 UserManager::kReauthDialogHeight) : 71 UserManagerDialog::kDialogHeight)
72 gfx::Size(UserManager::kPasswordCombinedReauthDialogWidth, 72 : gfx::Size(UserManagerDialog::kPasswordCombinedDialogWidth,
73 UserManager::kPasswordCombinedReauthDialogHeight); 73 UserManagerDialog::kPasswordCombinedDialogHeight);
74 } 74 }
75 75
76 ~UserManagerModalHost() override {} 76 ~UserManagerModalHost() override {}
77 77
78 gfx::NativeView GetHostView() const override { 78 gfx::NativeView GetHostView() const override {
79 return host_view_; 79 return host_view_;
80 } 80 }
81 81
82 gfx::Point GetDialogPosition(const gfx::Size& size) override { 82 gfx::Point GetDialogPosition(const gfx::Size& size) override {
83 return gfx::Point(0, 0); 83 return gfx::Point(0, 0);
84 } 84 }
85 85
86 void AddObserver(web_modal::ModalDialogHostObserver* observer) override {} 86 void AddObserver(web_modal::ModalDialogHostObserver* observer) override {}
87 void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override {} 87 void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override {}
88 88
89 private: 89 private:
90 gfx::NativeView host_view_; 90 gfx::NativeView host_view_;
91 }; 91 };
92 92
93 // The modal manager delegate allowing the display of constrained windows for 93 // The modal manager delegate allowing the display of constrained windows for
94 // the reauth dialog. 94 // the dialog.
95 class UserManagerModalManagerDelegate : 95 class UserManagerModalManagerDelegate :
96 public web_modal::WebContentsModalDialogManagerDelegate { 96 public web_modal::WebContentsModalDialogManagerDelegate {
97 public: 97 public:
98 UserManagerModalManagerDelegate(gfx::NativeView host_view) { 98 UserManagerModalManagerDelegate(gfx::NativeView host_view) {
99 modal_host_.reset(new UserManagerModalHost(host_view)); 99 modal_host_.reset(new UserManagerModalHost(host_view));
100 } 100 }
101 101
102 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() 102 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
103 override { 103 override {
104 return modal_host_.get(); 104 return modal_host_.get();
(...skipping 28 matching lines...) Expand all
133 BOOL isTextEditingCommand = [BrowserWindowUtils isTextEditingEvent:event]; 133 BOOL isTextEditingCommand = [BrowserWindowUtils isTextEditingEvent:event];
134 134
135 // Only handle close window Chrome accelerators and text editing ones. 135 // Only handle close window Chrome accelerators and text editing ones.
136 if (chromeCommandId == IDC_CLOSE_WINDOW || chromeCommandId == IDC_EXIT || 136 if (chromeCommandId == IDC_CLOSE_WINDOW || chromeCommandId == IDC_EXIT ||
137 isTextEditingCommand) { 137 isTextEditingCommand) {
138 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; 138 [[NSApp mainMenu] performKeyEquivalent:event.os_event];
139 } 139 }
140 } 140 }
141 }; 141 };
142 142
143 class ReauthDialogDelegate : public UserManager::BaseReauthDialogDelegate, 143 class UserManagerDialogDelegate : public UserManagerDialog::BaseDialogDelegate,
144 public ConstrainedWindowMacDelegate { 144 public ConstrainedWindowMacDelegate {
145 public: 145 public:
146 ReauthDialogDelegate() { 146 UserManagerDialogDelegate() {
147 hotKeysWebContentsDelegate_.reset(new UserManagerWebContentsDelegate()); 147 hotKeysWebContentsDelegate_.reset(new UserManagerWebContentsDelegate());
148 } 148 }
149 149
150 // UserManager::BaseReauthDialogDelegate: 150 // UserManagerDialog::BaseDialogDelegate:
151 void CloseReauthDialog() override { 151 void CloseDialog() override { CloseInstanceDialog(); }
152 CloseInstanceReauthDialog();
153 }
154 152
155 // WebContentsDelegate::HandleKeyboardEvent: 153 // WebContentsDelegate::HandleKeyboardEvent:
156 void HandleKeyboardEvent( 154 void HandleKeyboardEvent(
157 content::WebContents* source, 155 content::WebContents* source,
158 const content::NativeWebKeyboardEvent& event) override { 156 const content::NativeWebKeyboardEvent& event) override {
159 hotKeysWebContentsDelegate_->HandleKeyboardEvent(source, event); 157 hotKeysWebContentsDelegate_->HandleKeyboardEvent(source, event);
160 } 158 }
161 159
162 // ConstrainedWindowMacDelegate: 160 // ConstrainedWindowMacDelegate:
163 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { 161 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override {
164 CloseReauthDialog(); 162 CloseDialog();
165 } 163 }
166 164
167 private: 165 private:
168 std::unique_ptr<UserManagerWebContentsDelegate> hotKeysWebContentsDelegate_; 166 std::unique_ptr<UserManagerWebContentsDelegate> hotKeysWebContentsDelegate_;
169 167
170 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); 168 DISALLOW_COPY_AND_ASSIGN(UserManagerDialogDelegate);
171 }; 169 };
172 170
173 } // namespace 171 } // namespace
174 172
175 // WindowController for the reauth dialog. 173 // WindowController for the dialog.
176 @interface ReauthDialogWindowController 174 @interface DialogWindowController : NSWindowController<NSWindowDelegate> {
177 : NSWindowController <NSWindowDelegate> {
178 @private 175 @private
179 std::string emailAddress_; 176 std::string emailAddress_;
177 GURL url_;
180 content::WebContents* webContents_; 178 content::WebContents* webContents_;
181 signin_metrics::Reason reason_; 179 std::unique_ptr<UserManagerDialogDelegate> webContentsDelegate_;
182 std::unique_ptr<ReauthDialogDelegate> webContentsDelegate_;
183 std::unique_ptr<ConstrainedWindowMac> constrained_window_; 180 std::unique_ptr<ConstrainedWindowMac> constrained_window_;
184 std::unique_ptr<content::WebContents> reauthWebContents_; 181 std::unique_ptr<content::WebContents> dialogWebContents_;
185 } 182 }
186 - (id)initWithProfile:(Profile*)profile 183 - (id)initWithProfile:(Profile*)profile
187 email:(std::string)email 184 email:(std::string)email
188 reason:(signin_metrics::Reason)reason 185 url:(GURL)url
189 webContents:(content::WebContents*)webContents; 186 webContents:(content::WebContents*)webContents;
190 - (void)showURL:(const GURL&)url; 187 - (void)showURL:(const GURL&)url;
191 - (void)close; 188 - (void)close;
192 @end 189 @end
193 190
194 @implementation ReauthDialogWindowController 191 @implementation DialogWindowController
195 192
196 - (id)initWithProfile:(Profile*)profile 193 - (id)initWithProfile:(Profile*)profile
197 email:(std::string)email 194 email:(std::string)email
198 reason:(signin_metrics::Reason)reason 195 url:(GURL)url
199 webContents:(content::WebContents*)webContents { 196 webContents:(content::WebContents*)webContents {
200 webContents_ = webContents; 197 webContents_ = webContents;
201 emailAddress_ = email; 198 emailAddress_ = email;
202 reason_ = reason; 199 url_ = url;
203 200
204 NSRect frame = NSMakeRect( 201 NSRect frame = NSMakeRect(0, 0, UserManagerDialog::kDialogWidth,
205 0, 0, UserManager::kReauthDialogWidth, UserManager::kReauthDialogHeight); 202 UserManagerDialog::kDialogHeight);
206 base::scoped_nsobject<ConstrainedWindowCustomWindow> window( 203 base::scoped_nsobject<ConstrainedWindowCustomWindow> window(
207 [[ConstrainedWindowCustomWindow alloc] 204 [[ConstrainedWindowCustomWindow alloc]
208 initWithContentRect:frame 205 initWithContentRect:frame
209 styleMask:NSTitledWindowMask | NSClosableWindowMask]); 206 styleMask:NSTitledWindowMask | NSClosableWindowMask]);
210 if ((self = [super initWithWindow:window])) { 207 if ((self = [super initWithWindow:window])) {
211 webContents_ = webContents; 208 webContents_ = webContents;
212 209
213 reauthWebContents_.reset(content::WebContents::Create( 210 dialogWebContents_.reset(content::WebContents::Create(
214 content::WebContents::CreateParams(profile))); 211 content::WebContents::CreateParams(profile)));
215 window.get().contentView = reauthWebContents_->GetNativeView(); 212 window.get().contentView = dialogWebContents_->GetNativeView();
216 webContentsDelegate_.reset(new ReauthDialogDelegate()); 213 webContentsDelegate_.reset(new UserManagerDialogDelegate());
217 reauthWebContents_->SetDelegate(webContentsDelegate_.get()); 214 dialogWebContents_->SetDelegate(webContentsDelegate_.get());
218 215
219 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 216 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
220 [[CustomConstrainedWindowSheet alloc] 217 [[CustomConstrainedWindowSheet alloc]
221 initWithCustomWindow:[self window]]); 218 initWithCustomWindow:[self window]]);
222 constrained_window_ = 219 constrained_window_ =
223 CreateAndShowWebModalDialogMac( 220 CreateAndShowWebModalDialogMac(
224 webContentsDelegate_.get(), webContents_, sheet); 221 webContentsDelegate_.get(), webContents_, sheet);
225 222
226 // The close button needs to call CloseWebContentsModalDialog() on the 223 // The close button needs to call CloseWebContentsModalDialog() on the
227 // constrained window isntead of just [window close] so grab a reference to 224 // constrained window isntead of just [window close] so grab a reference to
228 // it in the title bar and change its action. 225 // it in the title bar and change its action.
229 auto closeButton = [window standardWindowButton:NSWindowCloseButton]; 226 auto closeButton = [window standardWindowButton:NSWindowCloseButton];
230 [closeButton setTarget:self]; 227 [closeButton setTarget:self];
231 [closeButton setAction:@selector(closeButtonClicked:)]; 228 [closeButton setAction:@selector(closeButtonClicked:)];
232 [self show]; 229 [self show];
233 } 230 }
234 231
235 return self; 232 return self;
236 } 233 }
237 234
238 - (void)showURL:(const GURL&)url { 235 - (void)showURL:(const GURL&)url {
239 reauthWebContents_->GetController().LoadURL(url, content::Referrer(), 236 dialogWebContents_->GetController().LoadURL(url, content::Referrer(),
240 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 237 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
241 std::string()); 238 std::string());
242 } 239 }
243 240
244 - (void)show { 241 - (void)show {
245 GURL url = signin::GetReauthURLWithEmail( 242 [self showURL:url_];
246 signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, reason_,
247 emailAddress_);
248 [self showURL:url];
249 } 243 }
250 244
251 - (void)closeButtonClicked:(NSButton*)button { 245 - (void)closeButtonClicked:(NSButton*)button {
252 [self close]; 246 [self close];
253 } 247 }
254 248
255 - (void)close { 249 - (void)close {
256 constrained_window_->CloseWebContentsModalDialog(); 250 constrained_window_->CloseWebContentsModalDialog();
257 } 251 }
258 252
259 - (void)dealloc { 253 - (void)dealloc {
260 constrained_window_->CloseWebContentsModalDialog(); 254 constrained_window_->CloseWebContentsModalDialog();
261 255
262 [super dealloc]; 256 [super dealloc];
263 } 257 }
264 258
265 @end 259 @end
266 260
267 // Window controller for the User Manager view. 261 // Window controller for the User Manager view.
268 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> { 262 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> {
269 @private 263 @private
270 std::unique_ptr<content::WebContents> webContents_; 264 std::unique_ptr<content::WebContents> webContents_;
271 std::unique_ptr<UserManagerWebContentsDelegate> webContentsDelegate_; 265 std::unique_ptr<UserManagerWebContentsDelegate> webContentsDelegate_;
272 UserManagerMac* userManagerObserver_; // Weak. 266 UserManagerMac* userManagerObserver_; // Weak.
273 std::unique_ptr<UserManagerModalManagerDelegate> modal_manager_delegate_; 267 std::unique_ptr<UserManagerModalManagerDelegate> modal_manager_delegate_;
274 base::scoped_nsobject<ReauthDialogWindowController> reauth_window_controller_; 268 base::scoped_nsobject<DialogWindowController> dialog_window_controller_;
275 } 269 }
276 - (void)windowWillClose:(NSNotification*)notification; 270 - (void)windowWillClose:(NSNotification*)notification;
277 - (void)dealloc; 271 - (void)dealloc;
278 - (id)initWithProfile:(Profile*)profile 272 - (id)initWithProfile:(Profile*)profile
279 withObserver:(UserManagerMac*)userManagerObserver; 273 withObserver:(UserManagerMac*)userManagerObserver;
280 - (void)showURL:(const GURL&)url; 274 - (void)showURL:(const GURL&)url;
281 - (void)show; 275 - (void)show;
282 - (void)close; 276 - (void)close;
283 - (BOOL)isVisible; 277 - (BOOL)isVisible;
284 - (void)showReauthDialogWithProfile:(Profile*)profile 278 - (void)showDialogWithProfile:(Profile*)profile
285 email:(std::string)email 279 email:(std::string)email
286 reason:(signin_metrics::Reason)reason; 280 url:(GURL)url;
287 - (void)displayErrorMessage; 281 - (void)displayErrorMessage;
288 - (void)closeReauthDialog; 282 - (void)closeDialog;
289 @end 283 @end
290 284
291 @implementation UserManagerWindowController 285 @implementation UserManagerWindowController
292 286
293 - (id)initWithProfile:(Profile*)profile 287 - (id)initWithProfile:(Profile*)profile
294 withObserver:(UserManagerMac*)userManagerObserver { 288 withObserver:(UserManagerMac*)userManagerObserver {
295 // Center the window on the screen that currently has focus. 289 // Center the window on the screen that currently has focus.
296 NSScreen* mainScreen = [NSScreen mainScreen]; 290 NSScreen* mainScreen = [NSScreen mainScreen];
297 CGFloat screenHeight = [mainScreen frame].size.height; 291 CGFloat screenHeight = [mainScreen frame].size.height;
298 CGFloat screenWidth = [mainScreen frame].size.width; 292 CGFloat screenWidth = [mainScreen frame].size.width;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 -(BOOL)isVisible { 377 -(BOOL)isVisible {
384 return [[self window] isVisible]; 378 return [[self window] isVisible];
385 } 379 }
386 380
387 - (void)windowWillClose:(NSNotification*)notification { 381 - (void)windowWillClose:(NSNotification*)notification {
388 [[NSNotificationCenter defaultCenter] removeObserver:self]; 382 [[NSNotificationCenter defaultCenter] removeObserver:self];
389 DCHECK(userManagerObserver_); 383 DCHECK(userManagerObserver_);
390 userManagerObserver_->WindowWasClosed(); 384 userManagerObserver_->WindowWasClosed();
391 } 385 }
392 386
393 - (void)showReauthDialogWithProfile:(Profile*)profile 387 - (void)showDialogWithProfile:(Profile*)profile
394 email:(std::string)email 388 email:(std::string)email
395 reason:(signin_metrics::Reason)reason { 389 url:(GURL)url {
396 reauth_window_controller_.reset([[ReauthDialogWindowController alloc] 390 dialog_window_controller_.reset([[DialogWindowController alloc]
397 initWithProfile:profile 391 initWithProfile:profile
398 email:email 392 email:email
399 reason:reason 393 url:url
400 webContents:webContents_.get()]); 394 webContents:webContents_.get()]);
401 } 395 }
402 396
403 - (void)displayErrorMessage { 397 - (void)displayErrorMessage {
404 [reauth_window_controller_ showURL:GURL(chrome::kChromeUISigninErrorURL)]; 398 [dialog_window_controller_ showURL:GURL(chrome::kChromeUISigninErrorURL)];
405 } 399 }
406 400
407 - (void)closeReauthDialog { 401 - (void)closeDialog {
408 [reauth_window_controller_ close]; 402 [dialog_window_controller_ close];
409 } 403 }
410 404
411 @end 405 @end
412 406
413 407
414 // static 408 // static
415 void UserManager::Show( 409 void UserManager::Show(
416 const base::FilePath& profile_path_to_focus, 410 const base::FilePath& profile_path_to_focus,
417 profiles::UserManagerTutorialMode tutorial_mode, 411 profiles::UserManagerTutorialMode tutorial_mode,
418 profiles::UserManagerAction user_manager_action) { 412 profiles::UserManagerAction user_manager_action) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 callback.Run(); 458 callback.Run();
465 } 459 }
466 // Delete the callback list after calling. 460 // Delete the callback list after calling.
467 delete user_manager_shown_callbacks_for_testing_; 461 delete user_manager_shown_callbacks_for_testing_;
468 user_manager_shown_callbacks_for_testing_ = nullptr; 462 user_manager_shown_callbacks_for_testing_ = nullptr;
469 } 463 }
470 } 464 }
471 } 465 }
472 466
473 // static 467 // static
474 void UserManager::ShowReauthDialog(content::BrowserContext* browser_context,
475 const std::string& email,
476 signin_metrics::Reason reason) {
477 // This method should only be called if the user manager is already showing.
478 if (!IsShowing())
479 return;
480
481 instance_->ShowReauthDialog(browser_context, email, reason);
482 }
483
484 // static
485 void UserManager::HideReauthDialog() {
486 // This method should only be called if the user manager is already showing.
487 if (!IsShowing())
488 return;
489
490 instance_->CloseReauthDialog();
491 }
492
493 // static
494 void UserManager::AddOnUserManagerShownCallbackForTesting( 468 void UserManager::AddOnUserManagerShownCallbackForTesting(
495 const base::Closure& callback) { 469 const base::Closure& callback) {
496 if (!user_manager_shown_callbacks_for_testing_) 470 if (!user_manager_shown_callbacks_for_testing_)
497 user_manager_shown_callbacks_for_testing_ = new std::vector<base::Closure>; 471 user_manager_shown_callbacks_for_testing_ = new std::vector<base::Closure>;
498 user_manager_shown_callbacks_for_testing_->push_back(callback); 472 user_manager_shown_callbacks_for_testing_->push_back(callback);
499 } 473 }
500 474
501 // static 475 // static
502 void UserManager::ShowSigninDialog(content::BrowserContext* browser_context, 476 base::FilePath UserManager::GetSigninProfilePath() {
503 const base::FilePath& profile_path) { 477 return instance_->GetSigninProfilePath();
504 if (!IsShowing())
505 return;
506 instance_->SetSigninProfilePath(profile_path);
507 ShowReauthDialog(browser_context, std::string(),
508 signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT);
509 } 478 }
510 479
511 // static 480 // static
512 void UserManager::DisplayErrorMessage() { 481 void UserManagerDialog::ShowReauthDialog(
482 content::BrowserContext* browser_context,
483 const std::string& email,
484 signin_metrics::Reason reason) {
485 // This method should only be called if the user manager is already showing.
486 if (!UserManager::IsShowing())
487 return;
488 GURL url = signin::GetReauthURLWithEmail(
489 signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, reason, email);
490 instance_->ShowDialog(browser_context, email, url);
491 }
492
493 // static
494 void UserManagerDialog::ShowSigninDialog(
495 content::BrowserContext* browser_context,
496 const base::FilePath& profile_path) {
497 if (!UserManager::IsShowing())
498 return;
499 instance_->SetSigninProfilePath(profile_path);
500 GURL url = signin::GetPromoURL(
501 signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER,
502 signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, true, true);
503 instance_->ShowDialog(browser_context, std::string(), url);
504 }
505
506 // static
507 void UserManagerDialog::ShowDialogAndDisplayErrorMessage(
508 content::BrowserContext* browser_context) {
509 if (!UserManager::IsShowing())
510 return;
511 instance_->ShowDialog(browser_context, std::string(),
512 GURL(chrome::kChromeUISigninErrorURL));
513 }
514
515 // static
516 void UserManagerDialog::DisplayErrorMessage() {
513 DCHECK(instance_); 517 DCHECK(instance_);
514 instance_->DisplayErrorMessage(); 518 instance_->DisplayErrorMessage();
515 } 519 }
516 520
517 // static 521 // static
518 base::FilePath UserManager::GetSigninProfilePath() { 522 void UserManagerDialog::HideDialog() {
519 return instance_->GetSigninProfilePath(); 523 // This method should only be called if the user manager is already showing.
524 if (!UserManager::IsShowing())
525 return;
526
527 instance_->CloseDialog();
520 } 528 }
521 529
522 void UserManagerMac::ShowReauthDialog(content::BrowserContext* browser_context, 530 void UserManagerMac::ShowDialog(content::BrowserContext* browser_context,
523 const std::string& email, 531 const std::string& email,
524 signin_metrics::Reason reason) { 532 const GURL& url) {
525 [window_controller_ 533 [window_controller_
526 showReauthDialogWithProfile:Profile::FromBrowserContext(browser_context) 534 showDialogWithProfile:Profile::FromBrowserContext(browser_context)
527 email:email 535 email:email
528 reason:reason]; 536 url:url];
529 } 537 }
530 538
531 void UserManagerMac::CloseReauthDialog() { 539 void UserManagerMac::CloseDialog() {
532 [window_controller_ closeReauthDialog]; 540 [window_controller_ closeDialog];
533 } 541 }
534 542
535 UserManagerMac::UserManagerMac(Profile* profile) { 543 UserManagerMac::UserManagerMac(Profile* profile) {
536 window_controller_.reset([[UserManagerWindowController alloc] 544 window_controller_.reset([[UserManagerWindowController alloc]
537 initWithProfile:profile withObserver:this]); 545 initWithProfile:profile withObserver:this]);
538 } 546 }
539 547
540 UserManagerMac::~UserManagerMac() { 548 UserManagerMac::~UserManagerMac() {
541 } 549 }
542 550
(...skipping 11 matching lines...) Expand all
554 void UserManagerMac::LogTimeToOpen() { 562 void UserManagerMac::LogTimeToOpen() {
555 if (user_manager_started_showing_ == base::Time()) 563 if (user_manager_started_showing_ == base::Time())
556 return; 564 return;
557 565
558 ProfileMetrics::LogTimeToOpenUserManager( 566 ProfileMetrics::LogTimeToOpenUserManager(
559 base::Time::Now() - user_manager_started_showing_); 567 base::Time::Now() - user_manager_started_showing_);
560 user_manager_started_showing_ = base::Time(); 568 user_manager_started_showing_ = base::Time();
561 } 569 }
562 570
563 void UserManagerMac::WindowWasClosed() { 571 void UserManagerMac::WindowWasClosed() {
564 CloseReauthDialog(); 572 CloseDialog();
565 instance_ = NULL; 573 instance_ = NULL;
566 delete this; 574 delete this;
567 } 575 }
568 576
569 void UserManagerMac::DisplayErrorMessage() { 577 void UserManagerMac::DisplayErrorMessage() {
570 [window_controller_ displayErrorMessage]; 578 [window_controller_ displayErrorMessage];
571 } 579 }
572 580
573 void UserManagerMac::SetSigninProfilePath(const base::FilePath& profile_path) { 581 void UserManagerMac::SetSigninProfilePath(const base::FilePath& profile_path) {
574 signin_profile_path_ = profile_path; 582 signin_profile_path_ = profile_path;
575 } 583 }
576 584
577 base::FilePath UserManagerMac::GetSigninProfilePath() { 585 base::FilePath UserManagerMac::GetSigninProfilePath() {
578 return signin_profile_path_; 586 return signin_profile_path_;
579 } 587 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698