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

Side by Side Diff: chrome/browser/ui/views/profiles/signin_view_controller_delegate_views.cc

Issue 2348423002: [Signin Error Dialog] (3/3) Added the triggering code (Closed)
Patch Set: Add comment. Created 4 years, 2 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/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 const int kPasswordCombinedFixedGaiaViewHeight = 440; 23 const int kPasswordCombinedFixedGaiaViewHeight = 440;
24 const int kPasswordCombinedFixedGaiaViewWidth = 360; 24 const int kPasswordCombinedFixedGaiaViewWidth = 360;
25 const int kFixedGaiaViewHeight = 612; 25 const int kFixedGaiaViewHeight = 612;
26 const int kModalDialogWidth = 448; 26 const int kModalDialogWidth = 448;
27 const int kSyncConfirmationDialogHeight = 487; 27 const int kSyncConfirmationDialogHeight = 487;
28 const int kSigninErrorDialogHeight = 164;
28 29
29 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews( 30 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews(
30 SigninViewController* signin_view_controller, 31 SigninViewController* signin_view_controller,
31 views::WebView* content_view, 32 views::WebView* content_view,
32 Browser* browser, 33 Browser* browser,
33 bool wait_for_size) 34 bool wait_for_size)
34 : SigninViewControllerDelegate(signin_view_controller, 35 : SigninViewControllerDelegate(signin_view_controller,
35 content_view->GetWebContents()), 36 content_view->GetWebContents()),
36 content_view_(content_view), 37 content_view_(content_view),
37 modal_signin_widget_(nullptr), 38 modal_signin_widget_(nullptr),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ->window() 147 ->window()
147 ->GetWebContentsModalDialogHost() 148 ->GetWebContentsModalDialogHost()
148 ->GetMaximumDialogSize().height(); 149 ->GetMaximumDialogSize().height();
149 web_view->SetPreferredSize( 150 web_view->SetPreferredSize(
150 gfx::Size(kModalDialogWidth, 151 gfx::Size(kModalDialogWidth,
151 std::min(kSyncConfirmationDialogHeight, max_height))); 152 std::min(kSyncConfirmationDialogHeight, max_height)));
152 153
153 return web_view; 154 return web_view;
154 } 155 }
155 156
157 views::WebView* SigninViewControllerDelegateViews::CreateSigninErrorWebView(
sky 2016/09/21 16:14:39 It's hard to reason about lifetime with raw pointe
anthonyvd 2016/09/22 16:52:01 Agreed, done. Could you clarify something about vi
sky 2016/09/22 20:29:35 You are correct for the common case. The exception
158 Browser* browser) {
159 views::WebView* web_view = new views::WebView(browser->profile());
160 web_view->LoadInitialURL(GURL(chrome::kChromeUISigninErrorURL));
161
162 int max_height = browser->window()
163 ->GetWebContentsModalDialogHost()
164 ->GetMaximumDialogSize()
165 .height();
166 web_view->SetPreferredSize(gfx::Size(
167 kModalDialogWidth, std::min(kSigninErrorDialogHeight, max_height)));
168
169 return web_view;
170 }
171
156 SigninViewControllerDelegate* 172 SigninViewControllerDelegate*
157 SigninViewControllerDelegate::CreateModalSigninDelegate( 173 SigninViewControllerDelegate::CreateModalSigninDelegate(
158 SigninViewController* signin_view_controller, 174 SigninViewController* signin_view_controller,
159 profiles::BubbleViewMode mode, 175 profiles::BubbleViewMode mode,
160 Browser* browser, 176 Browser* browser,
161 signin_metrics::AccessPoint access_point) { 177 signin_metrics::AccessPoint access_point) {
162 return new SigninViewControllerDelegateViews( 178 return new SigninViewControllerDelegateViews(
163 signin_view_controller, 179 signin_view_controller,
164 SigninViewControllerDelegateViews::CreateGaiaWebView( 180 SigninViewControllerDelegateViews::CreateGaiaWebView(
165 nullptr, mode, browser, access_point), 181 nullptr, mode, browser, access_point),
166 browser, false); 182 browser, false);
167 } 183 }
168 184
169 SigninViewControllerDelegate* 185 SigninViewControllerDelegate*
170 SigninViewControllerDelegate::CreateSyncConfirmationDelegate( 186 SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
171 SigninViewController* signin_view_controller, 187 SigninViewController* signin_view_controller,
172 Browser* browser) { 188 Browser* browser) {
173 return new SigninViewControllerDelegateViews( 189 return new SigninViewControllerDelegateViews(
174 signin_view_controller, 190 signin_view_controller,
175 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser), 191 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser),
176 browser, true); 192 browser, true);
177 } 193 }
194
195 SigninViewControllerDelegate*
196 SigninViewControllerDelegate::CreateSigninErrorDelegate(
197 SigninViewController* signin_view_controller,
198 Browser* browser) {
199 return new SigninViewControllerDelegateViews(
200 signin_view_controller,
201 SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser),
202 browser, true);
203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698