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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.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_dialog_coc oa.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_coc oa.h"
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h"
12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h"
13 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" 13 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 15
16 namespace { 16 namespace {
17 17
18 // static 18 // static
19 void ShowDialog( 19 void ShowDialog(Browser* browser,
20 Browser* browser, 20 content::WebContents* web_contents,
21 content::WebContents* web_contents, 21 Profile* profile,
22 Profile* profile, 22 const std::string& username,
23 const std::string& username, 23 std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate,
24 ui::ProfileSigninConfirmationDelegate* delegate, 24 bool offer_profile_creation) {
25 bool offer_profile_creation) {
26 // The dialog owns itself. 25 // The dialog owns itself.
27 new ProfileSigninConfirmationDialogCocoa(browser, 26 new ProfileSigninConfirmationDialogCocoa(browser, web_contents, profile,
28 web_contents, 27 username, std::move(delegate),
29 profile,
30 username,
31 delegate,
32 offer_profile_creation); 28 offer_profile_creation);
33 } 29 }
34 30
35 } // namespace 31 } // namespace
36 32
37 ProfileSigninConfirmationDialogCocoa::ProfileSigninConfirmationDialogCocoa( 33 ProfileSigninConfirmationDialogCocoa::ProfileSigninConfirmationDialogCocoa(
38 Browser* browser, 34 Browser* browser,
39 content::WebContents* web_contents, 35 content::WebContents* web_contents,
40 Profile* profile, 36 Profile* profile,
41 const std::string& username, 37 const std::string& username,
42 ui::ProfileSigninConfirmationDelegate* delegate, 38 std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate,
43 bool offer_profile_creation) { 39 bool offer_profile_creation) {
44 // Setup the dialog view controller. 40 // Setup the dialog view controller.
45 const base::Closure& closeDialogCallback = 41 const base::Closure& closeDialogCallback =
46 base::Bind(&ProfileSigninConfirmationDialogCocoa::Close, 42 base::Bind(&ProfileSigninConfirmationDialogCocoa::Close,
47 base::Unretained(this)); 43 base::Unretained(this));
48 controller_.reset( 44 controller_.reset([[ProfileSigninConfirmationViewController alloc]
49 [[ProfileSigninConfirmationViewController alloc] 45 initWithBrowser:browser
50 initWithBrowser:browser 46 username:username
51 username:username 47 delegate:std::move(delegate)
52 delegate:delegate 48 closeDialogCallback:closeDialogCallback
53 closeDialogCallback:closeDialogCallback 49 offerProfileCreation:offer_profile_creation]);
54 offerProfileCreation:offer_profile_creation]);
55 50
56 // Setup the constrained window that will show the view. 51 // Setup the constrained window that will show the view.
57 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] 52 base::scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc]
58 initWithContentRect:[[controller_ view] bounds]]); 53 initWithContentRect:[[controller_ view] bounds]]);
59 [[window contentView] addSubview:[controller_ view]]; 54 [[window contentView] addSubview:[controller_ view]];
60 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 55 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
61 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]); 56 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window]);
62 window_ = CreateAndShowWebModalDialogMac(this, web_contents, sheet); 57 window_ = CreateAndShowWebModalDialogMac(this, web_contents, sheet);
63 } 58 }
64 59
65 ProfileSigninConfirmationDialogCocoa::~ProfileSigninConfirmationDialogCocoa() { 60 ProfileSigninConfirmationDialogCocoa::~ProfileSigninConfirmationDialogCocoa() {
66 } 61 }
67 62
68 // static 63 // static
69 void ProfileSigninConfirmationDialogCocoa::Show( 64 void ProfileSigninConfirmationDialogCocoa::Show(
70 Browser* browser, 65 Browser* browser,
71 content::WebContents* web_contents, 66 content::WebContents* web_contents,
72 Profile* profile, 67 Profile* profile,
73 const std::string& username, 68 const std::string& username,
74 ui::ProfileSigninConfirmationDelegate* delegate) { 69 std::unique_ptr<ui::ProfileSigninConfirmationDelegate> delegate) {
75 ui::CheckShouldPromptForNewProfile( 70 ui::CheckShouldPromptForNewProfile(
76 profile, base::Bind(ShowDialog, browser, web_contents, profile, username, 71 profile, base::Bind(ShowDialog, browser, web_contents, profile, username,
77 delegate)); 72 base::Passed(std::move(delegate))));
78 } 73 }
79 74
80 void ProfileSigninConfirmationDialogCocoa::Close() { 75 void ProfileSigninConfirmationDialogCocoa::Close() {
81 window_->CloseWebContentsModalDialog(); 76 window_->CloseWebContentsModalDialog();
82 } 77 }
83 78
84 void ProfileSigninConfirmationDialogCocoa::OnConstrainedWindowClosed( 79 void ProfileSigninConfirmationDialogCocoa::OnConstrainedWindowClosed(
85 ConstrainedWindowMac* window) { 80 ConstrainedWindowMac* window) {
86 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 81 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
87 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698