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 f552fe104174c9a2f384889a05331580e9c98524..12aa197865a11ae6bbeb430e67381197811a8bd0 100644 |
--- a/chrome/browser/chromeos/login/login_utils.cc |
+++ b/chrome/browser/chromeos/login/login_utils.cc |
@@ -11,6 +11,7 @@ |
#include "base/chromeos/chromeos_version.h" |
#include "base/command_line.h" |
#include "base/compiler_specific.h" |
+#include "base/debug/trace_event.h" |
Nikita (slow)
2012/12/11 13:02:54
I'm assuming tracing will be removed.
Ivan Korotkov
2012/12/11 15:44:53
Done. Takes 0.17 msec on Alex to stat() a file in
|
#include "base/file_path.h" |
#include "base/file_util.h" |
#include "base/location.h" |
@@ -47,6 +48,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" |
@@ -186,6 +188,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. |
@@ -298,6 +309,7 @@ class LoginUtilsImpl |
virtual void TransferDefaultAuthCache(Profile* default_profile, |
Profile* new_profile) OVERRIDE; |
virtual void StopBackgroundFetchers() OVERRIDE; |
+ virtual void InitRlzDelayed() OVERRIDE; |
// OAuth1TokenFetcher::Delegate overrides. |
void OnOAuth1AccessTokenAvailable(const std::string& token, |
@@ -655,13 +667,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(); |
Nikita (slow)
2012/12/11 13:02:54
makes sense to pass user_profile here and remove G
Ivan Korotkov
2012/12/11 15:44:53
Done.
|
// TODO(altimofeev): This pointer should probably never be NULL, but it looks |
// like LoginUtilsImpl::OnProfileCreated() may be getting called before |
@@ -673,6 +679,35 @@ void LoginUtilsImpl::OnProfileCreated( |
delegate_->OnProfilePrepared(user_profile); |
} |
+void LoginUtilsImpl::InitRlzDelayed() { |
+#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())); |
+ return; |
+ } |
+ { |
+ TRACE_EVENT_BEGIN0("RLZ", "LoginUtilsImpl::InitRlzDelayed//FlagFileCheck"); |
+ // We need to perform a synchronous check for a flag file here. Should not |
+ // be a problem since this only stat()s a file in home directory which by |
+ // now should have been cached by filesystem anyway. |
+ base::ThreadRestrictions::ScopedAllowIO allow_io; |
+ if (file_util::PathExists(GetRlzDisabledFlagPath())) { |
+ // Empty brand code effectively turns RLZ off. |
+ google_util::chromeos::SetTemporaryBrand(""); |
+ } |
+ TRACE_EVENT_END0("RLZ", "LoginUtilsImpl::InitRlzDelayed//FlagFileCheck"); |
+ } |
+ // Init the RLZ library. |
+ Profile* user_profile = ProfileManager::GetDefaultProfile(); |
+ 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; |