| 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/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 const std::string& token, | 295 const std::string& token, |
| 296 const std::string& secret); | 296 const std::string& secret); |
| 297 | 297 |
| 298 // Check user's profile for kApplicationLocale setting. | 298 // Check user's profile for kApplicationLocale setting. |
| 299 void RespectLocalePreference(Profile* pref); | 299 void RespectLocalePreference(Profile* pref); |
| 300 | 300 |
| 301 // Callback for asynchronous profile creation. | 301 // Callback for asynchronous profile creation. |
| 302 void OnProfileCreated(Profile* profile, | 302 void OnProfileCreated(Profile* profile, |
| 303 Profile::CreateStatus status); | 303 Profile::CreateStatus status); |
| 304 | 304 |
| 305 // Initializes RLZ. If |disabled| is true, financial pings are turned off. | 305 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
| 306 void InitRlz(Profile* user_profile, bool disabled); | 306 void InitRlz(Profile* user_profile, bool disabled); |
| 307 | 307 |
| 308 std::string password_; | 308 std::string password_; |
| 309 bool pending_requests_; | 309 bool pending_requests_; |
| 310 bool using_oauth_; | 310 bool using_oauth_; |
| 311 bool has_cookies_; | 311 bool has_cookies_; |
| 312 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). | 312 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). |
| 313 scoped_refptr<Authenticator> authenticator_; | 313 scoped_refptr<Authenticator> authenticator_; |
| 314 scoped_ptr<PolicyOAuthFetcher> policy_oauth_fetcher_; | 314 scoped_ptr<PolicyOAuthFetcher> policy_oauth_fetcher_; |
| 315 scoped_ptr<OAuth1TokenFetcher> oauth1_token_fetcher_; | 315 scoped_ptr<OAuth1TokenFetcher> oauth1_token_fetcher_; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 | 602 |
| 603 void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) { | 603 void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) { |
| 604 #if defined(ENABLE_RLZ) | 604 #if defined(ENABLE_RLZ) |
| 605 if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) { | 605 if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) { |
| 606 // Read brand code asynchronously from an OEM file and repost ourselves. | 606 // Read brand code asynchronously from an OEM file and repost ourselves. |
| 607 google_util::chromeos::SetBrandFromFile( | 607 google_util::chromeos::SetBrandFromFile( |
| 608 base::Bind(&LoginUtilsImpl::InitRlzDelayed, AsWeakPtr(), user_profile)); | 608 base::Bind(&LoginUtilsImpl::InitRlzDelayed, AsWeakPtr(), user_profile)); |
| 609 return; | 609 return; |
| 610 } | 610 } |
| 611 base::PostTaskAndReplyWithResult( | 611 base::PostTaskAndReplyWithResult( |
| 612 base::WorkerPool::GetTaskRunner(false /* task_is_slow */), | 612 base::WorkerPool::GetTaskRunner(false), |
| 613 FROM_HERE, | 613 FROM_HERE, |
| 614 base::Bind(&file_util::PathExists, GetRlzDisabledFlagPath()), | 614 base::Bind(&file_util::PathExists, GetRlzDisabledFlagPath()), |
| 615 base::Bind(&LoginUtilsImpl::InitRlz, AsWeakPtr(), user_profile)); | 615 base::Bind(&LoginUtilsImpl::InitRlz, AsWeakPtr(), user_profile)); |
| 616 #endif | 616 #endif |
| 617 } | 617 } |
| 618 | 618 |
| 619 void LoginUtilsImpl::InitRlz(Profile* user_profile, bool disabled) { | 619 void LoginUtilsImpl::InitRlz(Profile* user_profile, bool disabled) { |
| 620 #if defined(ENABLE_RLZ) | 620 #if defined(ENABLE_RLZ) |
| 621 if (disabled) { | 621 if (disabled) { |
| 622 // Empty brand code turns financial pings off. | 622 // Empty brand code means an organic install (no RLZ pings are sent). |
| 623 google_util::chromeos::ClearBrandForCurrentSession(); | 623 google_util::chromeos::ClearBrandForCurrentSession(); |
| 624 } | 624 } |
| 625 // Init the RLZ library. | 625 // Init the RLZ library. |
| 626 int ping_delay = user_profile->GetPrefs()->GetInteger( | 626 int ping_delay = user_profile->GetPrefs()->GetInteger( |
| 627 first_run::GetPingDelayPrefName().c_str()); | 627 first_run::GetPingDelayPrefName().c_str()); |
| 628 // Negative ping delay means to send ping immediately after a first search is |
| 629 // recorded. |
| 628 RLZTracker::InitRlzFromProfileDelayed( | 630 RLZTracker::InitRlzFromProfileDelayed( |
| 629 user_profile, UserManager::Get()->IsCurrentUserNew(), ping_delay); | 631 user_profile, UserManager::Get()->IsCurrentUserNew(), |
| 632 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
| 630 if (delegate_) | 633 if (delegate_) |
| 631 delegate_->OnRlzInitialized(user_profile); | 634 delegate_->OnRlzInitialized(user_profile); |
| 632 #endif | 635 #endif |
| 633 } | 636 } |
| 634 | 637 |
| 635 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { | 638 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { |
| 636 std::string oauth1_token; | 639 std::string oauth1_token; |
| 637 std::string oauth1_secret; | 640 std::string oauth1_secret; |
| 638 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) | 641 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) |
| 639 return; | 642 return; |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1208 bool LoginUtils::IsWhitelisted(const std::string& username) { |
| 1206 CrosSettings* cros_settings = CrosSettings::Get(); | 1209 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1207 bool allow_new_user = false; | 1210 bool allow_new_user = false; |
| 1208 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1211 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 1209 if (allow_new_user) | 1212 if (allow_new_user) |
| 1210 return true; | 1213 return true; |
| 1211 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1214 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
| 1212 } | 1215 } |
| 1213 | 1216 |
| 1214 } // namespace chromeos | 1217 } // namespace chromeos |
| OLD | NEW |