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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_view_controller.mm

Issue 2625813003: MacViews: Allow the toolkit-views Enterprise Signin Confirmation Dialog to be used (Closed)
Patch Set: Rebase (DID NOT LAND) 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 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 #import "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_view_contr oller.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_view_contr oller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 - (void)addButton:(NSButton*)button 135 - (void)addButton:(NSButton*)button
136 withTitle:(int)resourceID 136 withTitle:(int)resourceID
137 target:(id)target 137 target:(id)target
138 action:(SEL)action 138 action:(SEL)action
139 shouldAutoSize:(BOOL)shouldAutoSize; 139 shouldAutoSize:(BOOL)shouldAutoSize;
140 @end 140 @end
141 141
142 @implementation ProfileSigninConfirmationViewController 142 @implementation ProfileSigninConfirmationViewController
143 143
144 - (id)initWithBrowser:(Browser*)browser 144 - (id)initWithBrowser:(Browser*)browser
145 username:(const std::string&)username 145 username:(const std::string&)username
146 delegate:(ui::ProfileSigninConfirmationDelegate*)delegate 146 delegate:
147 closeDialogCallback:(const base::Closure&)closeDialogCallback 147 (std::unique_ptr<ui::ProfileSigninConfirmationDelegate>)
148 offerProfileCreation:(bool)offer { 148 delegate
149 closeDialogCallback:(const base::Closure&)closeDialogCallback
150 offerProfileCreation:(bool)offer {
149 if ((self = [super initWithNibName:nil bundle:nil])) { 151 if ((self = [super initWithNibName:nil bundle:nil])) {
150 browser_ = browser; 152 browser_ = browser;
151 username_ = username; 153 username_ = username;
152 delegate_ = delegate; 154 delegate_ = std::move(delegate);
153 closeDialogCallback_ = closeDialogCallback; 155 closeDialogCallback_ = closeDialogCallback;
154 offerProfileCreation_ = offer; 156 offerProfileCreation_ = offer;
155 } 157 }
156 return self; 158 return self;
157 } 159 }
158 160
159 - (void)loadView { 161 - (void)loadView {
160 self.view = [[[NSView alloc] initWithFrame:NSZeroRect] autorelease]; 162 self.view = [[[NSView alloc] initWithFrame:NSZeroRect] autorelease];
161 cancelButton_.reset( 163 cancelButton_.reset(
162 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]); 164 [[ConstrainedWindowButton alloc] initWithFrame:NSZeroRect]);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 dialogWidth - chrome_style::kCloseButtonPadding - 371 dialogWidth - chrome_style::kCloseButtonPadding -
370 NSWidth(closeButtonFrame), 372 NSWidth(closeButtonFrame),
371 dialogHeight - chrome_style::kCloseButtonPadding - 373 dialogHeight - chrome_style::kCloseButtonPadding -
372 NSWidth(closeButtonFrame)); 374 NSWidth(closeButtonFrame));
373 [closeButton_ setFrameOrigin:closeOrigin]; 375 [closeButton_ setFrameOrigin:closeOrigin];
374 } 376 }
375 377
376 - (IBAction)cancel:(id)sender { 378 - (IBAction)cancel:(id)sender {
377 if (delegate_) { 379 if (delegate_) {
378 delegate_->OnCancelSignin(); 380 delegate_->OnCancelSignin();
379 delegate_ = NULL; 381 delegate_ = nullptr;
380 closeDialogCallback_.Run(); 382 closeDialogCallback_.Run();
381 } 383 }
382 } 384 }
383 385
384 - (IBAction)ok:(id)sender { 386 - (IBAction)ok:(id)sender {
385 if (delegate_) { 387 if (delegate_) {
386 delegate_->OnContinueSignin(); 388 delegate_->OnContinueSignin();
387 delegate_ = NULL; 389 delegate_ = nullptr;
388 closeDialogCallback_.Run(); 390 closeDialogCallback_.Run();
389 } 391 }
390 } 392 }
391 393
392 - (IBAction)close:(id)sender { 394 - (IBAction)close:(id)sender {
393 if (delegate_) { 395 if (delegate_) {
394 delegate_->OnCancelSignin(); 396 delegate_->OnCancelSignin();
395 delegate_ = NULL; 397 delegate_ = nullptr;
396 } 398 }
397 closeDialogCallback_.Run(); 399 closeDialogCallback_.Run();
398 } 400 }
399 401
400 - (IBAction)createProfile:(id)sender { 402 - (IBAction)createProfile:(id)sender {
401 if (delegate_) { 403 if (delegate_) {
402 delegate_->OnSigninWithNewProfile(); 404 delegate_->OnSigninWithNewProfile();
403 delegate_ = NULL; 405 delegate_ = nullptr;
404 closeDialogCallback_.Run(); 406 closeDialogCallback_.Run();
405 } 407 }
406 } 408 }
407 409
408 - (void)learnMore { 410 - (void)learnMore {
409 chrome::NavigateParams params( 411 chrome::NavigateParams params(
410 browser_, GURL(chrome::kChromeEnterpriseSignInLearnMoreURL), 412 browser_, GURL(chrome::kChromeEnterpriseSignInLearnMoreURL),
411 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); 413 ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
412 params.disposition = WindowOpenDisposition::NEW_POPUP; 414 params.disposition = WindowOpenDisposition::NEW_POPUP;
413 params.window_action = chrome::NavigateParams::SHOW_WINDOW; 415 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
(...skipping 19 matching lines...) Expand all
433 [button setTitle:base::SysUTF16ToNSString( 435 [button setTitle:base::SysUTF16ToNSString(
434 l10n_util::GetStringUTF16(resourceID))]; 436 l10n_util::GetStringUTF16(resourceID))];
435 [button setTarget:target]; 437 [button setTarget:target];
436 [button setAction:action]; 438 [button setAction:action];
437 [[self view] addSubview:button]; 439 [[self view] addSubview:button];
438 if (shouldAutoSize) 440 if (shouldAutoSize)
439 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button]; 441 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button];
440 } 442 }
441 443
442 @end 444 @end
443
444 @implementation ProfileSigninConfirmationViewController (TestingAPI)
445
446 - (ui::ProfileSigninConfirmationDelegate*)delegate {
447 return delegate_;
448 }
449
450 - (NSButton*)createProfileButton {
451 return createProfileButton_.get();
452 }
453
454 - (NSTextView*)explanationField {
455 return explanationField_.get();
456 }
457
458 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698