| 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 "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 8 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 9 #include "chrome/browser/signin/signin_error_controller_factory.h" | 9 #include "chrome/browser/signin/signin_error_controller_factory.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 "components/constrained_window/constrained_window_views.h" | 14 #include "components/constrained_window/constrained_window_views.h" |
| 14 #include "components/signin/core/browser/signin_error_controller.h" | 15 #include "components/signin/core/browser/signin_error_controller.h" |
| 15 #include "components/signin/core/common/profile_management_switches.h" | 16 #include "components/signin/core/common/profile_management_switches.h" |
| 16 #include "content/public/browser/render_widget_host_view.h" | 17 #include "content/public/browser/render_widget_host_view.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "ui/views/controls/webview/webview.h" | 19 #include "ui/views/controls/webview/webview.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 #include "ui/views/widget/widget_delegate.h" | 21 #include "ui/views/widget/widget_delegate.h" |
| 21 #include "ui/views/window/dialog_delegate.h" | 22 #include "ui/views/window/dialog_delegate.h" |
| 22 | 23 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 114 |
| 114 web_view->SetPreferredSize(pref_size); | 115 web_view->SetPreferredSize(pref_size); |
| 115 content::RenderWidgetHostView* rwhv = | 116 content::RenderWidgetHostView* rwhv = |
| 116 web_view->GetWebContents()->GetRenderWidgetHostView(); | 117 web_view->GetWebContents()->GetRenderWidgetHostView(); |
| 117 if (rwhv) | 118 if (rwhv) |
| 118 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); | 119 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); |
| 119 | 120 |
| 120 return web_view; | 121 return web_view; |
| 121 } | 122 } |
| 122 | 123 |
| 124 views::WebView* SigninViewController::CreateSyncConfirmationWebView( |
| 125 Profile* profile) { |
| 126 views::WebView* web_view = new views::WebView(profile); |
| 127 web_view->LoadInitialURL(GURL(chrome::kChromeUISyncConfirmationURL)); |
| 128 web_view->SetPreferredSize(gfx::Size(450, 360)); |
| 129 |
| 130 return web_view; |
| 131 } |
| 132 |
| 123 void SigninViewController::ShowModalSignin( | 133 void SigninViewController::ShowModalSignin( |
| 124 profiles::BubbleViewMode mode, Browser* browser) { | 134 profiles::BubbleViewMode mode, Browser* browser) { |
| 125 CloseModalSignin(); | 135 CloseModalSignin(); |
| 126 // The delegate will delete itself on request of the views code when the | 136 // The delegate will delete itself on request of the views code when the |
| 127 // widget is closed. | 137 // widget is closed. |
| 128 modal_signin_delegate_ = new ModalSigninDelegate( | 138 modal_signin_delegate_ = new ModalSigninDelegate( |
| 129 this, CreateGaiaWebView(nullptr, mode, browser->profile()), browser); | 139 this, CreateGaiaWebView(nullptr, mode, browser->profile()), browser); |
| 130 } | 140 } |
| 131 | 141 |
| 132 void SigninViewController::CloseModalSignin() { | 142 void SigninViewController::CloseModalSignin() { |
| 133 if (modal_signin_delegate_) | 143 if (modal_signin_delegate_) |
| 134 modal_signin_delegate_->CloseModalSignin(); | 144 modal_signin_delegate_->CloseModalSignin(); |
| 135 DCHECK(!modal_signin_delegate_); | 145 DCHECK(!modal_signin_delegate_); |
| 136 } | 146 } |
| 137 | 147 |
| 138 void SigninViewController::ResetModalSigninDelegate() { | 148 void SigninViewController::ResetModalSigninDelegate() { |
| 139 modal_signin_delegate_ = nullptr; | 149 modal_signin_delegate_ = nullptr; |
| 140 } | 150 } |
| 141 | 151 |
| 152 void SigninViewController::ShowModalSyncConfirmationDialog(Browser* browser) { |
| 153 CloseModalSignin(); |
| 154 modal_signin_delegate_ = new ModalSigninDelegate( |
| 155 this, CreateSyncConfirmationWebView(browser->profile()), browser); |
| 156 } |
| 157 |
| 142 // static | 158 // static |
| 143 bool SigninViewController::ShouldShowModalSigninForMode( | 159 bool SigninViewController::ShouldShowModalSigninForMode( |
| 144 profiles::BubbleViewMode mode) { | 160 profiles::BubbleViewMode mode) { |
| 145 return switches::UsePasswordSeparatedSigninFlow() && | 161 return switches::UsePasswordSeparatedSigninFlow() && |
| 146 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || | 162 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
| 147 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || | 163 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
| 148 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); | 164 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
| 149 } | 165 } |
| OLD | NEW |