Commit 245ea97f authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Add Incognito main frame navigations per session metric for non-iOS.

For better measurement of Incognito usage,
"Profile.Incognito.MainFrameNavigationsPerSession" metric is added to
record the activity length of Incognito sessions.

This metric will be added for iOS in a different CL.

Bug: 966747
Change-Id: I4d163f0ec603916949972d9dc290e4247a1125e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421821
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812105}
parent 4d502ffd
......@@ -215,12 +215,16 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
// other profile-related destroy notifications are dispatched.
ShutdownStoragePartitions();
// Store incognito lifetime histogram.
if (!IsGuestSession()) {
// Store incognito lifetime and navigations count histogram.
if (IsIncognitoProfile()) {
auto duration = base::Time::Now() - start_time_;
base::UmaHistogramCustomCounts(
"Profile.Incognito.Lifetime", duration.InMinutes(), 1,
base::TimeDelta::FromDays(28).InMinutes(), 100);
base::UmaHistogramCounts1000(
"Profile.Incognito.MainFrameNavigationsPerSession",
main_frame_navigations_);
}
}
......@@ -654,3 +658,7 @@ void OffTheRecordProfileImpl::UpdateDefaultZoomLevel() {
->OnDefaultZoomLevelChanged();
}
#endif // !defined(OS_ANDROID)
void OffTheRecordProfileImpl::RecordMainFrameNavigation() {
main_frame_navigations_++;
}
......@@ -127,6 +127,7 @@ class OffTheRecordProfileImpl : public Profile {
content::SharedCorsOriginAccessList* GetSharedCorsOriginAccessList() override;
content::NativeFileSystemPermissionContext*
GetNativeFileSystemPermissionContext() override;
void RecordMainFrameNavigation() override;
private:
#if !defined(OS_ANDROID)
......@@ -163,6 +164,9 @@ class OffTheRecordProfileImpl : public Profile {
std::unique_ptr<ProfileKey> key_;
base::FilePath last_selected_directory_;
// Number of main frame navigations done by this profile.
unsigned int main_frame_navigations_ = 0;
};
#endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IMPL_H_
......@@ -500,6 +500,8 @@ class Profile : public content::BrowserContext {
virtual void SetCreationTimeForTesting(base::Time creation_time) = 0;
virtual void RecordMainFrameNavigation() = 0;
protected:
void set_is_guest_profile(bool is_guest_profile) {
is_guest_profile_ = is_guest_profile;
......
......@@ -173,6 +173,7 @@ class ProfileImpl : public Profile {
#endif // defined(OS_CHROMEOS)
void SetCreationTimeForTesting(base::Time creation_time) override;
void RecordMainFrameNavigation() override {}
private:
#if defined(OS_CHROMEOS)
......
......@@ -86,6 +86,7 @@ void NavigationMetricsRecorder::DidFinishNavigation(
navigation_metrics::RecordMainFrameNavigation(
url, navigation_handle->IsSameDocument(), profile->IsOffTheRecord(),
ProfileMetrics::GetBrowserProfileType(profile));
profile->RecordMainFrameNavigation();
if (url.SchemeIsHTTPOrHTTPS() && !navigation_handle->IsSameDocument() &&
!navigation_handle->IsDownload() && !profile->IsOffTheRecord()) {
......
......@@ -367,6 +367,8 @@ class TestingProfile : public Profile {
PrefService* GetOffTheRecordPrefs() override;
void RecordMainFrameNavigation() override {}
void set_profile_name(const std::string& profile_name) {
profile_name_ = profile_name;
}
......
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