Commit 107af46b authored by atwilson@chromium.org's avatar atwilson@chromium.org

Now CHECKs to make sure we log out before clearing the token db

BUG=121755
TEST=signin/signout, should get no crashes


Review URL: http://codereview.chromium.org/10213013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133969 0039d316-1c4b-4281-b951-d872f2087c98
parent aa976446
...@@ -56,6 +56,13 @@ void SigninManager::Initialize(Profile* profile) { ...@@ -56,6 +56,13 @@ void SigninManager::Initialize(Profile* profile) {
DCHECK(!IsInitialized()); DCHECK(!IsInitialized());
profile_ = profile; profile_ = profile;
// If the user is clearing the token service from the command line, then
// clear their login info also (not valid to be logged in without any
// tokens).
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch(switches::kClearTokenService))
profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
std::string user = profile_->GetPrefs()->GetString( std::string user = profile_->GetPrefs()->GetString(
prefs::kGoogleServicesUsername); prefs::kGoogleServicesUsername);
if (!user.empty()) if (!user.empty())
......
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/gaia_auth_fetcher.h" #include "chrome/common/net/gaia/gaia_auth_fetcher.h"
#include "chrome/common/net/gaia/gaia_constants.h" #include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
...@@ -66,7 +68,10 @@ void TokenService::Initialize(const char* const source, ...@@ -66,7 +68,10 @@ void TokenService::Initialize(const char* const source,
source_ = std::string(source); source_ = std::string(source);
CommandLine* cmd_line = CommandLine::ForCurrentProcess(); CommandLine* cmd_line = CommandLine::ForCurrentProcess();
// Allow the token service to be cleared from the command line. // Allow the token service to be cleared from the command line. We rely on
// SigninManager::Initialize() being called to clear out the
// kGoogleServicesUsername pref before we call EraseTokensFromDB() as
// otherwise the system would be in an invalid state.
if (cmd_line->HasSwitch(switches::kClearTokenService)) if (cmd_line->HasSwitch(switches::kClearTokenService))
EraseTokensFromDB(); EraseTokensFromDB();
...@@ -133,6 +138,13 @@ void TokenService::SaveAuthTokenToDB(const std::string& service, ...@@ -133,6 +138,13 @@ void TokenService::SaveAuthTokenToDB(const std::string& service,
void TokenService::EraseTokensFromDB() { void TokenService::EraseTokensFromDB() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Try to track down http://crbug.com/121755 - we should never clear the
// token DB while we're still logged in.
if (profile_) {
std::string user = profile_->GetPrefs()->GetString(
prefs::kGoogleServicesUsername);
CHECK(user.empty());
}
if (web_data_service_.get()) if (web_data_service_.get())
web_data_service_->RemoveAllTokens(); web_data_service_->RemoveAllTokens();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment