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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // Callback for asynchronous profile creation. | 305 // Callback for asynchronous profile creation. |
306 void OnProfileCreated(Profile* profile, | 306 void OnProfileCreated(Profile* profile, |
307 Profile::CreateStatus status); | 307 Profile::CreateStatus status); |
308 | 308 |
309 // Finalized profile preparation. | 309 // Finalized profile preparation. |
310 void FinalizePrepareProfile(Profile* user_profile); | 310 void FinalizePrepareProfile(Profile* user_profile); |
311 | 311 |
312 // Restores GAIA auth cookies for the created profile. | 312 // Restores GAIA auth cookies for the created profile. |
313 void RestoreAuthCookies(Profile* user_profile); | 313 void RestoreAuthCookies(Profile* user_profile); |
314 | 314 |
315 // Initializes RLZ. If |disabled| is true, financial pings are turned off. | 315 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
316 void InitRlz(Profile* user_profile, bool disabled); | 316 void InitRlz(Profile* user_profile, bool disabled); |
317 | 317 |
318 std::string password_; | 318 std::string password_; |
319 bool pending_requests_; | 319 bool pending_requests_; |
320 bool using_oauth_; | 320 bool using_oauth_; |
321 // True if the authenrication profile's cookie jar should contain | 321 // True if the authenrication profile's cookie jar should contain |
322 // authentication cookies from the authentication extension log in flow. | 322 // authentication cookies from the authentication extension log in flow. |
323 bool has_web_auth_cookies_; | 323 bool has_web_auth_cookies_; |
324 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). | 324 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). |
325 scoped_refptr<Authenticator> authenticator_; | 325 scoped_refptr<Authenticator> authenticator_; |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 | 639 |
640 void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) { | 640 void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) { |
641 #if defined(ENABLE_RLZ) | 641 #if defined(ENABLE_RLZ) |
642 if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) { | 642 if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) { |
643 // Read brand code asynchronously from an OEM file and repost ourselves. | 643 // Read brand code asynchronously from an OEM file and repost ourselves. |
644 google_util::chromeos::SetBrandFromFile( | 644 google_util::chromeos::SetBrandFromFile( |
645 base::Bind(&LoginUtilsImpl::InitRlzDelayed, AsWeakPtr(), user_profile)); | 645 base::Bind(&LoginUtilsImpl::InitRlzDelayed, AsWeakPtr(), user_profile)); |
646 return; | 646 return; |
647 } | 647 } |
648 base::PostTaskAndReplyWithResult( | 648 base::PostTaskAndReplyWithResult( |
649 base::WorkerPool::GetTaskRunner(false /* task_is_slow */), | 649 base::WorkerPool::GetTaskRunner(false), |
650 FROM_HERE, | 650 FROM_HERE, |
651 base::Bind(&file_util::PathExists, GetRlzDisabledFlagPath()), | 651 base::Bind(&file_util::PathExists, GetRlzDisabledFlagPath()), |
652 base::Bind(&LoginUtilsImpl::InitRlz, AsWeakPtr(), user_profile)); | 652 base::Bind(&LoginUtilsImpl::InitRlz, AsWeakPtr(), user_profile)); |
653 #endif | 653 #endif |
654 } | 654 } |
655 | 655 |
656 void LoginUtilsImpl::InitRlz(Profile* user_profile, bool disabled) { | 656 void LoginUtilsImpl::InitRlz(Profile* user_profile, bool disabled) { |
657 #if defined(ENABLE_RLZ) | 657 #if defined(ENABLE_RLZ) |
658 PrefService* local_state = g_browser_process->local_state(); | 658 PrefService* local_state = g_browser_process->local_state(); |
659 if (disabled) { | 659 if (disabled) { |
660 // Empty brand code turns financial pings off. | 660 // Empty brand code means an organic install (no RLZ pings are sent). |
661 google_util::chromeos::ClearBrandForCurrentSession(); | 661 google_util::chromeos::ClearBrandForCurrentSession(); |
662 } | 662 } |
663 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) { | 663 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) { |
664 // When switching to RLZ enabled/disabled state, clear all recorded events. | 664 // When switching to RLZ enabled/disabled state, clear all recorded events. |
665 RLZTracker::ClearRlzState(); | 665 RLZTracker::ClearRlzState(); |
666 local_state->SetBoolean(prefs::kRLZDisabled, disabled); | 666 local_state->SetBoolean(prefs::kRLZDisabled, disabled); |
667 } | 667 } |
668 // Init the RLZ library. | 668 // Init the RLZ library. |
669 int ping_delay = user_profile->GetPrefs()->GetInteger( | 669 int ping_delay = user_profile->GetPrefs()->GetInteger( |
670 first_run::GetPingDelayPrefName().c_str()); | 670 first_run::GetPingDelayPrefName().c_str()); |
| 671 // Negative ping delay means to send ping immediately after a first search is |
| 672 // recorded. |
671 RLZTracker::InitRlzFromProfileDelayed( | 673 RLZTracker::InitRlzFromProfileDelayed( |
672 user_profile, UserManager::Get()->IsCurrentUserNew(), ping_delay); | 674 user_profile, UserManager::Get()->IsCurrentUserNew(), |
| 675 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
673 if (delegate_) | 676 if (delegate_) |
674 delegate_->OnRlzInitialized(user_profile); | 677 delegate_->OnRlzInitialized(user_profile); |
675 #endif | 678 #endif |
676 } | 679 } |
677 | 680 |
678 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { | 681 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { |
679 std::string oauth1_token; | 682 std::string oauth1_token; |
680 std::string oauth1_secret; | 683 std::string oauth1_secret; |
681 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) | 684 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) |
682 return; | 685 return; |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1253 bool LoginUtils::IsWhitelisted(const std::string& username) { |
1251 CrosSettings* cros_settings = CrosSettings::Get(); | 1254 CrosSettings* cros_settings = CrosSettings::Get(); |
1252 bool allow_new_user = false; | 1255 bool allow_new_user = false; |
1253 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1256 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1254 if (allow_new_user) | 1257 if (allow_new_user) |
1255 return true; | 1258 return true; |
1256 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1259 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
1257 } | 1260 } |
1258 | 1261 |
1259 } // namespace chromeos | 1262 } // namespace chromeos |
OLD | NEW |