blob: db560b21a696eca6c3492a8f87f6fc587357c2ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/logout_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/signin/public/base/signin_metrics.h"
#include "components/signin/public/identity_manager/accounts_mutator.h"
#include "components/signin/public/identity_manager/identity_manager.h"
WEB_CONTENTS_USER_DATA_KEY_IMPL(LogoutTabHelper);
LogoutTabHelper::LogoutTabHelper(content::WebContents* web_contents)
: content::WebContentsUserData<LogoutTabHelper>(*web_contents),
content::WebContentsObserver(web_contents) {}
LogoutTabHelper::~LogoutTabHelper() = default;
void LogoutTabHelper::PrimaryPageChanged(content::Page& page) {
if (page.GetMainDocument().IsErrorDocument()) {
// Failed to load the logout page, fallback to local signout.
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
IdentityManagerFactory::GetForProfile(profile)
->GetAccountsMutator()
->RemoveAllAccounts(signin_metrics::SourceForRefreshTokenOperation::
kLogoutTabHelper_PrimaryPageChanged);
}
// Delete this.
web_contents()->RemoveUserData(UserDataKey());
}
|