| OLD | NEW |
| 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/browser/ui/webui/signin/inline_login_ui.h" | 14 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
| 15 #include "chrome/common/url_constants.h" |
| 15 #include "components/constrained_window/constrained_window_views.h" | 16 #include "components/constrained_window/constrained_window_views.h" |
| 16 #include "components/signin/core/browser/signin_error_controller.h" | 17 #include "components/signin/core/browser/signin_error_controller.h" |
| 17 #include "components/signin/core/common/profile_management_switches.h" | 18 #include "components/signin/core/common/profile_management_switches.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/render_widget_host_view.h" | 20 #include "content/public/browser/render_widget_host_view.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
| 22 #include "ui/gfx/paint_vector_icon.h" | 23 #include "ui/gfx/paint_vector_icon.h" |
| 23 #include "ui/gfx/vector_icons.h" | 24 #include "ui/gfx/vector_icons.h" |
| 24 #include "ui/views/controls/button/image_button.h" | 25 #include "ui/views/controls/button/image_button.h" |
| 25 #include "ui/views/controls/webview/webview.h" | 26 #include "ui/views/controls/webview/webview.h" |
| 26 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
| 27 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 28 #include "ui/views/widget/widget_delegate.h" | 29 #include "ui/views/widget/widget_delegate.h" |
| 29 #include "ui/views/window/dialog_delegate.h" | 30 #include "ui/views/window/dialog_delegate.h" |
| 30 | 31 |
| 31 const int kPasswordCombinedFixedGaiaViewHeight = 440; | 32 const int kPasswordCombinedFixedGaiaViewHeight = 440; |
| 32 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 33 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
| 33 const int kFixedGaiaViewHeight = 512; | 34 const int kFixedGaiaViewHeight = 512; |
| 34 const int kFixedGaiaViewWidth = 448; | 35 const int kFixedGaiaViewWidth = 448; |
| 35 const int kNavigationButtonSize = 16; | 36 const int kNavigationButtonSize = 16; |
| 36 const int kNavigationButtonOffset = 16; | 37 const int kNavigationButtonOffset = 16; |
| 38 const int kSyncConfirmationDialogWidth = 448; |
| 39 const int kSyncConfirmationDialogHeight = 351; |
| 37 | 40 |
| 38 // View that contains the signin web contents and the back/close overlay button. | 41 // View that contains the signin web contents and the back/close overlay button. |
| 39 class HostView : public views::View { | 42 class HostView : public views::View { |
| 40 public: | 43 public: |
| 41 HostView(views::View* contents, views::ButtonListener* button_listener) | 44 HostView(views::View* contents, views::ButtonListener* button_listener) |
| 42 : contents_(contents), | 45 : contents_(contents), |
| 43 back_button_(new views::ImageButton(button_listener)) { | 46 back_button_(new views::ImageButton(button_listener)) { |
| 44 back_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, | 47 back_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| 45 views::ImageButton::ALIGN_MIDDLE); | 48 views::ImageButton::ALIGN_MIDDLE); |
| 46 back_button_->SetFocusable(true); | 49 back_button_->SetFocusable(true); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 218 |
| 216 web_view->SetPreferredSize(pref_size); | 219 web_view->SetPreferredSize(pref_size); |
| 217 content::RenderWidgetHostView* rwhv = | 220 content::RenderWidgetHostView* rwhv = |
| 218 web_view->GetWebContents()->GetRenderWidgetHostView(); | 221 web_view->GetWebContents()->GetRenderWidgetHostView(); |
| 219 if (rwhv) | 222 if (rwhv) |
| 220 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); | 223 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); |
| 221 | 224 |
| 222 return web_view; | 225 return web_view; |
| 223 } | 226 } |
| 224 | 227 |
| 228 views::WebView* SigninViewController::CreateSyncConfirmationWebView( |
| 229 Profile* profile) { |
| 230 views::WebView* web_view = new views::WebView(profile); |
| 231 web_view->LoadInitialURL(GURL(chrome::kChromeUISyncConfirmationURL)); |
| 232 web_view->SetPreferredSize( |
| 233 gfx::Size(kSyncConfirmationDialogWidth, kSyncConfirmationDialogHeight)); |
| 234 |
| 235 return web_view; |
| 236 } |
| 237 |
| 225 void SigninViewController::ShowModalSignin( | 238 void SigninViewController::ShowModalSignin( |
| 226 profiles::BubbleViewMode mode, | 239 profiles::BubbleViewMode mode, |
| 227 Browser* browser, | 240 Browser* browser, |
| 228 signin_metrics::AccessPoint access_point) { | 241 signin_metrics::AccessPoint access_point) { |
| 229 CloseModalSignin(); | 242 CloseModalSignin(); |
| 230 // The delegate will delete itself on request of the views code when the | 243 // The delegate will delete itself on request of the views code when the |
| 231 // widget is closed. | 244 // widget is closed. |
| 232 modal_signin_delegate_ = new ModalSigninDelegate( | 245 modal_signin_delegate_ = new ModalSigninDelegate( |
| 233 this, CreateGaiaWebView(nullptr, mode, browser->profile(), access_point), | 246 this, CreateGaiaWebView(nullptr, mode, browser->profile(), access_point), |
| 234 browser); | 247 browser); |
| 235 } | 248 } |
| 236 | 249 |
| 237 void SigninViewController::CloseModalSignin() { | 250 void SigninViewController::CloseModalSignin() { |
| 238 if (modal_signin_delegate_) | 251 if (modal_signin_delegate_) |
| 239 modal_signin_delegate_->CloseModalSignin(); | 252 modal_signin_delegate_->CloseModalSignin(); |
| 240 DCHECK(!modal_signin_delegate_); | 253 DCHECK(!modal_signin_delegate_); |
| 241 } | 254 } |
| 242 | 255 |
| 243 void SigninViewController::ResetModalSigninDelegate() { | 256 void SigninViewController::ResetModalSigninDelegate() { |
| 244 modal_signin_delegate_ = nullptr; | 257 modal_signin_delegate_ = nullptr; |
| 245 } | 258 } |
| 246 | 259 |
| 260 void SigninViewController::ShowModalSyncConfirmationDialog(Browser* browser) { |
| 261 CloseModalSignin(); |
| 262 modal_signin_delegate_ = new ModalSigninDelegate( |
| 263 this, CreateSyncConfirmationWebView(browser->profile()), browser); |
| 264 } |
| 265 |
| 247 // static | 266 // static |
| 248 bool SigninViewController::ShouldShowModalSigninForMode( | 267 bool SigninViewController::ShouldShowModalSigninForMode( |
| 249 profiles::BubbleViewMode mode) { | 268 profiles::BubbleViewMode mode) { |
| 250 return switches::UsePasswordSeparatedSigninFlow() && | 269 return switches::UsePasswordSeparatedSigninFlow() && |
| 251 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || | 270 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
| 252 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || | 271 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
| 253 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); | 272 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
| 254 } | 273 } |
| OLD | NEW |