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/views/profiles/signin_view_controller_delegate_views .h" | 5 #include "chrome/browser/ui/views/profiles/signin_view_controller_delegate_views .h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 9 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
10 #include "chrome/browser/signin/signin_promo.h" | 10 #include "chrome/browser/signin/signin_promo.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/browser/ui/views/frame/browser_view.h" | 13 #include "chrome/browser/ui/views/frame/browser_view.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "components/constrained_window/constrained_window_views.h" | 15 #include "components/constrained_window/constrained_window_views.h" |
16 #include "components/signin/core/common/profile_management_switches.h" | 16 #include "components/signin/core/common/profile_management_switches.h" |
17 #include "components/web_modal/web_contents_modal_dialog_host.h" | 17 #include "components/web_modal/web_contents_modal_dialog_host.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 #include "ui/views/controls/webview/webview.h" | 20 #include "ui/views/controls/webview/webview.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
23 namespace { | |
24 | |
23 const int kPasswordCombinedFixedGaiaViewHeight = 440; | 25 const int kPasswordCombinedFixedGaiaViewHeight = 440; |
24 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 26 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
25 const int kFixedGaiaViewHeight = 612; | 27 const int kFixedGaiaViewHeight = 612; |
26 const int kModalDialogWidth = 448; | 28 const int kModalDialogWidth = 448; |
27 const int kSyncConfirmationDialogHeight = 487; | 29 const int kSyncConfirmationDialogHeight = 487; |
28 const int kSigninErrorDialogHeight = 164; | 30 const int kSigninErrorDialogHeight = 164; |
Peter Kasting
2016/10/27 22:14:50
These numbers are so horribly magic :( I hope we
msarda
2016/10/28 11:11:09
Acknowledged.
| |
29 | 31 |
32 int GetSyncConfirmationDialogPreferredHeight(Profile* profile) { | |
33 // If sync is disabled, then the sync confirmation dialog looks like an error | |
34 // dialog and thus it has the same preferred size. | |
35 return profile->IsSyncAllowed() ? kSyncConfirmationDialogHeight | |
36 : kSigninErrorDialogHeight; | |
37 } | |
38 | |
39 } // namespace | |
40 | |
30 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews( | 41 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews( |
31 SigninViewController* signin_view_controller, | 42 SigninViewController* signin_view_controller, |
32 std::unique_ptr<views::WebView> content_view, | 43 std::unique_ptr<views::WebView> content_view, |
33 Browser* browser, | 44 Browser* browser, |
34 bool wait_for_size) | 45 bool wait_for_size) |
35 : SigninViewControllerDelegate(signin_view_controller, | 46 : SigninViewControllerDelegate(signin_view_controller, |
36 content_view->GetWebContents()), | 47 content_view->GetWebContents()), |
37 content_view_(content_view.release()), | 48 content_view_(content_view.release()), |
38 modal_signin_widget_(nullptr), | 49 modal_signin_widget_(nullptr), |
39 wait_for_size_(wait_for_size), | 50 wait_for_size_(wait_for_size), |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 | 148 |
138 return std::unique_ptr<views::WebView>(web_view); | 149 return std::unique_ptr<views::WebView>(web_view); |
139 } | 150 } |
140 | 151 |
141 std::unique_ptr<views::WebView> | 152 std::unique_ptr<views::WebView> |
142 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView( | 153 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView( |
143 Browser* browser) { | 154 Browser* browser) { |
144 views::WebView* web_view = new views::WebView(browser->profile()); | 155 views::WebView* web_view = new views::WebView(browser->profile()); |
145 web_view->LoadInitialURL(GURL(chrome::kChromeUISyncConfirmationURL)); | 156 web_view->LoadInitialURL(GURL(chrome::kChromeUISyncConfirmationURL)); |
146 | 157 |
158 int dialog_preferred_height = | |
159 GetSyncConfirmationDialogPreferredHeight(browser->profile()); | |
147 int max_height = browser | 160 int max_height = browser |
148 ->window() | 161 ->window() |
149 ->GetWebContentsModalDialogHost() | 162 ->GetWebContentsModalDialogHost() |
150 ->GetMaximumDialogSize().height(); | 163 ->GetMaximumDialogSize().height(); |
151 web_view->SetPreferredSize( | 164 web_view->SetPreferredSize(gfx::Size( |
152 gfx::Size(kModalDialogWidth, | 165 kModalDialogWidth, std::min(dialog_preferred_height, max_height))); |
153 std::min(kSyncConfirmationDialogHeight, max_height))); | |
154 | 166 |
155 return std::unique_ptr<views::WebView>(web_view); | 167 return std::unique_ptr<views::WebView>(web_view); |
156 } | 168 } |
157 | 169 |
158 std::unique_ptr<views::WebView> | 170 std::unique_ptr<views::WebView> |
159 SigninViewControllerDelegateViews::CreateSigninErrorWebView(Browser* browser) { | 171 SigninViewControllerDelegateViews::CreateSigninErrorWebView(Browser* browser) { |
160 views::WebView* web_view = new views::WebView(browser->profile()); | 172 views::WebView* web_view = new views::WebView(browser->profile()); |
161 web_view->LoadInitialURL(GURL(chrome::kChromeUISigninErrorURL)); | 173 web_view->LoadInitialURL(GURL(chrome::kChromeUISigninErrorURL)); |
162 | 174 |
163 int max_height = browser->window() | 175 int max_height = browser->window() |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 | 207 |
196 SigninViewControllerDelegate* | 208 SigninViewControllerDelegate* |
197 SigninViewControllerDelegate::CreateSigninErrorDelegate( | 209 SigninViewControllerDelegate::CreateSigninErrorDelegate( |
198 SigninViewController* signin_view_controller, | 210 SigninViewController* signin_view_controller, |
199 Browser* browser) { | 211 Browser* browser) { |
200 return new SigninViewControllerDelegateViews( | 212 return new SigninViewControllerDelegateViews( |
201 signin_view_controller, | 213 signin_view_controller, |
202 SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser), | 214 SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser), |
203 browser, true); | 215 browser, true); |
204 } | 216 } |
OLD | NEW |