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

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

Issue 2619963003: Change the views sign-in dialog to be tab modal. (Closed)
Patch Set: Created 3 years, 11 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"
(...skipping 24 matching lines...) Expand all
35 return profile->IsSyncAllowed() ? kSyncConfirmationDialogHeight 35 return profile->IsSyncAllowed() ? kSyncConfirmationDialogHeight
36 : kSigninErrorDialogHeight; 36 : kSigninErrorDialogHeight;
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews( 41 SigninViewControllerDelegateViews::SigninViewControllerDelegateViews(
42 SigninViewController* signin_view_controller, 42 SigninViewController* signin_view_controller,
43 std::unique_ptr<views::WebView> content_view, 43 std::unique_ptr<views::WebView> content_view,
44 Browser* browser, 44 Browser* browser,
45 DialogModalType dialog_modal_type_,
45 bool wait_for_size) 46 bool wait_for_size)
46 : SigninViewControllerDelegate(signin_view_controller, 47 : SigninViewControllerDelegate(signin_view_controller,
47 content_view->GetWebContents()), 48 content_view->GetWebContents()),
48 content_view_(content_view.release()), 49 content_view_(content_view.release()),
49 modal_signin_widget_(nullptr), 50 modal_signin_widget_(nullptr),
51 dialog_modal_type_(dialog_modal_type_),
50 wait_for_size_(wait_for_size), 52 wait_for_size_(wait_for_size),
51 browser_(browser) { 53 browser_(browser) {
52 DCHECK(browser_); 54 DCHECK(browser_);
53 DCHECK(browser_->tab_strip_model()->GetActiveWebContents()) 55 DCHECK(browser_->tab_strip_model()->GetActiveWebContents())
54 << "A tab must be active to present the sign-in modal dialog."; 56 << "A tab must be active to present the sign-in modal dialog.";
55 57
56 if (!wait_for_size_) 58 if (!wait_for_size_)
57 DisplayModal(); 59 DisplayModal();
58 } 60 }
59 61
(...skipping 11 matching lines...) Expand all
71 const views::Widget* SigninViewControllerDelegateViews::GetWidget() const { 73 const views::Widget* SigninViewControllerDelegateViews::GetWidget() const {
72 return content_view_->GetWidget(); 74 return content_view_->GetWidget();
73 } 75 }
74 76
75 void SigninViewControllerDelegateViews::DeleteDelegate() { 77 void SigninViewControllerDelegateViews::DeleteDelegate() {
76 ResetSigninViewControllerDelegate(); 78 ResetSigninViewControllerDelegate();
77 delete this; 79 delete this;
78 } 80 }
79 81
80 ui::ModalType SigninViewControllerDelegateViews::GetModalType() const { 82 ui::ModalType SigninViewControllerDelegateViews::GetModalType() const {
81 return ui::MODAL_TYPE_WINDOW; 83 switch (dialog_modal_type_) {
84 case TAB_MODAL:
85 return ui::MODAL_TYPE_CHILD;
86 case WINDOW_MODAL:
87 return ui::MODAL_TYPE_WINDOW;
Peter Kasting 2017/01/11 01:24:45 Why not just use these values directly everywhere,
msarda 2017/01/11 09:54:25 I hesitated to do that because we only support 2 v
88 }
89 NOTREACHED();
90 return ui::MODAL_TYPE_CHILD;
82 } 91 }
83 92
84 bool SigninViewControllerDelegateViews::ShouldShowCloseButton() const { 93 bool SigninViewControllerDelegateViews::ShouldShowCloseButton() const {
85 return false; 94 return false;
86 } 95 }
87 96
88 int SigninViewControllerDelegateViews::GetDialogButtons() const { 97 int SigninViewControllerDelegateViews::GetDialogButtons() const {
89 return ui::DIALOG_BUTTON_NONE; 98 return ui::DIALOG_BUTTON_NONE;
90 } 99 }
91 100
(...skipping 22 matching lines...) Expand all
114 content::WebContents* host_web_contents = 123 content::WebContents* host_web_contents =
115 browser_->tab_strip_model()->GetActiveWebContents(); 124 browser_->tab_strip_model()->GetActiveWebContents();
116 125
117 // Avoid displaying the sign-in modal view if there are no active web 126 // Avoid displaying the sign-in modal view if there are no active web
118 // contents. This happens if the user closes the browser window before this 127 // contents. This happens if the user closes the browser window before this
119 // dialog has a chance to be displayed. 128 // dialog has a chance to be displayed.
120 if (!host_web_contents) 129 if (!host_web_contents)
121 return; 130 return;
122 131
123 gfx::NativeWindow window = host_web_contents->GetTopLevelNativeWindow(); 132 gfx::NativeWindow window = host_web_contents->GetTopLevelNativeWindow();
124 modal_signin_widget_ = 133 switch (dialog_modal_type_) {
125 constrained_window::CreateBrowserModalDialogViews(this, window); 134 case WINDOW_MODAL:
126 modal_signin_widget_->Show(); 135 modal_signin_widget_ =
136 constrained_window::CreateBrowserModalDialogViews(this, window);
137 modal_signin_widget_->Show();
138 break;
139 case TAB_MODAL:
140 modal_signin_widget_ = constrained_window::ShowWebModalDialogViews(
141 this, browser_->tab_strip_model()->GetActiveWebContents());
142 break;
143 }
144 content_view_->RequestFocus();
127 } 145 }
128 146
129 // static 147 // static
130 std::unique_ptr<views::WebView> 148 std::unique_ptr<views::WebView>
131 SigninViewControllerDelegateViews::CreateGaiaWebView( 149 SigninViewControllerDelegateViews::CreateGaiaWebView(
132 content::WebContentsDelegate* delegate, 150 content::WebContentsDelegate* delegate,
133 profiles::BubbleViewMode mode, 151 profiles::BubbleViewMode mode,
134 Browser* browser, 152 Browser* browser,
135 signin_metrics::AccessPoint access_point) { 153 signin_metrics::AccessPoint access_point) {
136 GURL url = 154 GURL url =
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 SigninViewControllerDelegate* 217 SigninViewControllerDelegate*
200 SigninViewControllerDelegate::CreateModalSigninDelegate( 218 SigninViewControllerDelegate::CreateModalSigninDelegate(
201 SigninViewController* signin_view_controller, 219 SigninViewController* signin_view_controller,
202 profiles::BubbleViewMode mode, 220 profiles::BubbleViewMode mode,
203 Browser* browser, 221 Browser* browser,
204 signin_metrics::AccessPoint access_point) { 222 signin_metrics::AccessPoint access_point) {
205 return new SigninViewControllerDelegateViews( 223 return new SigninViewControllerDelegateViews(
206 signin_view_controller, 224 signin_view_controller,
207 SigninViewControllerDelegateViews::CreateGaiaWebView( 225 SigninViewControllerDelegateViews::CreateGaiaWebView(
208 nullptr, mode, browser, access_point), 226 nullptr, mode, browser, access_point),
209 browser, false); 227 browser, SigninViewControllerDelegateViews::TAB_MODAL, false);
210 } 228 }
211 229
212 SigninViewControllerDelegate* 230 SigninViewControllerDelegate*
213 SigninViewControllerDelegate::CreateSyncConfirmationDelegate( 231 SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
214 SigninViewController* signin_view_controller, 232 SigninViewController* signin_view_controller,
215 Browser* browser) { 233 Browser* browser) {
216 return new SigninViewControllerDelegateViews( 234 return new SigninViewControllerDelegateViews(
217 signin_view_controller, 235 signin_view_controller,
218 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser), 236 SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser),
219 browser, true); 237 browser, SigninViewControllerDelegateViews::WINDOW_MODAL, true);
220 } 238 }
221 239
222 SigninViewControllerDelegate* 240 SigninViewControllerDelegate*
223 SigninViewControllerDelegate::CreateSigninErrorDelegate( 241 SigninViewControllerDelegate::CreateSigninErrorDelegate(
224 SigninViewController* signin_view_controller, 242 SigninViewController* signin_view_controller,
225 Browser* browser) { 243 Browser* browser) {
226 return new SigninViewControllerDelegateViews( 244 return new SigninViewControllerDelegateViews(
227 signin_view_controller, 245 signin_view_controller,
228 SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser), 246 SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser),
229 browser, true); 247 browser, SigninViewControllerDelegateViews::WINDOW_MODAL, true);
230 } 248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698