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

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_handler_impl.cc

Issue 256623002: Implemented inline login dialog for Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge conflicts resolved. Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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/signin/inline_login_handler_impl.h" 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/signin/about_signin_internals_factory.h" 15 #include "chrome/browser/signin/about_signin_internals_factory.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_promo.h"
19 #include "chrome/browser/sync/profile_sync_service.h" 17 #include "chrome/browser/sync/profile_sync_service.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 18 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/ui/browser_finder.h" 19 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 20 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
23 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" 21 #include "chrome/browser/ui/sync/one_click_signin_histogram.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
27 #include "components/signin/core/browser/about_signin_internals.h" 24 #include "components/signin/core/browser/about_signin_internals.h"
28 #include "components/signin/core/browser/profile_oauth2_token_service.h" 25 #include "components/signin/core/browser/profile_oauth2_token_service.h"
29 #include "components/signin/core/browser/signin_error_controller.h" 26 #include "components/signin/core/browser/signin_error_controller.h"
30 #include "components/signin/core/browser/signin_oauth_helper.h" 27 #include "components/signin/core/browser/signin_oauth_helper.h"
31 #include "content/public/browser/storage_partition.h" 28 #include "content/public/browser/storage_partition.h"
32 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_ui.h" 29 #include "content/public/browser/web_ui.h"
34 #include "google_apis/gaia/gaia_auth_fetcher.h" 30 #include "google_apis/gaia/gaia_auth_fetcher.h"
35 #include "google_apis/gaia/gaia_auth_util.h" 31 #include "google_apis/gaia/gaia_auth_util.h"
36 #include "google_apis/gaia/gaia_constants.h" 32 #include "google_apis/gaia/gaia_constants.h"
37 #include "google_apis/gaia/gaia_urls.h" 33 #include "google_apis/gaia/gaia_urls.h"
38 #include "net/base/url_util.h" 34 #include "net/base/url_util.h"
39 35
40 namespace { 36 namespace {
41 37
42 class InlineSigninHelper : public SigninOAuthHelper, 38 class InlineSigninHelper : public SigninOAuthHelper,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 180
185 } // namespace 181 } // namespace
186 182
187 InlineLoginHandlerImpl::InlineLoginHandlerImpl() 183 InlineLoginHandlerImpl::InlineLoginHandlerImpl()
188 : weak_factory_(this), 184 : weak_factory_(this),
189 choose_what_to_sync_(false) { 185 choose_what_to_sync_(false) {
190 } 186 }
191 187
192 InlineLoginHandlerImpl::~InlineLoginHandlerImpl() {} 188 InlineLoginHandlerImpl::~InlineLoginHandlerImpl() {}
193 189
194 void InlineLoginHandlerImpl::RegisterMessages() { 190 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) {
195 InlineLoginHandler::RegisterMessages(); 191 params.SetString("service", "chromiumsync");
196 192
197 web_ui()->RegisterMessageCallback("switchToFullTab", 193 signin::Source source =
198 base::Bind(&InlineLoginHandlerImpl::HandleSwitchToFullTabMessage, 194 signin::GetSourceForPromoURL(web_ui()->GetWebContents()->GetURL());
199 base::Unretained(this)));
200 }
201
202 void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) {
203 params.SetInteger("authMode", InlineLoginHandler::kDesktopAuthMode);
204
205 const GURL& current_url = web_ui()->GetWebContents()->GetURL();
206 signin::Source source = signin::GetSourceForPromoURL(current_url);
207 if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT ||
208 source == signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) {
209 // Drop the leading slash in the path.
210 params.SetString("gaiaPath",
211 GaiaUrls::GetInstance()->embedded_signin_url().path().substr(1));
212 }
213
214 params.SetString("service", "chromiumsync");
215 params.SetString("continueUrl",
216 signin::GetLandingURL("source", static_cast<int>(source)).spec());
217
218 std::string default_email;
219 if (source != signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT) {
220 default_email = Profile::FromWebUI(web_ui())->GetPrefs()->
221 GetString(prefs::kGoogleServicesLastUsername);
222 } else {
223 if (!net::GetValueForKeyInQuery(current_url, "email", &default_email))
224 default_email.clear();
225 }
226 if (!default_email.empty())
227 params.SetString("email", default_email);
228
229 std::string frame_url;
230 net::GetValueForKeyInQuery(current_url, "frameUrl", &frame_url);
231 if (!frame_url.empty())
232 params.SetString("frameUrl", frame_url);
233
234 std::string is_constrained;
235 net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained);
236 if (!is_constrained.empty())
237 params.SetString("constrained", is_constrained);
238
239 // TODO(rogerta): this needs to be passed on to gaia somehow.
240 std::string read_only_email;
241 net::GetValueForKeyInQuery(current_url, "readOnlyEmail", &read_only_email);
242 if (!read_only_email.empty())
243 params.SetString("readOnlyEmail", read_only_email);
244
245 OneClickSigninHelper::LogHistogramValue( 195 OneClickSigninHelper::LogHistogramValue(
246 source, one_click_signin::HISTOGRAM_SHOWN); 196 source, one_click_signin::HISTOGRAM_SHOWN);
247 } 197 }
248 198
249 void InlineLoginHandlerImpl::HandleSwitchToFullTabMessage(
250 const base::ListValue* args) {
251 base::string16 url_str;
252 CHECK(args->GetString(0, &url_str));
253
254 content::WebContents* web_contents = web_ui()->GetWebContents();
255 GURL main_frame_url(web_contents->GetURL());
256 main_frame_url = net::AppendOrReplaceQueryParameter(
257 main_frame_url, "frameUrl", base::UTF16ToASCII(url_str));
258 chrome::NavigateParams params(
259 Profile::FromWebUI(web_ui()),
260 net::AppendOrReplaceQueryParameter(main_frame_url, "constrained", "0"),
261 content::PAGE_TRANSITION_AUTO_TOPLEVEL);
262 chrome::Navigate(&params);
263
264 web_ui()->CallJavascriptFunction("inline.login.closeDialog");
265 }
266
267 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) { 199 void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
268 content::WebContents* contents = web_ui()->GetWebContents(); 200 content::WebContents* contents = web_ui()->GetWebContents();
269 const GURL& current_url = contents->GetURL(); 201 const GURL& current_url = contents->GetURL();
270 202
271 const base::DictionaryValue* dict = NULL; 203 const base::DictionaryValue* dict = NULL;
272 args->GetDictionary(0, &dict); 204 args->GetDictionary(0, &dict);
273 205
274 bool skip_for_now = false; 206 bool skip_for_now = false;
275 dict->GetBoolean("skipForNow", &skip_for_now); 207 dict->GetBoolean("skipForNow", &skip_for_now);
276 if (skip_for_now) { 208 if (skip_for_now) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 TabStripModel* tab_strip_model = browser->tab_strip_model(); 344 TabStripModel* tab_strip_model = browser->tab_strip_model();
413 if (tab_strip_model) { 345 if (tab_strip_model) {
414 int index = tab_strip_model->GetIndexOfWebContents(tab); 346 int index = tab_strip_model->GetIndexOfWebContents(tab);
415 if (index != TabStripModel::kNoTab) { 347 if (index != TabStripModel::kNoTab) {
416 tab_strip_model->ExecuteContextMenuCommand( 348 tab_strip_model->ExecuteContextMenuCommand(
417 index, TabStripModel::CommandCloseTab); 349 index, TabStripModel::CommandCloseTab);
418 } 350 }
419 } 351 }
420 } 352 }
421 } 353 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/inline_login_handler_impl.h ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698