Commit 4cef55cc authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

GetBrowserStateType added to iOS browser state metrics.

A function is added to iOS browser state metrics to return browser
profile type given web state.

Bug: 966747
Change-Id: I3f00212bb875ba010ea98e3b9db71dd2fb082b57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1690577Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676385}
parent 063cdeef
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
#include <stddef.h> #include <stddef.h>
#include "components/profile_metrics/browser_profile_type.h"
#include "components/profile_metrics/counts.h" #include "components/profile_metrics/counts.h"
#include "ios/chrome/browser/browser_state/browser_state_info_cache.h" #include "ios/chrome/browser/browser_state/browser_state_info_cache.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h" #include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h"
#include "ios/web/public/browser_state.h"
bool CountBrowserStateInformation(ios::ChromeBrowserStateManager* manager, bool CountBrowserStateInformation(ios::ChromeBrowserStateManager* manager,
profile_metrics::Counts* counts) { profile_metrics::Counts* counts) {
...@@ -35,3 +37,10 @@ void LogNumberOfBrowserStates(ios::ChromeBrowserStateManager* manager) { ...@@ -35,3 +37,10 @@ void LogNumberOfBrowserStates(ios::ChromeBrowserStateManager* manager) {
CountBrowserStateInformation(manager, &counts); CountBrowserStateInformation(manager, &counts);
profile_metrics::LogProfileMetricsCounts(counts); profile_metrics::LogProfileMetricsCounts(counts);
} }
profile_metrics::BrowserProfileType GetBrowserStateType(
web::BrowserState* browser_state) {
return browser_state->IsOffTheRecord()
? profile_metrics::BrowserProfileType::kIncognito
: profile_metrics::BrowserProfileType::kRegular;
}
\ No newline at end of file
...@@ -11,6 +11,11 @@ class ChromeBrowserStateManager; ...@@ -11,6 +11,11 @@ class ChromeBrowserStateManager;
namespace profile_metrics { namespace profile_metrics {
struct Counts; struct Counts;
enum class BrowserProfileType;
} // namespace profile_metrics
namespace web {
class BrowserState;
} }
// Counts and returns summary information about the browser states currently in // Counts and returns summary information about the browser states currently in
...@@ -21,4 +26,7 @@ bool CountBrowserStateInformation(ios::ChromeBrowserStateManager* manager, ...@@ -21,4 +26,7 @@ bool CountBrowserStateInformation(ios::ChromeBrowserStateManager* manager,
void LogNumberOfBrowserStates(ios::ChromeBrowserStateManager* manager); void LogNumberOfBrowserStates(ios::ChromeBrowserStateManager* manager);
profile_metrics::BrowserProfileType GetBrowserStateType(
web::BrowserState* browser_state);
#endif // IOS_CHROME_BROWSER_BROWSER_STATE_METRICS_BROWSER_STATE_METRICS_H_ #endif // IOS_CHROME_BROWSER_BROWSER_STATE_METRICS_BROWSER_STATE_METRICS_H_
...@@ -67,6 +67,7 @@ source_set("tabs_internal") { ...@@ -67,6 +67,7 @@ source_set("tabs_internal") {
"//ios/chrome/browser/autofill", "//ios/chrome/browser/autofill",
"//ios/chrome/browser/autofill:autofill_internal", "//ios/chrome/browser/autofill:autofill_internal",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browser_state_metrics",
"//ios/chrome/browser/download", "//ios/chrome/browser/download",
"//ios/chrome/browser/download:features", "//ios/chrome/browser/download:features",
"//ios/chrome/browser/favicon", "//ios/chrome/browser/favicon",
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "components/sessions/core/tab_restore_service.h" #include "components/sessions/core/tab_restore_service.h"
#include "components/sessions/ios/ios_live_tab.h" #include "components/sessions/ios/ios_live_tab.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/browser_state_metrics/browser_state_metrics.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/chrome_url_util.h" #import "ios/chrome/browser/chrome_url_util.h"
#include "ios/chrome/browser/crash_loop_detection_util.h" #include "ios/chrome/browser/crash_loop_detection_util.h"
...@@ -207,15 +208,10 @@ void RecordMainFrameNavigationMetric(web::WebState* web_state) { ...@@ -207,15 +208,10 @@ void RecordMainFrameNavigationMetric(web::WebState* web_state) {
DCHECK(web_state->GetNavigationManager()); DCHECK(web_state->GetNavigationManager());
web::NavigationItem* item = web::NavigationItem* item =
web_state->GetNavigationManager()->GetLastCommittedItem(); web_state->GetNavigationManager()->GetLastCommittedItem();
// TODO(crbug.com/966747): Add a function in browser_state_metrics.h to return
// profile type.
profile_metrics::BrowserProfileType profile_type =
web_state->GetBrowserState()->IsOffTheRecord()
? profile_metrics::BrowserProfileType::kIncognito
: profile_metrics::BrowserProfileType::kRegular;
navigation_metrics::RecordMainFrameNavigation( navigation_metrics::RecordMainFrameNavigation(
item ? item->GetVirtualURL() : GURL::EmptyGURL(), true, item ? item->GetVirtualURL() : GURL::EmptyGURL(), true,
web_state->GetBrowserState()->IsOffTheRecord(), profile_type); web_state->GetBrowserState()->IsOffTheRecord(),
GetBrowserStateType(web_state->GetBrowserState()));
} }
} // anonymous namespace } // anonymous namespace
......
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