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

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

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/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/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "components/constrained_window/constrained_window_views.h" 14 #include "components/constrained_window/constrained_window_views.h"
15 #include "components/signin/core/common/profile_management_switches.h" 15 #include "components/signin/core/common/profile_management_switches.h"
16 #include "content/public/browser/render_widget_host_view.h" 16 #include "content/public/browser/render_widget_host_view.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "ui/views/controls/webview/webview.h" 18 #include "ui/views/controls/webview/webview.h"
19 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
20 20
21 const int kPasswordCombinedFixedGaiaViewHeight = 440; 21 const int kPasswordCombinedFixedGaiaViewHeight = 440;
22 const int kPasswordCombinedFixedGaiaViewWidth = 360; 22 const int kPasswordCombinedFixedGaiaViewWidth = 360;
23 const int kFixedGaiaViewHeight = 512; 23 const int kFixedGaiaViewHeight = 612;
24 const int kFixedGaiaViewWidth = 448; 24 const int kModalDialogWidth = 448;
25 const int kSyncConfirmationDialogWidth = 448;
26 const int kSyncConfirmationDialogHeight = 351; 25 const int kSyncConfirmationDialogHeight = 351;
27 26
28 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews( 27 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews(
29 SigninViewController* signin_view_controller, 28 SigninViewController* signin_view_controller,
30 views::WebView* content_view, 29 views::WebView* content_view,
31 Browser* browser) 30 Browser* browser,
31 bool wait_for_size)
32 : SigninViewControllerDelegate(signin_view_controller, 32 : SigninViewControllerDelegate(signin_view_controller,
33 content_view->GetWebContents()), 33 content_view->GetWebContents()),
34 content_view_(content_view), 34 content_view_(content_view),
35 modal_signin_widget_(nullptr) { 35 modal_signin_widget_(nullptr),
36 modal_signin_widget_ = constrained_window::ShowWebModalDialogViews( 36 wait_for_size_(wait_for_size),
37 this, browser->tab_strip_model()->GetActiveWebContents()); 37 browser_(browser) {
38 content_view_->RequestFocus(); 38 if (!wait_for_size_)
39 DisplayModal();
39 } 40 }
40 41
41 SigninViewControllerDelegateViews::~SigninViewControllerDelegateViews() {} 42 SigninViewControllerDelegateViews::~SigninViewControllerDelegateViews() {}
42 43
43 // views::DialogDelegateView: 44 // views::DialogDelegateView:
44 views::View* SigninViewControllerDelegateViews::GetContentsView() { 45 views::View* SigninViewControllerDelegateViews::GetContentsView() {
45 return content_view_; 46 return content_view_;
46 } 47 }
47 48
48 views::Widget* SigninViewControllerDelegateViews::GetWidget() { 49 views::Widget* SigninViewControllerDelegateViews::GetWidget() {
(...skipping 18 matching lines...) Expand all
67 } 68 }
68 69
69 int SigninViewControllerDelegateViews::GetDialogButtons() const { 70 int SigninViewControllerDelegateViews::GetDialogButtons() const {
70 return ui::DIALOG_BUTTON_NONE; 71 return ui::DIALOG_BUTTON_NONE;
71 } 72 }
72 73
73 void SigninViewControllerDelegateViews::PerformClose() { 74 void SigninViewControllerDelegateViews::PerformClose() {
74 modal_signin_widget_->Close(); 75 modal_signin_widget_->Close();
75 } 76 }
76 77
78 void SigninViewControllerDelegateViews::ResizeNativeView(int height) {
79 content_view_->SetPreferredSize(gfx::Size(kModalDialogWidth, height));
80 content_view_->Layout();
81
82 if (wait_for_size_) {
83 // The modal wasn't displayed yet so just show it with the already resized
84 // view.
85 DisplayModal();
86 }
87 }
88
89 void SigninViewControllerDelegateViews::DisplayModal() {
90 modal_signin_widget_ = constrained_window::ShowWebModalDialogViews(
91 this, browser_->tab_strip_model()->GetActiveWebContents());
92 content_view_->RequestFocus();
93 }
94
77 // static 95 // static
78 views::WebView* SigninViewControllerDelegateViews::CreateGaiaWebView( 96 views::WebView* SigninViewControllerDelegateViews::CreateGaiaWebView(
79 content::WebContentsDelegate* delegate, 97 content::WebContentsDelegate* delegate,
80 profiles::BubbleViewMode mode, 98 profiles::BubbleViewMode mode,
81 Profile* profile, 99 Profile* profile,
82 signin_metrics::AccessPoint access_point) { 100 signin_metrics::AccessPoint access_point) {
83 GURL url = 101 GURL url =
84 signin::GetSigninURLFromBubbleViewMode(profile, mode, access_point); 102 signin::GetSigninURLFromBubbleViewMode(profile, mode, access_point);
85 103
86 // Adds Gaia signin webview. 104 // Adds Gaia signin webview.
87 const gfx::Size pref_size = 105 const gfx::Size pref_size =
88 switches::UsePasswordSeparatedSigninFlow() 106 switches::UsePasswordSeparatedSigninFlow()
89 ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight) 107 ? gfx::Size(kModalDialogWidth, kFixedGaiaViewHeight)
90 : gfx::Size(kPasswordCombinedFixedGaiaViewWidth, 108 : gfx::Size(kPasswordCombinedFixedGaiaViewWidth,
91 kPasswordCombinedFixedGaiaViewHeight); 109 kPasswordCombinedFixedGaiaViewHeight);
92 views::WebView* web_view = new views::WebView(profile); 110 views::WebView* web_view = new views::WebView(profile);
93 web_view->LoadInitialURL(url); 111 web_view->LoadInitialURL(url);
94 112
95 if (delegate) 113 if (delegate)
96 web_view->GetWebContents()->SetDelegate(delegate); 114 web_view->GetWebContents()->SetDelegate(delegate);
97 115
98 web_view->SetPreferredSize(pref_size); 116 web_view->SetPreferredSize(pref_size);
99 content::RenderWidgetHostView* rwhv = 117 content::RenderWidgetHostView* rwhv =
100 web_view->GetWebContents()->GetRenderWidgetHostView(); 118 web_view->GetWebContents()->GetRenderWidgetHostView();
101 if (rwhv) 119 if (rwhv)
102 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); 120 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor);
103 121
104 return web_view; 122 return web_view;
105 } 123 }
106 124
107 views::WebView* 125 views::WebView*
108 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView( 126 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(
109 Profile* profile) { 127 Profile* profile) {
110 views::WebView* web_view = new views::WebView(profile); 128 views::WebView* web_view = new views::WebView(profile);
111 web_view->LoadInitialURL(GURL(chrome::kChromeUISyncConfirmationURL)); 129 web_view->LoadInitialURL(GURL(chrome::kChromeUISyncConfirmationURL));
112 web_view->SetPreferredSize( 130 web_view->SetPreferredSize(
113 gfx::Size(kSyncConfirmationDialogWidth, kSyncConfirmationDialogHeight)); 131 gfx::Size(kModalDialogWidth, kSyncConfirmationDialogHeight));
114 132
115 return web_view; 133 return web_view;
116 } 134 }
117 135
118 SigninViewControllerDelegate* 136 SigninViewControllerDelegate*
119 SigninViewControllerDelegate::CreateModalSigninDelegate( 137 SigninViewControllerDelegate::CreateModalSigninDelegate(
120 SigninViewController* signin_view_controller, 138 SigninViewController* signin_view_controller,
121 profiles::BubbleViewMode mode, 139 profiles::BubbleViewMode mode,
122 Browser* browser, 140 Browser* browser,
123 signin_metrics::AccessPoint access_point) { 141 signin_metrics::AccessPoint access_point) {
124 return new SigninViewControllerDelegateViews( 142 return new SigninViewControllerDelegateViews(
125 signin_view_controller, 143 signin_view_controller,
126 SigninViewControllerDelegateViews::CreateGaiaWebView( 144 SigninViewControllerDelegateViews::CreateGaiaWebView(
127 nullptr, mode, browser->profile(), access_point), 145 nullptr, mode, browser->profile(), access_point),
128 browser); 146 browser, false);
129 } 147 }
130 148
131 SigninViewControllerDelegate* 149 SigninViewControllerDelegate*
132 SigninViewControllerDelegate::CreateSyncConfirmationDelegate( 150 SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
133 SigninViewController* signin_view_controller, 151 SigninViewController* signin_view_controller,
134 Browser* browser) { 152 Browser* browser) {
135 return new SigninViewControllerDelegateViews( 153 return new SigninViewControllerDelegateViews(
136 signin_view_controller, 154 signin_view_controller,
137 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView( 155 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(
138 browser->profile()), 156 browser->profile()),
139 browser); 157 browser, true);
140 } 158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698