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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 29 matching lines...) Expand all
40 #include "chrome/browser/chromeos/login/oauth1_token_fetcher.h" 40 #include "chrome/browser/chromeos/login/oauth1_token_fetcher.h"
41 #include "chrome/browser/chromeos/login/oauth_login_verifier.h" 41 #include "chrome/browser/chromeos/login/oauth_login_verifier.h"
42 #include "chrome/browser/chromeos/login/parallel_authenticator.h" 42 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
43 #include "chrome/browser/chromeos/login/policy_oauth_fetcher.h" 43 #include "chrome/browser/chromeos/login/policy_oauth_fetcher.h"
44 #include "chrome/browser/chromeos/login/screen_locker.h" 44 #include "chrome/browser/chromeos/login/screen_locker.h"
45 #include "chrome/browser/chromeos/login/user_manager.h" 45 #include "chrome/browser/chromeos/login/user_manager.h"
46 #include "chrome/browser/chromeos/settings/cros_settings.h" 46 #include "chrome/browser/chromeos/settings/cros_settings.h"
47 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 47 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
48 #include "chrome/browser/extensions/extension_service.h" 48 #include "chrome/browser/extensions/extension_service.h"
49 #include "chrome/browser/first_run/first_run.h" 49 #include "chrome/browser/first_run/first_run.h"
50 #include "chrome/browser/google/google_util_chromeos.h"
50 #include "chrome/browser/net/chrome_url_request_context.h" 51 #include "chrome/browser/net/chrome_url_request_context.h"
51 #include "chrome/browser/net/preconnect.h" 52 #include "chrome/browser/net/preconnect.h"
52 #include "chrome/browser/policy/browser_policy_connector.h" 53 #include "chrome/browser/policy/browser_policy_connector.h"
53 #include "chrome/browser/policy/cloud_policy_client.h" 54 #include "chrome/browser/policy/cloud_policy_client.h"
54 #include "chrome/browser/policy/cloud_policy_service.h" 55 #include "chrome/browser/policy/cloud_policy_service.h"
55 #include "chrome/browser/policy/network_configuration_updater.h" 56 #include "chrome/browser/policy/network_configuration_updater.h"
56 #include "chrome/browser/prefs/pref_service.h" 57 #include "chrome/browser/prefs/pref_service.h"
57 #include "chrome/browser/profiles/profile.h" 58 #include "chrome/browser/profiles/profile.h"
58 #include "chrome/browser/profiles/profile_manager.h" 59 #include "chrome/browser/profiles/profile_manager.h"
59 #include "chrome/browser/rlz/rlz.h" 60 #include "chrome/browser/rlz/rlz.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 void TransferDefaultAuthCacheOnIOThread( 180 void TransferDefaultAuthCacheOnIOThread(
180 net::URLRequestContextGetter* auth_context, 181 net::URLRequestContextGetter* auth_context,
181 net::URLRequestContextGetter* new_context) { 182 net::URLRequestContextGetter* new_context) {
182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
183 net::HttpAuthCache* new_cache = new_context->GetURLRequestContext()-> 184 net::HttpAuthCache* new_cache = new_context->GetURLRequestContext()->
184 http_transaction_factory()->GetSession()->http_auth_cache(); 185 http_transaction_factory()->GetSession()->http_auth_cache();
185 new_cache->UpdateAllFrom(*auth_context->GetURLRequestContext()-> 186 new_cache->UpdateAllFrom(*auth_context->GetURLRequestContext()->
186 http_transaction_factory()->GetSession()->http_auth_cache()); 187 http_transaction_factory()->GetSession()->http_auth_cache());
187 } 188 }
188 189
190 #if defined(ENABLE_RLZ)
191 // Flag file that disables RLZ tracking, when present.
192 const char kRLZDisabledFlagName[] = FILE_PATH_LITERAL(".rlz_disabled");
193
194 FilePath GetRlzDisabledFlagPath() {
195 return file_util::GetHomeDir().Append(kRLZDisabledFlagName);
196 }
197 #endif
198
189 } // namespace 199 } // namespace
190 200
191 // Used to request a restart to switch to the guest mode. 201 // Used to request a restart to switch to the guest mode.
192 class JobRestartRequest 202 class JobRestartRequest
193 : public base::RefCountedThreadSafe<JobRestartRequest> { 203 : public base::RefCountedThreadSafe<JobRestartRequest> {
194 public: 204 public:
195 JobRestartRequest(int pid, const std::string& command_line) 205 JobRestartRequest(int pid, const std::string& command_line)
196 : pid_(pid), 206 : pid_(pid),
197 command_line_(command_line), 207 command_line_(command_line),
198 local_state_(g_browser_process->local_state()) { 208 local_state_(g_browser_process->local_state()) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 virtual void StartTokenServices(Profile* user_profile) OVERRIDE; 301 virtual void StartTokenServices(Profile* user_profile) OVERRIDE;
292 virtual void StartSignedInServices( 302 virtual void StartSignedInServices(
293 Profile* profile, 303 Profile* profile,
294 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; 304 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE;
295 virtual void TransferDefaultCookiesAndServerBoundCerts( 305 virtual void TransferDefaultCookiesAndServerBoundCerts(
296 Profile* default_profile, 306 Profile* default_profile,
297 Profile* new_profile) OVERRIDE; 307 Profile* new_profile) OVERRIDE;
298 virtual void TransferDefaultAuthCache(Profile* default_profile, 308 virtual void TransferDefaultAuthCache(Profile* default_profile,
299 Profile* new_profile) OVERRIDE; 309 Profile* new_profile) OVERRIDE;
300 virtual void StopBackgroundFetchers() OVERRIDE; 310 virtual void StopBackgroundFetchers() OVERRIDE;
311 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE;
301 312
302 // OAuth1TokenFetcher::Delegate overrides. 313 // OAuth1TokenFetcher::Delegate overrides.
303 void OnOAuth1AccessTokenAvailable(const std::string& token, 314 void OnOAuth1AccessTokenAvailable(const std::string& token,
304 const std::string& secret) OVERRIDE; 315 const std::string& secret) OVERRIDE;
305 void OnOAuth1AccessTokenFetchFailed() OVERRIDE; 316 void OnOAuth1AccessTokenFetchFailed() OVERRIDE;
306 317
307 // OAuthLoginVerifier::Delegate overrides. 318 // OAuthLoginVerifier::Delegate overrides.
308 virtual void OnOAuthVerificationSucceeded(const std::string& user_name, 319 virtual void OnOAuthVerificationSucceeded(const std::string& user_name,
309 const std::string& sid, 320 const std::string& sid,
310 const std::string& lsid, 321 const std::string& lsid,
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 659
649 user_profile->OnLogin(); 660 user_profile->OnLogin();
650 661
651 // Send the notification before creating the browser so additional objects 662 // Send the notification before creating the browser so additional objects
652 // that need the profile (e.g. the launcher) can be created first. 663 // that need the profile (e.g. the launcher) can be created first.
653 content::NotificationService::current()->Notify( 664 content::NotificationService::current()->Notify(
654 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 665 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
655 content::NotificationService::AllSources(), 666 content::NotificationService::AllSources(),
656 content::Details<Profile>(user_profile)); 667 content::Details<Profile>(user_profile));
657 668
658 #if defined(ENABLE_RLZ) 669 InitRlzDelayed(user_profile);
659 // Init the RLZ library.
660 int ping_delay = user_profile->GetPrefs()->GetInteger(
661 first_run::GetPingDelayPrefName().c_str());
662 RLZTracker::InitRlzFromProfileDelayed(
663 user_profile, UserManager::Get()->IsCurrentUserNew(), ping_delay);
664 #endif
665 670
666 // TODO(altimofeev): This pointer should probably never be NULL, but it looks 671 // TODO(altimofeev): This pointer should probably never be NULL, but it looks
667 // like LoginUtilsImpl::OnProfileCreated() may be getting called before 672 // like LoginUtilsImpl::OnProfileCreated() may be getting called before
668 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed 673 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed
669 // during shutdown in tests -- see http://crosbug.com/18269. Replace this 674 // during shutdown in tests -- see http://crosbug.com/18269. Replace this
670 // 'if' statement with a CHECK(delegate_) once the underlying issue is 675 // 'if' statement with a CHECK(delegate_) once the underlying issue is
671 // resolved. 676 // resolved.
672 if (delegate_) 677 if (delegate_)
673 delegate_->OnProfilePrepared(user_profile); 678 delegate_->OnProfilePrepared(user_profile);
674 } 679 }
675 680
681 void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) {
682 #if defined(ENABLE_RLZ)
683 if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) {
684 // Read brand code asynchronously from an OEM file and repost ourselves.
685 google_util::chromeos::SetBrandFromFile(
686 base::Bind(&LoginUtilsImpl::InitRlzDelayed, AsWeakPtr(), user_profile));
687 return;
688 }
689 {
690 // We need to perform a synchronous check for a flag file here. Should not
691 // be a problem since this only stat()s a file in home directory which by
692 // now should have been cached by filesystem anyway.
693 base::ThreadRestrictions::ScopedAllowIO allow_io;
694 if (file_util::PathExists(GetRlzDisabledFlagPath())) {
695 // Empty brand code effectively turns RLZ off.
696 google_util::chromeos::SetTemporaryBrand("");
697 }
698 }
699 // Init the RLZ library.
700 int ping_delay = user_profile->GetPrefs()->GetInteger(
701 first_run::GetPingDelayPrefName().c_str());
702 RLZTracker::InitRlzFromProfileDelayed(
703 user_profile, UserManager::Get()->IsCurrentUserNew(), ping_delay);
704 #endif
705 }
706
676 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { 707 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) {
677 std::string oauth1_token; 708 std::string oauth1_token;
678 std::string oauth1_secret; 709 std::string oauth1_secret;
679 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) 710 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret))
680 return; 711 return;
681 712
682 FetchSecondaryTokens(user_profile->GetOffTheRecordProfile(), 713 FetchSecondaryTokens(user_profile->GetOffTheRecordProfile(),
683 oauth1_token, oauth1_secret); 714 oauth1_token, oauth1_secret);
684 } 715 }
685 716
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 bool LoginUtils::IsWhitelisted(const std::string& username) { 1301 bool LoginUtils::IsWhitelisted(const std::string& username) {
1271 CrosSettings* cros_settings = CrosSettings::Get(); 1302 CrosSettings* cros_settings = CrosSettings::Get();
1272 bool allow_new_user = false; 1303 bool allow_new_user = false;
1273 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 1304 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
1274 if (allow_new_user) 1305 if (allow_new_user)
1275 return true; 1306 return true;
1276 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 1307 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
1277 } 1308 }
1278 1309
1279 } // namespace chromeos 1310 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698