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

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

Issue 1487283005: Implement the new Sync Confirmation dialog on Linux and Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.h" 5 #include "chrome/browser/ui/views/profiles/signin_view_controller.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_error_controller_factory.h" 10 #include "chrome/browser/signin/signin_error_controller_factory.h"
11 #include "chrome/browser/signin/signin_promo.h" 11 #include "chrome/browser/signin/signin_promo.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/common/url_constants.h"
14 #include "components/constrained_window/constrained_window_views.h" 15 #include "components/constrained_window/constrained_window_views.h"
15 #include "components/signin/core/browser/signin_error_controller.h" 16 #include "components/signin/core/browser/signin_error_controller.h"
16 #include "components/signin/core/common/profile_management_switches.h" 17 #include "components/signin/core/common/profile_management_switches.h"
17 #include "content/public/browser/render_widget_host_view.h" 18 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "ui/views/controls/webview/webview.h" 20 #include "ui/views/controls/webview/webview.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
21 #include "ui/views/widget/widget_delegate.h" 22 #include "ui/views/widget/widget_delegate.h"
22 #include "ui/views/window/dialog_delegate.h" 23 #include "ui/views/window/dialog_delegate.h"
23 24
24 const int kPasswordCombinedFixedGaiaViewHeight = 440; 25 const int kPasswordCombinedFixedGaiaViewHeight = 440;
25 const int kPasswordCombinedFixedGaiaViewWidth = 360; 26 const int kPasswordCombinedFixedGaiaViewWidth = 360;
26 const int kFixedGaiaViewHeight = 512; 27 const int kFixedGaiaViewHeight = 512;
27 const int kFixedGaiaViewWidth = 448; 28 const int kFixedGaiaViewWidth = 448;
29 const int kSyncConfirmationDialogWidth = 448;
30 const int kSyncConfirmationDialogHeight = 351;
28 31
29 class ModalSigninDelegate : public views::DialogDelegateView { 32 class ModalSigninDelegate : public views::DialogDelegateView {
30 public: 33 public:
31 ModalSigninDelegate(SigninViewController* signin_view_controller, 34 ModalSigninDelegate(SigninViewController* signin_view_controller,
32 views::WebView* content_view, 35 views::WebView* content_view,
33 Browser* browser) 36 Browser* browser)
34 : content_view_(content_view), 37 : content_view_(content_view),
35 signin_view_controller_(signin_view_controller) { 38 signin_view_controller_(signin_view_controller) {
36 modal_signin_widget_ = constrained_window::ShowWebModalDialogViews( 39 modal_signin_widget_ = constrained_window::ShowWebModalDialogViews(
37 this, browser->tab_strip_model()->GetActiveWebContents()); 40 this, browser->tab_strip_model()->GetActiveWebContents());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 119
117 web_view->SetPreferredSize(pref_size); 120 web_view->SetPreferredSize(pref_size);
118 content::RenderWidgetHostView* rwhv = 121 content::RenderWidgetHostView* rwhv =
119 web_view->GetWebContents()->GetRenderWidgetHostView(); 122 web_view->GetWebContents()->GetRenderWidgetHostView();
120 if (rwhv) 123 if (rwhv)
121 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); 124 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor);
122 125
123 return web_view; 126 return web_view;
124 } 127 }
125 128
129 views::WebView* SigninViewController::CreateSyncConfirmationWebView(
130 Profile* profile) {
131 views::WebView* web_view = new views::WebView(profile);
132 web_view->LoadInitialURL(GURL(chrome::kChromeUISyncConfirmationURL));
133 web_view->SetPreferredSize(
134 gfx::Size(kSyncConfirmationDialogWidth, kSyncConfirmationDialogHeight));
135
136 return web_view;
137 }
138
126 void SigninViewController::ShowModalSignin( 139 void SigninViewController::ShowModalSignin(
127 profiles::BubbleViewMode mode, 140 profiles::BubbleViewMode mode,
128 Browser* browser, 141 Browser* browser,
129 signin_metrics::AccessPoint access_point) { 142 signin_metrics::AccessPoint access_point) {
130 CloseModalSignin(); 143 CloseModalSignin();
131 // The delegate will delete itself on request of the views code when the 144 // The delegate will delete itself on request of the views code when the
132 // widget is closed. 145 // widget is closed.
133 modal_signin_delegate_ = new ModalSigninDelegate( 146 modal_signin_delegate_ = new ModalSigninDelegate(
134 this, CreateGaiaWebView(nullptr, mode, browser->profile(), access_point), 147 this, CreateGaiaWebView(nullptr, mode, browser->profile(), access_point),
135 browser); 148 browser);
136 } 149 }
137 150
138 void SigninViewController::CloseModalSignin() { 151 void SigninViewController::CloseModalSignin() {
139 if (modal_signin_delegate_) 152 if (modal_signin_delegate_)
140 modal_signin_delegate_->CloseModalSignin(); 153 modal_signin_delegate_->CloseModalSignin();
141 DCHECK(!modal_signin_delegate_); 154 DCHECK(!modal_signin_delegate_);
142 } 155 }
143 156
144 void SigninViewController::ResetModalSigninDelegate() { 157 void SigninViewController::ResetModalSigninDelegate() {
145 modal_signin_delegate_ = nullptr; 158 modal_signin_delegate_ = nullptr;
146 } 159 }
147 160
161 void SigninViewController::ShowModalSyncConfirmationDialog(Browser* browser) {
162 CloseModalSignin();
163 modal_signin_delegate_ = new ModalSigninDelegate(
164 this, CreateSyncConfirmationWebView(browser->profile()), browser);
165 }
166
148 // static 167 // static
149 bool SigninViewController::ShouldShowModalSigninForMode( 168 bool SigninViewController::ShouldShowModalSigninForMode(
150 profiles::BubbleViewMode mode) { 169 profiles::BubbleViewMode mode) {
151 return switches::UsePasswordSeparatedSigninFlow() && 170 return switches::UsePasswordSeparatedSigninFlow() &&
152 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || 171 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN ||
153 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 172 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
154 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); 173 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH);
155 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698