| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( | 53 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( |
| 54 SigninViewController* signin_view_controller, | 54 SigninViewController* signin_view_controller, |
| 55 std::unique_ptr<content::WebContents> web_contents, | 55 std::unique_ptr<content::WebContents> web_contents, |
| 56 Browser* browser, | 56 Browser* browser, |
| 57 NSRect frame, | 57 NSRect frame, |
| 58 ui::ModalType dialog_modal_type, | 58 ui::ModalType dialog_modal_type, |
| 59 bool wait_for_size) | 59 bool wait_for_size) |
| 60 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), | 60 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), |
| 61 web_contents_(std::move(web_contents)), | 61 web_contents_(std::move(web_contents)), |
| 62 wait_for_size_(wait_for_size), | |
| 63 browser_(browser), | 62 browser_(browser), |
| 64 dialog_modal_type_(dialog_modal_type), | 63 dialog_modal_type_(dialog_modal_type), |
| 65 window_frame_(frame) { | 64 window_frame_(frame) { |
| 66 DCHECK(browser_); | 65 DCHECK(browser_); |
| 67 DCHECK(browser_->tab_strip_model()->GetActiveWebContents()) | 66 DCHECK(browser_->tab_strip_model()->GetActiveWebContents()) |
| 68 << "A tab must be active to present the sign-in modal dialog."; | 67 << "A tab must be active to present the sign-in modal dialog."; |
| 69 | 68 |
| 70 if (!wait_for_size_) | 69 if (!wait_for_size) |
| 71 DisplayModal(); | 70 DisplayModal(); |
| 72 } | 71 } |
| 73 | 72 |
| 74 SigninViewControllerDelegateMac::~SigninViewControllerDelegateMac() {} | 73 SigninViewControllerDelegateMac::~SigninViewControllerDelegateMac() {} |
| 75 | 74 |
| 76 void SigninViewControllerDelegateMac::OnConstrainedWindowClosed( | 75 void SigninViewControllerDelegateMac::OnConstrainedWindowClosed( |
| 77 ConstrainedWindowMac* window) { | 76 ConstrainedWindowMac* window) { |
| 78 CleanupAndDeleteThis(); | 77 CleanupAndDeleteThis(); |
| 79 } | 78 } |
| 80 | 79 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 window_.reset(nil); | 160 window_.reset(nil); |
| 162 CleanupAndDeleteThis(); | 161 CleanupAndDeleteThis(); |
| 163 } | 162 } |
| 164 break; | 163 break; |
| 165 default: | 164 default: |
| 166 NOTREACHED() << "Unsupported dialog modal type " << dialog_modal_type_; | 165 NOTREACHED() << "Unsupported dialog modal type " << dialog_modal_type_; |
| 167 } | 166 } |
| 168 } | 167 } |
| 169 | 168 |
| 170 void SigninViewControllerDelegateMac::ResizeNativeView(int height) { | 169 void SigninViewControllerDelegateMac::ResizeNativeView(int height) { |
| 171 if (wait_for_size_) { | 170 if (!window_) { |
| 172 [window_.get().contentView | |
| 173 setFrameSize:NSMakeSize(kModalDialogWidth, | |
| 174 height)]; | |
| 175 window_frame_.size = NSMakeSize(kModalDialogWidth, height); | 171 window_frame_.size = NSMakeSize(kModalDialogWidth, height); |
| 176 DisplayModal(); | 172 DisplayModal(); |
| 177 } | 173 } |
| 178 } | 174 } |
| 179 | 175 |
| 180 void SigninViewControllerDelegateMac::DisplayModal() { | 176 void SigninViewControllerDelegateMac::DisplayModal() { |
| 177 DCHECK(!window_); |
| 178 |
| 181 content::WebContents* host_web_contents = | 179 content::WebContents* host_web_contents = |
| 182 browser_->tab_strip_model()->GetActiveWebContents(); | 180 browser_->tab_strip_model()->GetActiveWebContents(); |
| 183 | 181 |
| 184 // Avoid displaying the sign-in modal view if there are no active web | 182 // Avoid displaying the sign-in modal view if there are no active web |
| 185 // contents. This happens if the user closes the browser window before this | 183 // contents. This happens if the user closes the browser window before this |
| 186 // dialog has a chance to be displayed. | 184 // dialog has a chance to be displayed. |
| 187 if (!host_web_contents) | 185 if (!host_web_contents) |
| 188 return; | 186 return; |
| 189 | 187 |
| 190 window_.reset( | 188 window_.reset( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 SigninViewControllerDelegate::CreateSigninErrorDelegate( | 258 SigninViewControllerDelegate::CreateSigninErrorDelegate( |
| 261 SigninViewController* signin_view_controller, | 259 SigninViewController* signin_view_controller, |
| 262 Browser* browser) { | 260 Browser* browser) { |
| 263 return new SigninViewControllerDelegateMac( | 261 return new SigninViewControllerDelegateMac( |
| 264 signin_view_controller, | 262 signin_view_controller, |
| 265 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( | 263 SigninViewControllerDelegateMac::CreateSigninErrorWebContents( |
| 266 browser->profile()), | 264 browser->profile()), |
| 267 browser, NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight), | 265 browser, NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight), |
| 268 ui::MODAL_TYPE_WINDOW, true /* wait_for_size */); | 266 ui::MODAL_TYPE_WINDOW, true /* wait_for_size */); |
| 269 } | 267 } |
| OLD | NEW |