OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/webui/inline_login_ui.h" | 5 #include "chrome/browser/ui/webui/inline_login_ui.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // the cookie jar of the embedded webview. | 144 // the cookie jar of the embedded webview. |
145 std::string scope = net::EscapeUrlEncodedData( | 145 std::string scope = net::EscapeUrlEncodedData( |
146 gaiaUrls->oauth1_login_scope(), true); | 146 gaiaUrls->oauth1_login_scope(), true); |
147 std::string client_id = net::EscapeUrlEncodedData( | 147 std::string client_id = net::EscapeUrlEncodedData( |
148 gaiaUrls->oauth2_chrome_client_id(), true); | 148 gaiaUrls->oauth2_chrome_client_id(), true); |
149 std::string encoded_continue_params = base::StringPrintf( | 149 std::string encoded_continue_params = base::StringPrintf( |
150 "?scope=%s&client_id=%s", scope.c_str(), client_id.c_str()); | 150 "?scope=%s&client_id=%s", scope.c_str(), client_id.c_str()); |
151 | 151 |
152 const GURL& current_url = web_ui()->GetWebContents()->GetURL(); | 152 const GURL& current_url = web_ui()->GetWebContents()->GetURL(); |
153 signin::Source source = signin::GetSourceForPromoURL(current_url); | 153 signin::Source source = signin::GetSourceForPromoURL(current_url); |
154 // TODO(guohui): switch to the embedded gaia endpoint for avatar flows | |
155 // when available. | |
156 DCHECK(source != signin::SOURCE_UNKNOWN); | 154 DCHECK(source != signin::SOURCE_UNKNOWN); |
157 if (source != signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT && | 155 if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || |
158 source != signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) { | 156 source == signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) { |
159 params.SetString("service", "chromiumsync"); | 157 // Drop the leading slash in the path. |
160 base::StringAppendF( | 158 params.SetString("gaiaPath", |
161 &encoded_continue_params, "&%s=%d", "source", | 159 gaiaUrls->embedded_signin_url().path().substr(1)); |
162 static_cast<int>(source)); | |
163 } | 160 } |
164 | 161 |
| 162 params.SetString("service", "chromiumsync"); |
| 163 base::StringAppendF( |
| 164 &encoded_continue_params, "&%s=%d", "source", |
| 165 static_cast<int>(source)); |
| 166 |
165 params.SetString("continueUrl", | 167 params.SetString("continueUrl", |
166 gaiaUrls->client_login_to_oauth2_url().Resolve( | 168 gaiaUrls->client_login_to_oauth2_url().Resolve( |
167 encoded_continue_params).spec()); | 169 encoded_continue_params).spec()); |
168 | 170 |
169 std::string email; | 171 std::string email; |
170 net::GetValueForKeyInQuery(current_url, "Email", &email); | 172 net::GetValueForKeyInQuery(current_url, "Email", &email); |
171 if (!email.empty()) | 173 if (!email.empty()) |
172 params.SetString("email", email); | 174 params.SetString("email", email); |
173 | 175 |
174 partition_id_ = | 176 partition_id_ = |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); | 341 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); |
340 | 342 |
341 web_ui->AddMessageHandler(new InlineLoginUIHandler(profile)); | 343 web_ui->AddMessageHandler(new InlineLoginUIHandler(profile)); |
342 // Required for intercepting extension function calls when the page is loaded | 344 // Required for intercepting extension function calls when the page is loaded |
343 // in a bubble (not a full tab, thus tab helpers are not registered | 345 // in a bubble (not a full tab, thus tab helpers are not registered |
344 // automatically). | 346 // automatically). |
345 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); | 347 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); |
346 } | 348 } |
347 | 349 |
348 InlineLoginUI::~InlineLoginUI() {} | 350 InlineLoginUI::~InlineLoginUI() {} |
OLD | NEW |