| Index: chrome/browser/chromeos/login/login_utils.cc
|
| diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
|
| index ecd0c92479057d6efff75a769cc9674e5763ea44..2625bbc60e2220604204506873125972d56a312f 100644
|
| --- a/chrome/browser/chromeos/login/login_utils.cc
|
| +++ b/chrome/browser/chromeos/login/login_utils.cc
|
| @@ -22,7 +22,8 @@
|
| #include "base/string_util.h"
|
| #include "base/stringprintf.h"
|
| #include "base/synchronization/lock.h"
|
| -#include "base/threading/thread_restrictions.h"
|
| +#include "base/task_runner_util.h"
|
| +#include "base/threading/worker_pool.h"
|
| #include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "cc/switches.h"
|
| @@ -48,6 +49,7 @@
|
| #include "chrome/browser/chromeos/settings/cros_settings_names.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/first_run/first_run.h"
|
| +#include "chrome/browser/google/google_util_chromeos.h"
|
| #include "chrome/browser/net/chrome_url_request_context.h"
|
| #include "chrome/browser/net/preconnect.h"
|
| #include "chrome/browser/policy/browser_policy_connector.h"
|
| @@ -187,6 +189,15 @@ void TransferDefaultAuthCacheOnIOThread(
|
| http_transaction_factory()->GetSession()->http_auth_cache());
|
| }
|
|
|
| +#if defined(ENABLE_RLZ)
|
| +// Flag file that disables RLZ tracking, when present.
|
| +const char kRLZDisabledFlagName[] = FILE_PATH_LITERAL(".rlz_disabled");
|
| +
|
| +FilePath GetRlzDisabledFlagPath() {
|
| + return file_util::GetHomeDir().Append(kRLZDisabledFlagName);
|
| +}
|
| +#endif
|
| +
|
| } // namespace
|
|
|
| // Used to request a restart to switch to the guest mode.
|
| @@ -299,6 +310,7 @@ class LoginUtilsImpl
|
| virtual void TransferDefaultAuthCache(Profile* default_profile,
|
| Profile* new_profile) OVERRIDE;
|
| virtual void StopBackgroundFetchers() OVERRIDE;
|
| + virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE;
|
|
|
| // OAuth1TokenFetcher::Delegate overrides.
|
| void OnOAuth1AccessTokenAvailable(const std::string& token,
|
| @@ -369,6 +381,9 @@ class LoginUtilsImpl
|
| void OnProfileCreated(Profile* profile,
|
| Profile::CreateStatus status);
|
|
|
| + // Initializes RLZ. If |disabled| is true, financial pings are turned off.
|
| + void InitRlz(Profile* user_profile, bool disabled);
|
| +
|
| std::string password_;
|
| bool pending_requests_;
|
| bool using_oauth_;
|
| @@ -656,13 +671,7 @@ void LoginUtilsImpl::OnProfileCreated(
|
| content::NotificationService::AllSources(),
|
| content::Details<Profile>(user_profile));
|
|
|
| -#if defined(ENABLE_RLZ)
|
| - // Init the RLZ library.
|
| - int ping_delay = user_profile->GetPrefs()->GetInteger(
|
| - first_run::GetPingDelayPrefName().c_str());
|
| - RLZTracker::InitRlzFromProfileDelayed(
|
| - user_profile, UserManager::Get()->IsCurrentUserNew(), ping_delay);
|
| -#endif
|
| + InitRlzDelayed(user_profile);
|
|
|
| // TODO(altimofeev): This pointer should probably never be NULL, but it looks
|
| // like LoginUtilsImpl::OnProfileCreated() may be getting called before
|
| @@ -674,6 +683,36 @@ void LoginUtilsImpl::OnProfileCreated(
|
| delegate_->OnProfilePrepared(user_profile);
|
| }
|
|
|
| +void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) {
|
| +#if defined(ENABLE_RLZ)
|
| + if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) {
|
| + // Read brand code asynchronously from an OEM file and repost ourselves.
|
| + google_util::chromeos::SetBrandFromFile(
|
| + base::Bind(&LoginUtilsImpl::InitRlzDelayed, AsWeakPtr(), user_profile));
|
| + return;
|
| + }
|
| + base::PostTaskAndReplyWithResult(
|
| + base::WorkerPool::GetTaskRunner(false /* task_is_slow */),
|
| + FROM_HERE,
|
| + base::Bind(&file_util::PathExists, GetRlzDisabledFlagPath()),
|
| + base::Bind(&LoginUtilsImpl::InitRlz, AsWeakPtr(), user_profile));
|
| +#endif
|
| +}
|
| +
|
| +void LoginUtilsImpl::InitRlz(Profile* user_profile, bool disabled) {
|
| +#if defined(ENABLE_RLZ)
|
| + if (disabled) {
|
| + // Empty brand code turns financial pings off.
|
| + google_util::chromeos::SetBrandForCurrentSession(std::string());
|
| + }
|
| + // Init the RLZ library.
|
| + int ping_delay = user_profile->GetPrefs()->GetInteger(
|
| + first_run::GetPingDelayPrefName().c_str());
|
| + RLZTracker::InitRlzFromProfileDelayed(
|
| + user_profile, UserManager::Get()->IsCurrentUserNew(), ping_delay);
|
| +#endif
|
| +}
|
| +
|
| void LoginUtilsImpl::StartTokenServices(Profile* user_profile) {
|
| std::string oauth1_token;
|
| std::string oauth1_secret;
|
|
|