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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm

Issue 1814513002: Fix sizing issues in the tab modal signin flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 4 years, 8 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 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/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #include "chrome/browser/signin/signin_promo.h" 11 #include "chrome/browser/signin/signin_promo.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_s heet.h" 13 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_s heet.h"
14 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_w indow.h" 14 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_w indow.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "components/signin/core/common/profile_management_switches.h" 17 #include "components/signin/core/common/profile_management_switches.h"
18 #include "content/public/browser/render_widget_host_view.h" 18 #include "content/public/browser/render_widget_host_view.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 20
21 namespace { 21 namespace {
22 22
23 // Dimensions of the web contents containing the old-style signin flow with the 23 // Dimensions of the web contents containing the old-style signin flow with the
24 // username and password challenge on the same form. 24 // username and password challenge on the same form.
25 const CGFloat kPasswordCombinedFixedGaiaViewHeight = 440; 25 const CGFloat kPasswordCombinedFixedGaiaViewHeight = 440;
26 const CGFloat kPasswordCombinedFixedGaiaViewWidth = 360; 26 const CGFloat kPasswordCombinedFixedGaiaViewWidth = 360;
27 27
28 // Dimensions of the tab-modal dialog displaying the password-separated signin 28 // Width of the different dialogs that make up the signin flow.
29 // flow. These match the dimensions of the server content they display. 29 const int kModalDialogWidth = 448;
30 const CGFloat kFixedGaiaViewHeight = 512;
31 const CGFloat kFixedGaiaViewWidth = 448;
32 30
33 // Dimensions of the sync confirmation tab-modal dialog. These are taken from 31 // Height of the tab-modal dialog displaying the password-separated signin
34 // the design spec for this feature. 32 // flow. It matches the dimensions of the server content the dialog displays.
35 const int kSyncConfirmationDialogWidth = 448; 33 const CGFloat kFixedGaiaViewHeight = 612;
34
35 // Initial height of the sync confirmation t
36 const int kSyncConfirmationDialogHeight = 351; 36 const int kSyncConfirmationDialogHeight = 351;
37 37
38 } // namespace 38 } // namespace
39 39
40 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac( 40 SigninViewControllerDelegateMac::SigninViewControllerDelegateMac(
41 SigninViewController* signin_view_controller, 41 SigninViewController* signin_view_controller,
42 scoped_ptr<content::WebContents> web_contents, 42 scoped_ptr<content::WebContents> web_contents,
43 content::WebContents* host_web_contents, 43 content::WebContents* host_web_contents,
44 NSRect frame) 44 NSRect frame,
45 bool wait_for_size)
45 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()), 46 : SigninViewControllerDelegate(signin_view_controller, web_contents.get()),
46 web_contents_(std::move(web_contents)), 47 web_contents_(std::move(web_contents)),
47 window_( 48 wait_for_size_(wait_for_size),
48 [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]) { 49 host_web_contents_(host_web_contents),
49 window_.get().contentView = web_contents_->GetNativeView(); 50 window_frame_(frame) {
50 51 if (!wait_for_size_)
51 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 52 DisplayModal();
52 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window_]);
53 constrained_window_ =
54 CreateAndShowWebModalDialogMac(this, host_web_contents, sheet);
55 } 53 }
56 54
57 SigninViewControllerDelegateMac::~SigninViewControllerDelegateMac() {} 55 SigninViewControllerDelegateMac::~SigninViewControllerDelegateMac() {}
58 56
59 void SigninViewControllerDelegateMac::OnConstrainedWindowClosed( 57 void SigninViewControllerDelegateMac::OnConstrainedWindowClosed(
60 ConstrainedWindowMac* window) { 58 ConstrainedWindowMac* window) {
61 ResetSigninViewControllerDelegate(); 59 ResetSigninViewControllerDelegate();
62 delete this; 60 delete this;
63 } 61 }
64 62
(...skipping 12 matching lines...) Expand all
77 75
78 if (delegate) 76 if (delegate)
79 web_contents->SetDelegate(delegate); 77 web_contents->SetDelegate(delegate);
80 78
81 web_contents->GetController().LoadURL(url, content::Referrer(), 79 web_contents->GetController().LoadURL(url, content::Referrer(),
82 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 80 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
83 std::string()); 81 std::string());
84 NSView* webview = web_contents->GetNativeView(); 82 NSView* webview = web_contents->GetNativeView();
85 [webview 83 [webview
86 setFrameSize:switches::UsePasswordSeparatedSigninFlow() 84 setFrameSize:switches::UsePasswordSeparatedSigninFlow()
87 ? NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight) 85 ? NSMakeSize(kModalDialogWidth, kFixedGaiaViewHeight)
88 : NSMakeSize(kPasswordCombinedFixedGaiaViewWidth, 86 : NSMakeSize(kPasswordCombinedFixedGaiaViewWidth,
89 kPasswordCombinedFixedGaiaViewHeight)]; 87 kPasswordCombinedFixedGaiaViewHeight)];
90 88
91 content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); 89 content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
92 if (rwhv) 90 if (rwhv)
93 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); 91 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor);
94 92
95 return web_contents; 93 return web_contents;
96 } 94 }
97 95
98 // static 96 // static
99 scoped_ptr<content::WebContents> 97 scoped_ptr<content::WebContents>
100 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( 98 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents(
101 Profile* profile) { 99 Profile* profile) {
102 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create( 100 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create(
103 content::WebContents::CreateParams(profile))); 101 content::WebContents::CreateParams(profile)));
104 web_contents->GetController().LoadURL( 102 web_contents->GetController().LoadURL(
105 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(), 103 GURL(chrome::kChromeUISyncConfirmationURL), content::Referrer(),
106 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); 104 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
107 105
108 NSView* webview = web_contents->GetNativeView(); 106 NSView* webview = web_contents->GetNativeView();
109 [webview setFrameSize:NSMakeSize(kSyncConfirmationDialogWidth, 107 [webview setFrameSize:NSMakeSize(kModalDialogWidth,
110 kSyncConfirmationDialogHeight)]; 108 kSyncConfirmationDialogHeight)];
111 109
112 return web_contents; 110 return web_contents;
113 } 111 }
114 112
115 void SigninViewControllerDelegateMac::PerformClose() { 113 void SigninViewControllerDelegateMac::PerformClose() {
116 constrained_window_->CloseWebContentsModalDialog(); 114 if (constrained_window_.get())
115 constrained_window_->CloseWebContentsModalDialog();
116 }
117
118 void SigninViewControllerDelegateMac::ResizeNativeView(int height) {
119 if (wait_for_size_) {
120 [window_.get().contentView
121 setFrameSize:NSMakeSize(kModalDialogWidth,
122 height)];
123 window_frame_.size = NSMakeSize(kModalDialogWidth, height);
124 DisplayModal();
125 }
126 }
127
128 void SigninViewControllerDelegateMac::DisplayModal() {
129 window_.reset(
130 [[ConstrainedWindowCustomWindow alloc]
131 initWithContentRect:window_frame_]);
132
133 window_.get().contentView = web_contents_->GetNativeView();
134 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
135 [[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window_]);
136 constrained_window_ =
137 CreateAndShowWebModalDialogMac(this, host_web_contents_, sheet);
117 } 138 }
118 139
119 // static 140 // static
120 SigninViewControllerDelegate* 141 SigninViewControllerDelegate*
121 SigninViewControllerDelegate::CreateModalSigninDelegate( 142 SigninViewControllerDelegate::CreateModalSigninDelegate(
122 SigninViewController* signin_view_controller, 143 SigninViewController* signin_view_controller,
123 profiles::BubbleViewMode mode, 144 profiles::BubbleViewMode mode,
124 Browser* browser, 145 Browser* browser,
125 signin_metrics::AccessPoint access_point) { 146 signin_metrics::AccessPoint access_point) {
126 return new SigninViewControllerDelegateMac( 147 return new SigninViewControllerDelegateMac(
127 signin_view_controller, 148 signin_view_controller,
128 SigninViewControllerDelegateMac::CreateGaiaWebContents( 149 SigninViewControllerDelegateMac::CreateGaiaWebContents(
129 nullptr, mode, browser->profile(), access_point), 150 nullptr, mode, browser->profile(), access_point),
130 browser->tab_strip_model()->GetActiveWebContents(), 151 browser->tab_strip_model()->GetActiveWebContents(),
131 NSMakeRect(0, 0, kFixedGaiaViewWidth, kFixedGaiaViewHeight)); 152 NSMakeRect(0, 0, kModalDialogWidth, kFixedGaiaViewHeight),
153 false);
132 } 154 }
133 155
134 // static 156 // static
135 SigninViewControllerDelegate* 157 SigninViewControllerDelegate*
136 SigninViewControllerDelegate::CreateSyncConfirmationDelegate( 158 SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
137 SigninViewController* signin_view_controller, 159 SigninViewController* signin_view_controller,
138 Browser* browser) { 160 Browser* browser) {
139 return new SigninViewControllerDelegateMac( 161 return new SigninViewControllerDelegateMac(
140 signin_view_controller, 162 signin_view_controller,
141 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents( 163 SigninViewControllerDelegateMac::CreateSyncConfirmationWebContents(
142 browser->profile()), 164 browser->profile()),
143 browser->tab_strip_model()->GetActiveWebContents(), 165 browser->tab_strip_model()->GetActiveWebContents(),
144 NSMakeRect(0, 0, kSyncConfirmationDialogWidth, 166 NSMakeRect(0, 0, kModalDialogWidth,
145 kSyncConfirmationDialogHeight)); 167 kSyncConfirmationDialogHeight),
168 true);
146 } 169 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.h ('k') | chrome/browser/ui/signin_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698