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

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

Issue 902493003: cros: Pass gaia_auth init params via postMessage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 5 years, 10 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
« no previous file with comments | « chrome/browser/resources/gaia_auth_host/gaia_auth_host.js ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "chrome/browser/ui/webui/signin/inline_login_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h"
12 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/signin/signin_promo.h" 15 #include "chrome/browser/signin/signin_promo.h"
14 #include "chrome/browser/ui/browser_navigator.h" 16 #include "chrome/browser/ui/browser_navigator.h"
15 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
18 #include "google_apis/gaia/gaia_urls.h" 20 #include "google_apis/gaia/gaia_urls.h"
19 #include "net/base/url_util.h" 21 #include "net/base/url_util.h"
20 22
21 InlineLoginHandler::InlineLoginHandler() {} 23 InlineLoginHandler::InlineLoginHandler() {}
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 params.SetString( 55 params.SetString(
54 "gaiaPath", 56 "gaiaPath",
55 GaiaUrls::GetInstance()->embedded_signin_url().path().substr(1)); 57 GaiaUrls::GetInstance()->embedded_signin_url().path().substr(1));
56 } 58 }
57 59
58 params.SetString( 60 params.SetString(
59 "continueUrl", 61 "continueUrl",
60 signin::GetLandingURL(signin::kSignInPromoQueryKeySource, 62 signin::GetLandingURL(signin::kSignInPromoQueryKeySource,
61 static_cast<int>(source)).spec()); 63 static_cast<int>(source)).spec());
62 64
65 Profile* profile = Profile::FromWebUI(web_ui());
63 std::string default_email; 66 std::string default_email;
64 if (source != signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT && 67 if (source != signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT &&
65 source != signin_metrics::SOURCE_REAUTH) { 68 source != signin_metrics::SOURCE_REAUTH) {
66 default_email = Profile::FromWebUI(web_ui())->GetPrefs()->GetString( 69 default_email =
67 prefs::kGoogleServicesLastUsername); 70 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
68 } else { 71 } else {
69 if (!net::GetValueForKeyInQuery(current_url, "email", &default_email)) 72 if (!net::GetValueForKeyInQuery(current_url, "email", &default_email))
70 default_email.clear(); 73 default_email.clear();
71 } 74 }
72 if (!default_email.empty()) 75 if (!default_email.empty())
73 params.SetString("email", default_email); 76 params.SetString("email", default_email);
74 77
78 std::string frame_url_id_str;
79 net::GetValueForKeyInQuery(current_url, "frameUrlId", &frame_url_id_str);
80 int frame_url_id;
75 std::string frame_url; 81 std::string frame_url;
76 net::GetValueForKeyInQuery(current_url, "frameUrl", &frame_url); 82 if (!frame_url_id_str.empty() &&
77 if (!frame_url.empty()) 83 base::StringToInt(frame_url_id_str, &frame_url_id) &&
84 extensions::GaiaAuthExtensionLoader::Get(profile)
85 ->GetData(frame_url_id, &frame_url)) {
78 params.SetString("frameUrl", frame_url); 86 params.SetString("frameUrl", frame_url);
87 }
79 88
80 std::string is_constrained; 89 std::string is_constrained;
81 net::GetValueForKeyInQuery( 90 net::GetValueForKeyInQuery(
82 current_url, signin::kSignInPromoQueryKeyConstrained, &is_constrained); 91 current_url, signin::kSignInPromoQueryKeyConstrained, &is_constrained);
83 if (!is_constrained.empty()) 92 if (!is_constrained.empty())
84 params.SetString(signin::kSignInPromoQueryKeyConstrained, is_constrained); 93 params.SetString(signin::kSignInPromoQueryKeyConstrained, is_constrained);
85 94
86 // TODO(rogerta): this needs to be passed on to gaia somehow. 95 // TODO(rogerta): this needs to be passed on to gaia somehow.
87 std::string read_only_email; 96 std::string read_only_email;
88 net::GetValueForKeyInQuery(current_url, "readOnlyEmail", &read_only_email); 97 net::GetValueForKeyInQuery(current_url, "readOnlyEmail", &read_only_email);
89 if (!read_only_email.empty()) 98 if (!read_only_email.empty())
90 params.SetString("readOnlyEmail", read_only_email); 99 params.SetString("readOnlyEmail", read_only_email);
91 100
92 SetExtraInitParams(params); 101 SetExtraInitParams(params);
93 102
94 web_ui()->CallJavascriptFunction("inline.login.loadAuthExtension", params); 103 web_ui()->CallJavascriptFunction("inline.login.loadAuthExtension", params);
95 } 104 }
96 105
97 void InlineLoginHandler::HandleCompleteLoginMessage( 106 void InlineLoginHandler::HandleCompleteLoginMessage(
98 const base::ListValue* args) { 107 const base::ListValue* args) {
99 CompleteLogin(args); 108 CompleteLogin(args);
100 } 109 }
101 110
102 void InlineLoginHandler::HandleSwitchToFullTabMessage( 111 void InlineLoginHandler::HandleSwitchToFullTabMessage(
103 const base::ListValue* args) { 112 const base::ListValue* args) {
104 base::string16 url_str; 113 std::string url_str;
105 CHECK(args->GetString(0, &url_str)); 114 CHECK(args->GetString(0, &url_str));
106 115
116 Profile* profile = Profile::FromWebUI(web_ui());
117 const int frame_url_id =
118 extensions::GaiaAuthExtensionLoader::Get(profile)->AddData(url_str);
119
107 content::WebContents* web_contents = web_ui()->GetWebContents(); 120 content::WebContents* web_contents = web_ui()->GetWebContents();
108 GURL main_frame_url(web_contents->GetURL()); 121 GURL main_frame_url(web_contents->GetURL());
109 main_frame_url = net::AppendOrReplaceQueryParameter( 122 main_frame_url = net::AppendOrReplaceQueryParameter(
110 main_frame_url, "frameUrl", base::UTF16ToASCII(url_str)); 123 main_frame_url, "frameUrlId", base::IntToString(frame_url_id));
111 124
112 // Adds extra parameters to the signin URL so that Chrome will close the tab 125 // Adds extra parameters to the signin URL so that Chrome will close the tab
113 // and show the account management view of the avatar menu upon completion. 126 // and show the account management view of the avatar menu upon completion.
114 main_frame_url = net::AppendOrReplaceQueryParameter( 127 main_frame_url = net::AppendOrReplaceQueryParameter(
115 main_frame_url, signin::kSignInPromoQueryKeyAutoClose, "1"); 128 main_frame_url, signin::kSignInPromoQueryKeyAutoClose, "1");
116 main_frame_url = net::AppendOrReplaceQueryParameter( 129 main_frame_url = net::AppendOrReplaceQueryParameter(
117 main_frame_url, signin::kSignInPromoQueryKeyShowAccountManagement, "1"); 130 main_frame_url, signin::kSignInPromoQueryKeyShowAccountManagement, "1");
118 131
119 chrome::NavigateParams params( 132 chrome::NavigateParams params(
120 Profile::FromWebUI(web_ui()), 133 profile,
121 net::AppendOrReplaceQueryParameter( 134 net::AppendOrReplaceQueryParameter(
122 main_frame_url, signin::kSignInPromoQueryKeyConstrained, "0"), 135 main_frame_url, signin::kSignInPromoQueryKeyConstrained, "0"),
123 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); 136 ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
124 chrome::Navigate(&params); 137 chrome::Navigate(&params);
125 138
126 web_ui()->CallJavascriptFunction("inline.login.closeDialog"); 139 web_ui()->CallJavascriptFunction("inline.login.closeDialog");
127 } 140 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/gaia_auth_host/gaia_auth_host.js ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698