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 to serve the purposes | |
|
Charlie Reis
2013/03/06 00:14:54
nit: chrome-extension URL
(We don't have an actual
tim (not reviewing)
2013/03/06 01:04:08
Done.
| |
| 100 // outlined in the .h file comment for this string. | |
| 101 const char* SyncPromoUI::kChromeSigninEffectiveURL = | |
| 102 "chrome-extension://acfccoigjajmmgbhpfbjnpckhjjegnih"; | |
| 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 if (url == GURL(kChromeSigninEffectiveURL)) | |
|
Charlie Reis
2013/03/06 00:14:54
You should check the scheme and host.
tim (not reviewing)
2013/03/06 01:04:08
Done.
| |
| 269 return true; | |
| 270 | |
| 271 GURL service_login(GaiaUrls::GetInstance()->service_login_url()); | |
| 272 if (url.GetOrigin() != service_login.GetOrigin()) | |
| 273 return false; | |
| 274 | |
| 275 return url.path() == service_login.path(); | |
| 276 } | |
| 277 | |
| 278 // static | |
| 262 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { | 279 GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { |
| 263 const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue : | 280 const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue : |
| 264 kSyncPromoQueryKeyNextPage; | 281 kSyncPromoQueryKeyNextPage; |
| 265 std::string value; | 282 std::string value; |
| 266 if (net::GetValueForKeyInQuery(url, key_name, &value)) { | 283 if (net::GetValueForKeyInQuery(url, key_name, &value)) { |
| 267 return GURL(value); | 284 return GURL(value); |
| 268 } | 285 } |
| 269 return GURL(); | 286 return GURL(); |
| 270 } | 287 } |
| 271 | 288 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 301 g_force_web_based_signin_flow; | 318 g_force_web_based_signin_flow; |
| 302 #else | 319 #else |
| 303 return false; | 320 return false; |
| 304 #endif | 321 #endif |
| 305 } | 322 } |
| 306 | 323 |
| 307 // static | 324 // static |
| 308 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { | 325 void SyncPromoUI::ForceWebBasedSigninFlowForTesting(bool force) { |
| 309 g_force_web_based_signin_flow = force; | 326 g_force_web_based_signin_flow = force; |
| 310 } | 327 } |
| OLD | NEW |