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 17 matching lines...) Expand all Loading... |
28 const CGFloat kPasswordCombinedFixedGaiaViewHeight = 440; | 28 const CGFloat kPasswordCombinedFixedGaiaViewHeight = 440; |
29 const CGFloat kPasswordCombinedFixedGaiaViewWidth = 360; | 29 const CGFloat kPasswordCombinedFixedGaiaViewWidth = 360; |
30 | 30 |
31 // Width of the different dialogs that make up the signin flow. | 31 // Width of the different dialogs that make up the signin flow. |
32 const int kModalDialogWidth = 448; | 32 const int kModalDialogWidth = 448; |
33 | 33 |
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 t | 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. |
| 42 const int kSigninErrorDialogHeight = 164; |
| 43 |
41 } // namespace | 44 } // namespace |
42 | 45 |
43 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( | 46 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( |
44 SigninViewController* signin_view_controller, | 47 SigninViewController* signin_view_controller, |
45 std::unique_ptr<content::WebContents> web_contents, | 48 std::unique_ptr<content::WebContents> web_contents, |
46 content::WebContents* host_web_contents, | 49 content::WebContents* host_web_contents, |
47 NSRect frame, | 50 NSRect frame, |
48 bool wait_for_size) | 51 bool wait_for_size) |
49 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), | 52 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), |
50 web_contents_(std::move(web_contents)), | 53 web_contents_(std::move(web_contents)), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), | 111 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), |
109 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | 112 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
110 | 113 |
111 NSView* webview = web_contents->GetNativeView(); | 114 NSView* webview = web_contents->GetNativeView(); |
112 [webview setFrameSize:NSMakeSize(kModalDialogWidth, | 115 [webview setFrameSize:NSMakeSize(kModalDialogWidth, |
113 kSyncConfirmationDialogHeight)]; | 116 kSyncConfirmationDialogHeight)]; |
114 | 117 |
115 return web_contents; | 118 return web_contents; |
116 } | 119 } |
117 | 120 |
| 121 // static |
| 122 std::unique_ptr<content::WebContents> |
| 123 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( |
| 124 Profile* profile) { |
| 125 std::unique_ptr<content::WebContents> web_contents( |
| 126 content::WebContents::Create( |
| 127 content::WebContents::CreateParams(profile))); |
| 128 web_contents->GetController().LoadURL( |
| 129 GURL(chrome::kChromeUISigninErrorURL), content::Referrer(), |
| 130 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
| 131 |
| 132 NSView* webview = web_contents->GetNativeView(); |
| 133 [webview |
| 134 setFrameSize:NSMakeSize(kModalDialogWidth, kSigninErrorDialogHeight)]; |
| 135 |
| 136 return web_contents; |
| 137 } |
| 138 |
118 void SigninViewControllerDelegateMac::PerformClose() { | 139 void SigninViewControllerDelegateMac::PerformClose() { |
119 if (constrained_window_.get()) | 140 if (constrained_window_.get()) |
120 constrained_window_->CloseWebContentsModalDialog(); | 141 constrained_window_->CloseWebContentsModalDialog(); |
121 } | 142 } |
122 | 143 |
123 void SigninViewControllerDelegateMac::ResizeNativeView(int height) { | 144 void SigninViewControllerDelegateMac::ResizeNativeView(int height) { |
124 if (wait_for_size_) { | 145 if (wait_for_size_) { |
125 [window_.get().contentView | 146 [window_.get().contentView |
126 setFrameSize:NSMakeSize(kModalDialogWidth, | 147 setFrameSize:NSMakeSize(kModalDialogWidth, |
127 height)]; | 148 height)]; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 Browser* browser) { | 199 Browser* browser) { |
179 return new SigninViewControllerDelegateMac( | 200 return new SigninViewControllerDelegateMac( |
180 signin_view_controller, | 201 signin_view_controller, |
181 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( | 202 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( |
182 browser->profile()), | 203 browser->profile()), |
183 browser->tab_strip_model()->GetActiveWebContents(), | 204 browser->tab_strip_model()->GetActiveWebContents(), |
184 NSMakeRect(0, 0, kModalDialogWidth, | 205 NSMakeRect(0, 0, kModalDialogWidth, |
185 kSyncConfirmationDialogHeight), | 206 kSyncConfirmationDialogHeight), |
186 true); | 207 true); |
187 } | 208 } |
| 209 |
| 210 // static |
| 211 SigninViewControllerDelegate* |
| 212 SigninViewControllerDelegate::CreateSigninErrorDelegate( |
| 213 SigninViewController* signin_view_controller, |
| 214 Browser* browser) { |
| 215 return new SigninViewControllerDelegateMac( |
| 216 signin_view_controller, |
| 217 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( |
| 218 browser->profile()), |
| 219 browser->tab_strip_model()->GetActiveWebContents(), |
| 220 NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight), true); |
| 221 } |
OLD | NEW |