OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/signin_view_controller_delegate_mac.h
" | 5 #include "chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.h
" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // Height of the tab-modal dialog displaying the password-separated signin | 34 // Height of the tab-modal dialog displaying the password-separated signin |
35 // flow. It matches the dimensions of the server content the dialog displays. | 35 // flow. It matches the dimensions of the server content the dialog displays. |
36 const CGFloat kFixedGaiaViewHeight = 612; | 36 const CGFloat kFixedGaiaViewHeight = 612; |
37 | 37 |
38 // Initial height of the sync confirmation modal dialog. | 38 // Initial height of the sync confirmation modal dialog. |
39 const int kSyncConfirmationDialogHeight = 351; | 39 const int kSyncConfirmationDialogHeight = 351; |
40 | 40 |
41 // Initial height of the signin error modal dialog. | 41 // Initial height of the signin error modal dialog. |
42 const int kSigninErrorDialogHeight = 164; | 42 const int kSigninErrorDialogHeight = 164; |
43 | 43 |
| 44 CGFloat GetSyncConfirmationDialogPreferredHeight(Profile* profile) { |
| 45 // If sync is disabled, then the sync confirmation dialog looks like an error |
| 46 // dialog and thus it has the same preferred size. |
| 47 return profile->IsSyncAllowed() ? kSyncConfirmationDialogHeight |
| 48 : kSigninErrorDialogHeight; |
| 49 } |
| 50 |
44 } // namespace | 51 } // namespace |
45 | 52 |
46 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( | 53 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( |
47 SigninViewController* signin_view_controller, | 54 SigninViewController* signin_view_controller, |
48 std::unique_ptr<content::WebContents> web_contents, | 55 std::unique_ptr<content::WebContents> web_contents, |
49 content::WebContents* host_web_contents, | 56 content::WebContents* host_web_contents, |
50 NSRect frame, | 57 NSRect frame, |
51 bool wait_for_size) | 58 bool wait_for_size) |
52 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), | 59 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), |
53 web_contents_(std::move(web_contents)), | 60 web_contents_(std::move(web_contents)), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( | 112 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( |
106 Profile* profile) { | 113 Profile* profile) { |
107 std::unique_ptr<content::WebContents> web_contents( | 114 std::unique_ptr<content::WebContents> web_contents( |
108 content::WebContents::Create( | 115 content::WebContents::Create( |
109 content::WebContents::CreateParams(profile))); | 116 content::WebContents::CreateParams(profile))); |
110 web_contents->GetController().LoadURL( | 117 web_contents->GetController().LoadURL( |
111 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), | 118 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), |
112 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | 119 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
113 | 120 |
114 NSView* webview = web_contents->GetNativeView(); | 121 NSView* webview = web_contents->GetNativeView(); |
115 [webview setFrameSize:NSMakeSize(kModalDialogWidth, | 122 [webview setFrameSize:NSMakeSize( |
116 kSyncConfirmationDialogHeight)]; | 123 kModalDialogWidth, |
| 124 GetSyncConfirmationDialogPreferredHeight(profile))]; |
117 | 125 |
118 return web_contents; | 126 return web_contents; |
119 } | 127 } |
120 | 128 |
121 // static | 129 // static |
122 std::unique_ptr<content::WebContents> | 130 std::unique_ptr<content::WebContents> |
123 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( | 131 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( |
124 Profile* profile) { | 132 Profile* profile) { |
125 std::unique_ptr<content::WebContents> web_contents( | 133 std::unique_ptr<content::WebContents> web_contents( |
126 content::WebContents::Create( | 134 content::WebContents::Create( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 SigninViewControllerDelegate* | 204 SigninViewControllerDelegate* |
197 SigninViewControllerDelegate::CreateSyncConfirmationDelegate( | 205 SigninViewControllerDelegate::CreateSyncConfirmationDelegate( |
198 SigninViewController* signin_view_controller, | 206 SigninViewController* signin_view_controller, |
199 Browser* browser) { | 207 Browser* browser) { |
200 return new SigninViewControllerDelegateMac( | 208 return new SigninViewControllerDelegateMac( |
201 signin_view_controller, | 209 signin_view_controller, |
202 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( | 210 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( |
203 browser->profile()), | 211 browser->profile()), |
204 browser->tab_strip_model()->GetActiveWebContents(), | 212 browser->tab_strip_model()->GetActiveWebContents(), |
205 NSMakeRect(0, 0, kModalDialogWidth, | 213 NSMakeRect(0, 0, kModalDialogWidth, |
206 kSyncConfirmationDialogHeight), | 214 GetSyncConfirmationDialogPreferredHeight(browser->profile())), |
207 true); | 215 true); |
208 } | 216 } |
209 | 217 |
210 // static | 218 // static |
211 SigninViewControllerDelegate* | 219 SigninViewControllerDelegate* |
212 SigninViewControllerDelegate::CreateSigninErrorDelegate( | 220 SigninViewControllerDelegate::CreateSigninErrorDelegate( |
213 SigninViewController* signin_view_controller, | 221 SigninViewController* signin_view_controller, |
214 Browser* browser) { | 222 Browser* browser) { |
215 return new SigninViewControllerDelegateMac( | 223 return new SigninViewControllerDelegateMac( |
216 signin_view_controller, | 224 signin_view_controller, |
217 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( | 225 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( |
218 browser->profile()), | 226 browser->profile()), |
219 browser->tab_strip_model()->GetActiveWebContents(), | 227 browser->tab_strip_model()->GetActiveWebContents(), |
220 NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight), true); | 228 NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight), true); |
221 } | 229 } |
OLD | NEW |