Commit 978e643d authored by Ramin Halavati's avatar Ramin Halavati Committed by Chromium LUCI CQ

Add metrics for signin in Ephemeral Guest profiles.

"Profile.EphemeralGuest.Signin" metric is recorded when user signs in
to or signs out from a GAIA account in an ephemeral Guest profile.

Bug: 1167474, 1148695
Change-Id: Ib0aa6660c2663083b740a6c393243a0058be78c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2632694
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Commit-Queue: Brian White <bcwhite@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845705}
parent ec759de0
...@@ -1437,6 +1437,8 @@ static_library("browser") { ...@@ -1437,6 +1437,8 @@ static_library("browser") {
"profiles/gaia_info_update_service_factory.h", "profiles/gaia_info_update_service_factory.h",
"profiles/guest_mode_policy_handler.cc", "profiles/guest_mode_policy_handler.cc",
"profiles/guest_mode_policy_handler.h", "profiles/guest_mode_policy_handler.h",
"profiles/guest_signin_observer_factory.cc",
"profiles/guest_signin_observer_factory.h",
"profiles/incognito_helpers.cc", "profiles/incognito_helpers.cc",
"profiles/incognito_helpers.h", "profiles/incognito_helpers.h",
"profiles/incognito_mode_policy_handler.cc", "profiles/incognito_mode_policy_handler.cc",
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include "chrome/browser/prefs/pref_metrics_service.h" #include "chrome/browser/prefs/pref_metrics_service.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h" #include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
#include "chrome/browser/profiles/gaia_info_update_service_factory.h" #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
#include "chrome/browser/profiles/guest_signin_observer_factory.h"
#include "chrome/browser/profiles/renderer_updater_factory.h" #include "chrome/browser/profiles/renderer_updater_factory.h"
#include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h"
#include "chrome/browser/search/suggestions/suggestions_service_factory.h" #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
...@@ -238,6 +239,7 @@ void ChromeBrowserMainExtraPartsProfiles:: ...@@ -238,6 +239,7 @@ void ChromeBrowserMainExtraPartsProfiles::
AboutSigninInternalsFactory::GetInstance(); AboutSigninInternalsFactory::GetInstance();
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
AccessContextAuditServiceFactory::GetInstance(); AccessContextAuditServiceFactory::GetInstance();
GuestSigninObserverFactory::GetInstance();
#endif #endif
AccountConsistencyModeManagerFactory::GetInstance(); AccountConsistencyModeManagerFactory::GetInstance();
AccountInvestigatorFactory::GetInstance(); AccountInvestigatorFactory::GetInstance();
......
// Copyright 2021 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/profiles/guest_signin_observer_factory.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/signin/public/identity_manager/identity_manager.h"
namespace {
class GuestSigninObserver : public KeyedService,
public signin::IdentityManager::Observer {
public:
explicit GuestSigninObserver(Profile* profile) : profile_(profile) {
IdentityManagerFactory::GetForProfile(profile)->AddObserver(this);
}
void Shutdown() override {
IdentityManagerFactory::GetForProfile(profile_)->RemoveObserver(this);
}
void OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event) override {
switch (event.GetEventTypeFor(signin::ConsentLevel::kNotRequired)) {
case signin::PrimaryAccountChangeEvent::Type::kSet:
base::UmaHistogramBoolean("Profile.EphemeralGuest.Signin", true);
break;
case signin::PrimaryAccountChangeEvent::Type::kCleared:
base::UmaHistogramBoolean("Profile.EphemeralGuest.Signin", false);
break;
case signin::PrimaryAccountChangeEvent::Type::kNone:
break;
}
}
private:
Profile* profile_;
};
} // namespace
// static
GuestSigninObserverFactory* GuestSigninObserverFactory::GetInstance() {
return base::Singleton<GuestSigninObserverFactory>::get();
}
GuestSigninObserverFactory::GuestSigninObserverFactory()
: BrowserContextKeyedServiceFactory(
"GuestSigninObserver",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(IdentityManagerFactory::GetInstance());
}
KeyedService* GuestSigninObserverFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile(Profile::FromBrowserContext(context));
if (profile->IsEphemeralGuestProfile())
return new GuestSigninObserver(profile);
return nullptr;
}
bool GuestSigninObserverFactory::ServiceIsCreatedWithBrowserContext() const {
return true;
}
// Copyright 2021 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.
#ifndef CHROME_BROWSER_PROFILES_GUEST_SIGNIN_OBSERVER_FACTORY_H_
#define CHROME_BROWSER_PROFILES_GUEST_SIGNIN_OBSERVER_FACTORY_H_
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
namespace base {
template <typename T>
struct DefaultSingletonTraits;
} // namespace base
// Factory for BrowserKeyedService GuestSigninObserver.
class GuestSigninObserverFactory : public BrowserContextKeyedServiceFactory {
public:
static GuestSigninObserverFactory* GetInstance();
private:
friend struct base::DefaultSingletonTraits<GuestSigninObserverFactory>;
GuestSigninObserverFactory();
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
bool ServiceIsCreatedWithBrowserContext() const override;
DISALLOW_COPY_AND_ASSIGN(GuestSigninObserverFactory);
};
#endif // CHROME_BROWSER_PROFILES_GUEST_SIGNIN_OBSERVER_FACTORY_H_
...@@ -197,6 +197,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -197,6 +197,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="Profile.EphemeralGuest.Signin" enum="BooleanProfileSignedIn"
expires_after="2022-02-02">
<owner>rhalavati@chromium.org</owner>
<owner>chrome-privacy-core@google.com</owner>
<summary>
This histogram records if user's sign-in state to a GAIA account in an
Ephemeral Guest profile is changed. This is recorded when user signs in and
when user signs out in an Ephemeral Guest profile.
</summary>
</histogram>
<histogram name="Profile.ExtensionSize" units="MB" expires_after="2018-08-30"> <histogram name="Profile.ExtensionSize" units="MB" expires_after="2018-08-30">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner> <owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary>Size of the extension cookies database.</summary> <summary>Size of the extension cookies database.</summary>
......
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