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" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 : modal_signin_delegate_(nullptr) {} | 90 : modal_signin_delegate_(nullptr) {} |
91 | 91 |
92 SigninViewController::~SigninViewController() { | 92 SigninViewController::~SigninViewController() { |
93 CloseModalSignin(); | 93 CloseModalSignin(); |
94 } | 94 } |
95 | 95 |
96 // static | 96 // static |
97 views::WebView* SigninViewController::CreateGaiaWebView( | 97 views::WebView* SigninViewController::CreateGaiaWebView( |
98 content::WebContentsDelegate* delegate, | 98 content::WebContentsDelegate* delegate, |
99 profiles::BubbleViewMode mode, | 99 profiles::BubbleViewMode mode, |
100 Profile* profile) { | 100 Profile* profile, |
101 GURL url = signin::GetSigninURLFromBubbleViewMode(profile, mode); | 101 signin_metrics::AccessPoint access_point) { |
| 102 GURL url = |
| 103 signin::GetSigninURLFromBubbleViewMode(profile, mode, access_point); |
102 | 104 |
103 // Adds Gaia signin webview. | 105 // Adds Gaia signin webview. |
104 const gfx::Size pref_size = switches::UsePasswordSeparatedSigninFlow() | 106 const gfx::Size pref_size = switches::UsePasswordSeparatedSigninFlow() |
105 ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight) | 107 ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight) |
106 : gfx::Size(kPasswordCombinedFixedGaiaViewWidth, | 108 : gfx::Size(kPasswordCombinedFixedGaiaViewWidth, |
107 kPasswordCombinedFixedGaiaViewHeight); | 109 kPasswordCombinedFixedGaiaViewHeight); |
108 views::WebView* web_view = new views::WebView(profile); | 110 views::WebView* web_view = new views::WebView(profile); |
109 web_view->LoadInitialURL(url); | 111 web_view->LoadInitialURL(url); |
110 | 112 |
111 if (delegate) | 113 if (delegate) |
112 web_view->GetWebContents()->SetDelegate(delegate); | 114 web_view->GetWebContents()->SetDelegate(delegate); |
113 | 115 |
114 web_view->SetPreferredSize(pref_size); | 116 web_view->SetPreferredSize(pref_size); |
115 content::RenderWidgetHostView* rwhv = | 117 content::RenderWidgetHostView* rwhv = |
116 web_view->GetWebContents()->GetRenderWidgetHostView(); | 118 web_view->GetWebContents()->GetRenderWidgetHostView(); |
117 if (rwhv) | 119 if (rwhv) |
118 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); | 120 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); |
119 | 121 |
120 return web_view; | 122 return web_view; |
121 } | 123 } |
122 | 124 |
123 void SigninViewController::ShowModalSignin( | 125 void SigninViewController::ShowModalSignin( |
124 profiles::BubbleViewMode mode, Browser* browser) { | 126 profiles::BubbleViewMode mode, |
| 127 Browser* browser, |
| 128 signin_metrics::AccessPoint access_point) { |
125 CloseModalSignin(); | 129 CloseModalSignin(); |
126 // The delegate will delete itself on request of the views code when the | 130 // The delegate will delete itself on request of the views code when the |
127 // widget is closed. | 131 // widget is closed. |
128 modal_signin_delegate_ = new ModalSigninDelegate( | 132 modal_signin_delegate_ = new ModalSigninDelegate( |
129 this, CreateGaiaWebView(nullptr, mode, browser->profile()), browser); | 133 this, CreateGaiaWebView(nullptr, mode, browser->profile(), access_point), |
| 134 browser); |
130 } | 135 } |
131 | 136 |
132 void SigninViewController::CloseModalSignin() { | 137 void SigninViewController::CloseModalSignin() { |
133 if (modal_signin_delegate_) | 138 if (modal_signin_delegate_) |
134 modal_signin_delegate_->CloseModalSignin(); | 139 modal_signin_delegate_->CloseModalSignin(); |
135 DCHECK(!modal_signin_delegate_); | 140 DCHECK(!modal_signin_delegate_); |
136 } | 141 } |
137 | 142 |
138 void SigninViewController::ResetModalSigninDelegate() { | 143 void SigninViewController::ResetModalSigninDelegate() { |
139 modal_signin_delegate_ = nullptr; | 144 modal_signin_delegate_ = nullptr; |
140 } | 145 } |
141 | 146 |
142 // static | 147 // static |
143 bool SigninViewController::ShouldShowModalSigninForMode( | 148 bool SigninViewController::ShouldShowModalSigninForMode( |
144 profiles::BubbleViewMode mode) { | 149 profiles::BubbleViewMode mode) { |
145 return switches::UsePasswordSeparatedSigninFlow() && | 150 return switches::UsePasswordSeparatedSigninFlow() && |
146 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || | 151 (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
147 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || | 152 mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
148 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); | 153 mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
149 } | 154 } |
OLD | NEW |