Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 html_source->AddLocalizedStrings(localized_strings); | 89 html_source->AddLocalizedStrings(localized_strings); |
| 90 html_source->SetJsonPath(kStringsJsFile); | 90 html_source->SetJsonPath(kStringsJsFile); |
| 91 html_source->AddResourcePath(kSyncPromoJsFile, IDR_SYNC_PROMO_JS); | 91 html_source->AddResourcePath(kSyncPromoJsFile, IDR_SYNC_PROMO_JS); |
| 92 html_source->SetDefaultResource(IDR_SYNC_PROMO_HTML); | 92 html_source->SetDefaultResource(IDR_SYNC_PROMO_HTML); |
| 93 html_source->SetUseJsonJSFormatV2(); | 93 html_source->SetUseJsonJSFormatV2(); |
| 94 return html_source; | 94 return html_source; |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| 98 | 98 |
| 99 // Under the covers, we use a dummy chrome-extension ID to serve the purposes | |
| 100 // outlined in the .h file comment for this string. | |
| 101 const char* SyncPromoUI::kChromeSigninEffectiveOrigin = | |
| 102 "chrome-extension://acfccoigjajmmgbhpfbjnpckhjjegnih"; | |
|
Charlie Reis
2013/03/06 01:28:46
Separate from this CL, please ask erikkay@ how we
| |
| 103 | |
| 99 SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 104 SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 100 SyncPromoHandler* handler = new SyncPromoHandler( | 105 SyncPromoHandler* handler = new SyncPromoHandler( |
| 101 g_browser_process->profile_manager()); | 106 g_browser_process->profile_manager()); |
| 102 web_ui->AddMessageHandler(handler); | 107 web_ui->AddMessageHandler(handler); |
| 103 | 108 |
| 104 // Set up the chrome://theme/ source. | 109 // Set up the chrome://theme/ source. |
| 105 Profile* profile = Profile::FromWebUI(web_ui); | 110 Profile* profile = Profile::FromWebUI(web_ui); |
| 106 ThemeSource* theme = new ThemeSource(profile); | 111 ThemeSource* theme = new ThemeSource(profile); |
| 107 content::URLDataSource::Add(profile, theme); | 112 content::URLDataSource::Add(profile, theme); |
| 108 | 113 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 base::StringAppendF(&url_string, "&%s=%s", kSyncPromoQueryKeyNextPage, | 257 base::StringAppendF(&url_string, "&%s=%s", kSyncPromoQueryKeyNextPage, |
| 253 net::EscapeQueryParamValue(next_page.spec(), | 258 net::EscapeQueryParamValue(next_page.spec(), |
| 254 false).c_str()); | 259 false).c_str()); |
| 255 } | 260 } |
| 256 } | 261 } |
| 257 | 262 |
| 258 return GURL(url_string); | 263 return GURL(url_string); |
| 259 } | 264 } |
| 260 | 265 |
| 261 // static | 266 // static |
| 267 bool SyncPromoUI::IsWebBasedSigninFlowURL(const GURL& url) { | |
| 268 GURL effective(kChromeSigninEffectiveOrigin); | |
| 269 if (url.SchemeIs(effective.scheme().c_str()) && | |
| 270 url.host() == effective.host()) | |
| 271 return true; | |
| 272 | |
| 273 GURL service_login(GaiaUrls::GetInstance()->service_login_url()); | |
| 274 if (url.GetOrigin() != service_login.GetOrigin()) | |
| 275 return false; | |
| 276 | |
| 277 return url.path() == service_login.path(); | |
| 278 } | |
| 279 | |
| 280 // static | |
| 262 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { | 281 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { |
| 263 const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue : | 282 const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue : |
| 264 kSyncPromoQueryKeyNextPage; | 283 kSyncPromoQueryKeyNextPage; |
| 265 std::string value; | 284 std::string value; |
| 266 if (net::GetValueForKeyInQuery(url, key_name, &value)) { | 285 if (net::GetValueForKeyInQuery(url, key_name, &value)) { |
| 267 return GURL(value); | 286 return GURL(value); |
| 268 } | 287 } |
| 269 return GURL(); | 288 return GURL(); |
| 270 } | 289 } |
| 271 | 290 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 301 g_force_web_based_signin_flow; | 320 g_force_web_based_signin_flow; |
| 302 #else | 321 #else |
| 303 return false; | 322 return false; |
| 304 #endif | 323 #endif |
| 305 } | 324 } |
| 306 | 325 |
| 307 // static | 326 // static |
| 308 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { | 327 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { |
| 309 g_force_web_based_signin_flow = force; | 328 g_force_web_based_signin_flow = force; |
| 310 } | 329 } |
| OLD | NEW |