| 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 24 matching lines...) Expand all Loading... |
| 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 t |
| 39 const int kSyncConfirmationDialogHeight = 351; | 39 const int kSyncConfirmationDialogHeight = 351; |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( | 43 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( |
| 44 SigninViewController* signin_view_controller, | 44 SigninViewController* signin_view_controller, |
| 45 scoped_ptr<content::WebContents> web_contents, | 45 std::unique_ptr<content::WebContents> web_contents, |
| 46 content::WebContents* host_web_contents, | 46 content::WebContents* host_web_contents, |
| 47 NSRect frame, | 47 NSRect frame, |
| 48 bool wait_for_size) | 48 bool wait_for_size) |
| 49 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), | 49 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), |
| 50 web_contents_(std::move(web_contents)), | 50 web_contents_(std::move(web_contents)), |
| 51 wait_for_size_(wait_for_size), | 51 wait_for_size_(wait_for_size), |
| 52 host_web_contents_(host_web_contents), | 52 host_web_contents_(host_web_contents), |
| 53 window_frame_(frame) { | 53 window_frame_(frame) { |
| 54 if (!wait_for_size_) | 54 if (!wait_for_size_) |
| 55 DisplayModal(); | 55 DisplayModal(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 SigninViewControllerDelegateMac::~SigninViewControllerDelegateMac() {} | 58 SigninViewControllerDelegateMac::~SigninViewControllerDelegateMac() {} |
| 59 | 59 |
| 60 void SigninViewControllerDelegateMac::OnConstrainedWindowClosed( | 60 void SigninViewControllerDelegateMac::OnConstrainedWindowClosed( |
| 61 ConstrainedWindowMac* window) { | 61 ConstrainedWindowMac* window) { |
| 62 ResetSigninViewControllerDelegate(); | 62 ResetSigninViewControllerDelegate(); |
| 63 delete this; | 63 delete this; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // static | 66 // static |
| 67 scoped_ptr<content::WebContents> | 67 std::unique_ptr<content::WebContents> |
| 68 SigninViewControllerDelegateMac::CreateGaiaWebContents( | 68 SigninViewControllerDelegateMac::CreateGaiaWebContents( |
| 69 content::WebContentsDelegate* delegate, | 69 content::WebContentsDelegate* delegate, |
| 70 profiles::BubbleViewMode mode, | 70 profiles::BubbleViewMode mode, |
| 71 Profile* profile, | 71 Profile* profile, |
| 72 signin_metrics::AccessPoint access_point) { | 72 signin_metrics::AccessPoint access_point) { |
| 73 GURL url = | 73 GURL url = |
| 74 signin::GetSigninURLFromBubbleViewMode(profile, mode, access_point); | 74 signin::GetSigninURLFromBubbleViewMode(profile, mode, access_point); |
| 75 | 75 |
| 76 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create( | 76 std::unique_ptr<content::WebContents> web_contents( |
| 77 content::WebContents::CreateParams(profile))); | 77 content::WebContents::Create( |
| 78 content::WebContents::CreateParams(profile))); |
| 78 | 79 |
| 79 if (delegate) | 80 if (delegate) |
| 80 web_contents->SetDelegate(delegate); | 81 web_contents->SetDelegate(delegate); |
| 81 | 82 |
| 82 web_contents->GetController().LoadURL(url, content::Referrer(), | 83 web_contents->GetController().LoadURL(url, content::Referrer(), |
| 83 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 84 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 84 std::string()); | 85 std::string()); |
| 85 NSView* webview = web_contents->GetNativeView(); | 86 NSView* webview = web_contents->GetNativeView(); |
| 86 [webview | 87 [webview |
| 87 setFrameSize:switches::UsePasswordSeparatedSigninFlow() | 88 setFrameSize:switches::UsePasswordSeparatedSigninFlow() |
| 88 ? NSMakeSize(kModalDialogWidth, kFixedGaiaViewHeight) | 89 ? NSMakeSize(kModalDialogWidth, kFixedGaiaViewHeight) |
| 89 : NSMakeSize(kPasswordCombinedFixedGaiaViewWidth, | 90 : NSMakeSize(kPasswordCombinedFixedGaiaViewWidth, |
| 90 kPasswordCombinedFixedGaiaViewHeight)]; | 91 kPasswordCombinedFixedGaiaViewHeight)]; |
| 91 | 92 |
| 92 content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); | 93 content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); |
| 93 if (rwhv) | 94 if (rwhv) |
| 94 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); | 95 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); |
| 95 | 96 |
| 96 return web_contents; | 97 return web_contents; |
| 97 } | 98 } |
| 98 | 99 |
| 99 // static | 100 // static |
| 100 scoped_ptr<content::WebContents> | 101 std::unique_ptr<content::WebContents> |
| 101 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( | 102 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( |
| 102 Profile* profile) { | 103 Profile* profile) { |
| 103 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create( | 104 std::unique_ptr<content::WebContents> web_contents( |
| 104 content::WebContents::CreateParams(profile))); | 105 content::WebContents::Create( |
| 106 content::WebContents::CreateParams(profile))); |
| 105 web_contents->GetController().LoadURL( | 107 web_contents->GetController().LoadURL( |
| 106 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), | 108 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), |
| 107 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | 109 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
| 108 | 110 |
| 109 NSView* webview = web_contents->GetNativeView(); | 111 NSView* webview = web_contents->GetNativeView(); |
| 110 [webview setFrameSize:NSMakeSize(kModalDialogWidth, | 112 [webview setFrameSize:NSMakeSize(kModalDialogWidth, |
| 111 kSyncConfirmationDialogHeight)]; | 113 kSyncConfirmationDialogHeight)]; |
| 112 | 114 |
| 113 return web_contents; | 115 return web_contents; |
| 114 } | 116 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 Browser* browser) { | 178 Browser* browser) { |
| 177 return new SigninViewControllerDelegateMac( | 179 return new SigninViewControllerDelegateMac( |
| 178 signin_view_controller, | 180 signin_view_controller, |
| 179 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( | 181 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( |
| 180 browser->profile()), | 182 browser->profile()), |
| 181 browser->tab_strip_model()->GetActiveWebContents(), | 183 browser->tab_strip_model()->GetActiveWebContents(), |
| 182 NSMakeRect(0, 0, kModalDialogWidth, | 184 NSMakeRect(0, 0, kModalDialogWidth, |
| 183 kSyncConfirmationDialogHeight), | 185 kSyncConfirmationDialogHeight), |
| 184 true); | 186 true); |
| 185 } | 187 } |
| OLD | NEW |