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

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc

Issue 11494003: Enable "Let me choose what to sync" checkbox in gaia sign in page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only redirect to NTP on error if explicit signin Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync_promo/sync_promo_ui.h" 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace { 43 namespace {
44 44
45 const char kStringsJsFile[] = "strings.js"; 45 const char kStringsJsFile[] = "strings.js";
46 const char kSyncPromoJsFile[] = "sync_promo.js"; 46 const char kSyncPromoJsFile[] = "sync_promo.js";
47 47
48 const char kSyncPromoQueryKeyAutoClose[] = "auto_close"; 48 const char kSyncPromoQueryKeyAutoClose[] = "auto_close";
49 const char kSyncPromoQueryKeyContinue[] = "continue"; 49 const char kSyncPromoQueryKeyContinue[] = "continue";
50 const char kSyncPromoQueryKeyNextPage[] = "next_page"; 50 const char kSyncPromoQueryKeyNextPage[] = "next_page";
51 const char kSyncPromoQueryKeySource[] = "source"; 51 const char kSyncPromoQueryKeySource[] = "source";
52 52
53 // TODO(rogerta): It would be better to use about:blank, but until that is 53 // Gaia cannot support about:blank as a continue URL, so using a hosted blank
54 // supported by Gaia this blank continue URL will be used. 54 // page instead.
55 const char kContinueUrl[] = "http://www.google.com/gen_204"; 55 const char kContinueUrl[] = "http://www.google.com/chrome/blank.html";
56 56
57 // The maximum number of times we want to show the sync promo at startup. 57 // The maximum number of times we want to show the sync promo at startup.
58 const int kSyncPromoShowAtStartupMaximum = 10; 58 const int kSyncPromoShowAtStartupMaximum = 10;
59 59
60 // Checks we want to show the sync promo for the given brand. 60 // Checks we want to show the sync promo for the given brand.
61 bool AllowPromoAtStartupForCurrentBrand() { 61 bool AllowPromoAtStartupForCurrentBrand() {
62 std::string brand; 62 std::string brand;
63 google_util::GetBrand(&brand); 63 google_util::GetBrand(&brand);
64 64
65 if (brand.empty()) 65 if (brand.empty())
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // - tell Gaia which service the user is signing into. In this case, 233 // - tell Gaia which service the user is signing into. In this case,
234 // a chrome sign in uses the service "chromiumsync" 234 // a chrome sign in uses the service "chromiumsync"
235 // - provide a continue URL. This is the URL that Gaia will redirect to 235 // - provide a continue URL. This is the URL that Gaia will redirect to
236 // once the sign is complete. 236 // once the sign is complete.
237 // 237 //
238 // The continue URL includes a source parameter that can be extracted using 238 // The continue URL includes a source parameter that can be extracted using
239 // the function GetSourceForSyncPromoURL() below. This is used to know 239 // the function GetSourceForSyncPromoURL() below. This is used to know
240 // which of the chrome sign in access points was used to sign the userr in. 240 // which of the chrome sign in access points was used to sign the userr in.
241 // See OneClickSigninHelper for details. 241 // See OneClickSigninHelper for details.
242 url_string = GaiaUrls::GetInstance()->service_login_url(); 242 url_string = GaiaUrls::GetInstance()->service_login_url();
243 url_string.append("?service=chromiumsync"); 243 url_string.append("?service=chromiumsync&sarp=1&rm=hide&fpc=1");
244 244
245 std::string continue_url = base::StringPrintf("%s?%s=%d", 245 std::string continue_url = base::StringPrintf("%s?%s=%d",
246 kContinueUrl, kSyncPromoQueryKeySource, static_cast<int>(source)); 246 kContinueUrl, kSyncPromoQueryKeySource, static_cast<int>(source));
247 247
248 base::StringAppendF(&url_string, "&%s=%s", kSyncPromoQueryKeyContinue, 248 base::StringAppendF(&url_string, "&%s=%s", kSyncPromoQueryKeyContinue,
249 net::EscapeQueryParamValue( 249 net::EscapeQueryParamValue(
250 continue_url, false).c_str()); 250 continue_url, false).c_str());
251 } else { 251 } else {
252 url_string = base::StringPrintf("%s?%s=%d", chrome::kChromeUISyncPromoURL, 252 url_string = base::StringPrintf("%s?%s=%d", chrome::kChromeUISyncPromoURL,
253 kSyncPromoQueryKeySource, 253 kSyncPromoQueryKeySource,
254 static_cast<int>(source)); 254 static_cast<int>(source));
255 255
256 if (auto_close) 256 if (auto_close)
257 base::StringAppendF(&url_string, "&%s=1", kSyncPromoQueryKeyAutoClose); 257 base::StringAppendF(&url_string, "&%s=1", kSyncPromoQueryKeyAutoClose);
258 258
259 if (!next_page.spec().empty()) { 259 if (!next_page.spec().empty()) {
260 base::StringAppendF(&url_string, "&%s=%s", kSyncPromoQueryKeyNextPage, 260 base::StringAppendF(&url_string, "&%s=%s", kSyncPromoQueryKeyNextPage,
261 net::EscapeQueryParamValue(next_page.spec(), 261 net::EscapeQueryParamValue(next_page.spec(),
262 false).c_str()); 262 false).c_str());
263 } 263 }
264 } 264 }
265 265
266 return GURL(url_string); 266 return GURL(url_string);
267 } 267 }
268 268
269 // static 269 // static
270 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { 270 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) {
271 const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue :
272 kSyncPromoQueryKeyNextPage;
271 std::string value; 273 std::string value;
272 if (chrome_common_net::GetValueForKeyInQuery( 274 if (chrome_common_net::GetValueForKeyInQuery(url, key_name, &value)) {
273 url, kSyncPromoQueryKeyNextPage, &value)) {
274 return GURL(value); 275 return GURL(value);
275 } 276 }
276 return GURL(); 277 return GURL();
277 } 278 }
278 279
279 // static 280 // static
280 SyncPromoUI::Source SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) { 281 SyncPromoUI::Source SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) {
281 std::string value; 282 std::string value;
282 if (chrome_common_net::GetValueForKeyInQuery( 283 if (chrome_common_net::GetValueForKeyInQuery(
283 url, kSyncPromoQueryKeySource, &value)) { 284 url, kSyncPromoQueryKeySource, &value)) {
(...skipping 20 matching lines...) Expand all
304 305
305 // static 306 // static
306 bool SyncPromoUI::UseWebBasedSigninFlow() { 307 bool SyncPromoUI::UseWebBasedSigninFlow() {
307 #if defined(ENABLE_ONE_CLICK_SIGNIN) 308 #if defined(ENABLE_ONE_CLICK_SIGNIN)
308 return CommandLine::ForCurrentProcess()->HasSwitch( 309 return CommandLine::ForCurrentProcess()->HasSwitch(
309 switches::kUseWebBasedSigninFlow); 310 switches::kUseWebBasedSigninFlow);
310 #else 311 #else
311 return false; 312 return false;
312 #endif 313 #endif
313 } 314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698