Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Unified Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 11506006: [cros] RLZ tracking can be turned off via a flag file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..445427e8a34a45517aeae616a278d770ef9149d8 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -47,6 +47,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 +187,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 +308,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,
@@ -655,13 +666,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
@@ -673,6 +678,32 @@ 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;
+ }
+ {
+ // 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("");
+ }
+ }
+ // 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;

Powered by Google App Engine
This is Rietveld 408576698