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

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

Issue 2685163003: Avoid multiple displays of the sign-in dialogs. (Closed)
Patch Set: Ready for reviews Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/views/profiles/signin_view_controller_delegate_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ui::ModalType dialog_modal_type, 45 ui::ModalType dialog_modal_type,
46 bool wait_for_size) 46 bool wait_for_size)
47 : SigninViewControllerDelegate(signin_view_controller, 47 : SigninViewControllerDelegate(signin_view_controller,
48 content_view->GetWebContents()), 48 content_view->GetWebContents()),
49 content_view_(content_view.release()), 49 content_view_(content_view.release()),
50 modal_signin_widget_(nullptr), 50 modal_signin_widget_(nullptr),
51 dialog_modal_type_(dialog_modal_type), 51 dialog_modal_type_(dialog_modal_type),
52 wait_for_size_(wait_for_size),
53 browser_(browser) { 52 browser_(browser) {
54 DCHECK(browser_); 53 DCHECK(browser_);
55 DCHECK(browser_->tab_strip_model()->GetActiveWebContents()) 54 DCHECK(browser_->tab_strip_model()->GetActiveWebContents())
56 << "A tab must be active to present the sign-in modal dialog."; 55 << "A tab must be active to present the sign-in modal dialog.";
57 DCHECK(dialog_modal_type == ui::MODAL_TYPE_CHILD || 56 DCHECK(dialog_modal_type == ui::MODAL_TYPE_CHILD ||
58 dialog_modal_type == ui::MODAL_TYPE_WINDOW) 57 dialog_modal_type == ui::MODAL_TYPE_WINDOW)
59 << "Unsupported dialog modal type " << dialog_modal_type; 58 << "Unsupported dialog modal type " << dialog_modal_type;
60 if (!wait_for_size_) 59 if (!wait_for_size)
61 DisplayModal(); 60 DisplayModal();
62 } 61 }
63 62
64 SigninViewControllerDelegateViews::~SigninViewControllerDelegateViews() {} 63 SigninViewControllerDelegateViews::~SigninViewControllerDelegateViews() {}
65 64
66 // views::DialogDelegateView: 65 // views::DialogDelegateView:
67 views::View* SigninViewControllerDelegateViews::GetContentsView() { 66 views::View* SigninViewControllerDelegateViews::GetContentsView() {
68 return content_view_; 67 return content_view_;
69 } 68 }
70 69
(...skipping 29 matching lines...) Expand all
100 99
101 void SigninViewControllerDelegateViews::ResizeNativeView(int height) { 100 void SigninViewControllerDelegateViews::ResizeNativeView(int height) {
102 int max_height = browser_ 101 int max_height = browser_
103 ->window() 102 ->window()
104 ->GetWebContentsModalDialogHost() 103 ->GetWebContentsModalDialogHost()
105 ->GetMaximumDialogSize().height(); 104 ->GetMaximumDialogSize().height();
106 content_view_->SetPreferredSize( 105 content_view_->SetPreferredSize(
107 gfx::Size(kModalDialogWidth, std::min(height, max_height))); 106 gfx::Size(kModalDialogWidth, std::min(height, max_height)));
108 content_view_->Layout(); 107 content_view_->Layout();
109 108
110 if (wait_for_size_) { 109 if (!modal_signin_widget_) {
111 // The modal wasn't displayed yet so just show it with the already resized 110 // The modal wasn't displayed yet so just show it with the already resized
112 // view. 111 // view.
113 DisplayModal(); 112 DisplayModal();
114 } 113 }
115 } 114 }
116 115
117 void SigninViewControllerDelegateViews::DisplayModal() { 116 void SigninViewControllerDelegateViews::DisplayModal() {
117 DCHECK(!modal_signin_widget_);
118
118 content::WebContents* host_web_contents = 119 content::WebContents* host_web_contents =
119 browser_->tab_strip_model()->GetActiveWebContents(); 120 browser_->tab_strip_model()->GetActiveWebContents();
120 121
121 // Avoid displaying the sign-in modal view if there are no active web 122 // Avoid displaying the sign-in modal view if there are no active web
122 // contents. This happens if the user closes the browser window before this 123 // contents. This happens if the user closes the browser window before this
123 // dialog has a chance to be displayed. 124 // dialog has a chance to be displayed.
124 if (!host_web_contents) 125 if (!host_web_contents)
125 return; 126 return;
126 127
127 gfx::NativeWindow window = host_web_contents->GetTopLevelNativeWindow(); 128 gfx::NativeWindow window = host_web_contents->GetTopLevelNativeWindow();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 237
237 SigninViewControllerDelegate* 238 SigninViewControllerDelegate*
238 SigninViewControllerDelegate::CreateSigninErrorDelegate( 239 SigninViewControllerDelegate::CreateSigninErrorDelegate(
239 SigninViewController* signin_view_controller, 240 SigninViewController* signin_view_controller,
240 Browser* browser) { 241 Browser* browser) {
241 return new SigninViewControllerDelegateViews( 242 return new SigninViewControllerDelegateViews(
242 signin_view_controller, 243 signin_view_controller,
243 SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser), 244 SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser),
244 browser, ui::MODAL_TYPE_WINDOW, true); 245 browser, ui::MODAL_TYPE_WINDOW, true);
245 } 246 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/signin_view_controller_delegate_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698