| 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/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" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/first_run/first_run.h" | 13 #include "chrome/browser/first_run/first_run.h" |
| 14 #include "chrome/browser/google/google_util.h" | 14 #include "chrome/browser/google/google_util.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_info_cache.h" | 17 #include "chrome/browser/profiles/profile_info_cache.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
| 20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 21 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 21 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 22 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 22 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 23 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 23 #include "chrome/browser/ui/webui/options/core_options_handler.h" | 24 #include "chrome/browser/ui/webui/options/core_options_handler.h" |
| 24 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h" | 25 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler.h" |
| 25 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" | 26 #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" |
| 26 #include "chrome/browser/ui/webui/theme_source.h" | 27 #include "chrome/browser/ui/webui/theme_source.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/common/net/url_util.h" | 31 #include "chrome/common/net/url_util.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (brand.empty()) | 65 if (brand.empty()) |
| 65 return true; | 66 return true; |
| 66 | 67 |
| 67 if (google_util::IsInternetCafeBrandCode(brand)) | 68 if (google_util::IsInternetCafeBrandCode(brand)) |
| 68 return false; | 69 return false; |
| 69 | 70 |
| 70 // Enable for both organic and distribution. | 71 // Enable for both organic and distribution. |
| 71 return true; | 72 return true; |
| 72 } | 73 } |
| 73 | 74 |
| 74 bool UseWebBasedSigninFlow() { | |
| 75 const bool use_web_based_singin_flow = | |
| 76 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 77 switches::kUseWebBasedSigninFlow); | |
| 78 return use_web_based_singin_flow; | |
| 79 } | |
| 80 | |
| 81 // The Web UI data source for the sync promo page. | 75 // The Web UI data source for the sync promo page. |
| 82 class SyncPromoUIHTMLSource : public ChromeWebUIDataSource { | 76 class SyncPromoUIHTMLSource : public ChromeWebUIDataSource { |
| 83 public: | 77 public: |
| 84 explicit SyncPromoUIHTMLSource(content::WebUI* web_ui); | 78 explicit SyncPromoUIHTMLSource(content::WebUI* web_ui); |
| 85 | 79 |
| 86 private: | 80 private: |
| 87 ~SyncPromoUIHTMLSource() {} | 81 ~SyncPromoUIHTMLSource() {} |
| 88 DISALLOW_COPY_AND_ASSIGN(SyncPromoUIHTMLSource); | 82 DISALLOW_COPY_AND_ASSIGN(SyncPromoUIHTMLSource); |
| 89 }; | 83 }; |
| 90 | 84 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 215 } |
| 222 | 216 |
| 223 // static | 217 // static |
| 224 GURL SyncPromoUI::GetSyncPromoURL(const GURL& next_page, | 218 GURL SyncPromoUI::GetSyncPromoURL(const GURL& next_page, |
| 225 Source source, | 219 Source source, |
| 226 bool auto_close) { | 220 bool auto_close) { |
| 227 DCHECK_NE(SOURCE_UNKNOWN, source); | 221 DCHECK_NE(SOURCE_UNKNOWN, source); |
| 228 | 222 |
| 229 std::string url_string; | 223 std::string url_string; |
| 230 | 224 |
| 231 if (UseWebBasedSigninFlow()) { | 225 if (OneClickSigninHelper::UseWebBasedSigninFlow()) { |
| 232 // Build a Gaia-based URL that can be used to sign the user into chrome. | 226 // Build a Gaia-based URL that can be used to sign the user into chrome. |
| 233 // There are required request parameters: | 227 // There are required request parameters: |
| 234 // | 228 // |
| 235 // - tell Gaia which service the user is signing into. In this case, | 229 // - tell Gaia which service the user is signing into. In this case, |
| 236 // a chrome sign in uses the service "chromiumsync" | 230 // a chrome sign in uses the service "chromiumsync" |
| 237 // - provide a continue URL. This is the URL that Gaia will redirect to | 231 // - provide a continue URL. This is the URL that Gaia will redirect to |
| 238 // once the sign is complete. | 232 // once the sign is complete. |
| 239 // | 233 // |
| 240 // The continue URL includes a source parameter that can be extracted using | 234 // The continue URL includes a source parameter that can be extracted using |
| 241 // the function GetSourceForSyncPromoURL() below. This is used to know | 235 // the function GetSourceForSyncPromoURL() below. This is used to know |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 bool SyncPromoUI::GetAutoCloseForSyncPromoURL(const GURL& url) { | 290 bool SyncPromoUI::GetAutoCloseForSyncPromoURL(const GURL& url) { |
| 297 std::string value; | 291 std::string value; |
| 298 if (chrome_common_net::GetValueForKeyInQuery( | 292 if (chrome_common_net::GetValueForKeyInQuery( |
| 299 url, kSyncPromoQueryKeyAutoClose, &value)) { | 293 url, kSyncPromoQueryKeyAutoClose, &value)) { |
| 300 int source = 0; | 294 int source = 0; |
| 301 base::StringToInt(value, &source); | 295 base::StringToInt(value, &source); |
| 302 return (source == 1); | 296 return (source == 1); |
| 303 } | 297 } |
| 304 return false; | 298 return false; |
| 305 } | 299 } |
| OLD | NEW |