Skip to content

Commit

Permalink
Add Download and Setting per profile metrics for Incognito to iOS.
Browse files Browse the repository at this point in the history
This CL adds per profile type metrics for Downloads and Settings on
iOS. Although there are many metrics for settings and downloads,
there is not enough metric to interpret the usage of those
functionalities for specifically incognito mode.

By this CL;
- Download.OpenDownloads.PerProfieType metric is added to
record opening Downloads page for each profile type.
- Download.OpenDownloadsFromMenu.PerProfieType metric is added to
record opening Downloads page from pop-up menu for each profile type.
- Settings.OpenSettingsFromMenu.PerProfieType metric is added to
record opening Settings page from pop-up menu for each profile.

(cherry picked from commit f4c32cc)

Bug: 1179196
Change-Id: I4c4c49d328294b7da3147fa5249d4e3667f00ee1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2725092
Reviewed-by: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#859718}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2741584
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/4430@{#218}
Cr-Branched-From: e5ce7dc-refs/heads/master@{#857950}
  • Loading branch information
Side Yilmaz authored and Chromium LUCI CQ committed Mar 8, 2021
1 parent ae45299 commit a5bca6a
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 15 deletions.
2 changes: 2 additions & 0 deletions ios/chrome/browser/ui/browser_view/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ source_set("browser_view") {
"//components/image_fetcher/ios",
"//components/language/ios/browser",
"//components/omnibox/browser",
"//components/profile_metrics",
"//components/reading_list/core",
"//components/search_engines",
"//components/sessions",
Expand All @@ -42,6 +43,7 @@ source_set("browser_view") {
"//ios/chrome/browser/autofill:autofill_internal",
"//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browser_state_metrics",
"//ios/chrome/browser/crash_report",
"//ios/chrome/browser/download",
"//ios/chrome/browser/feature_engagement",
Expand Down
7 changes: 7 additions & 0 deletions ios/chrome/browser/ui/browser_view/browser_coordinator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

#include <memory>

#import "base/metrics/histogram_functions.h"
#include "base/scoped_observer.h"
#include "components/profile_metrics/browser_profile_type.h"
#import "ios/chrome/browser/app_launcher/app_launcher_abuse_detector.h"
#import "ios/chrome/browser/app_launcher/app_launcher_tab_helper.h"
#import "ios/chrome/browser/autofill/autofill_tab_helper.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/download/download_directory_util.h"
#import "ios/chrome/browser/download/external_app_util.h"
Expand Down Expand Up @@ -574,6 +577,10 @@ - (void)showDownloadsFolder {
[[UIApplication sharedApplication] openURL:URL
options:@{}
completionHandler:nil];

base::UmaHistogramEnumeration(
"Download.OpenDownloads.PerProfileType",
GetBrowserStateType(self.browser->GetBrowserState()));
}

- (void)showRecentTabs {
Expand Down
4 changes: 3 additions & 1 deletion ios/chrome/browser/ui/popup_menu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source_set("popup_menu") {
sources = [
"popup_menu_action_handler.h",
"popup_menu_action_handler.mm",
"popup_menu_action_handler_commands.h",
"popup_menu_action_handler_delegate.h",
"popup_menu_coordinator.h",
"popup_menu_coordinator.mm",
"popup_menu_mediator.h",
Expand Down Expand Up @@ -51,11 +51,13 @@ source_set("popup_menu") {
"//components/open_from_clipboard",
"//components/prefs",
"//components/prefs/ios",
"//components/profile_metrics",
"//components/translate/core/browser",
"//ios/chrome/app/strings",
"//ios/chrome/browser",
"//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browser_state_metrics",
"//ios/chrome/browser/feature_engagement",
"//ios/chrome/browser/find_in_page",
"//ios/chrome/browser/main:public",
Expand Down
4 changes: 2 additions & 2 deletions ios/chrome/browser/ui/popup_menu/popup_menu_action_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@protocol BrowserCommands;
@protocol FindInPageCommands;
@protocol LoadQueryCommands;
@protocol PopupMenuActionHandlerCommands;
@protocol PopupMenuActionHandlerDelegate;
@protocol TextZoomCommands;
class WebNavigationBrowserAgent;

Expand All @@ -25,7 +25,7 @@ class WebNavigationBrowserAgent;
@property(nonatomic, weak) UIViewController* baseViewController;

// Command handler.
@property(nonatomic, weak) id<PopupMenuActionHandlerCommands> commandHandler;
@property(nonatomic, weak) id<PopupMenuActionHandlerDelegate> delegate;

// Dispatcher.
@property(nonatomic, weak) id<ApplicationCommands,
Expand Down
10 changes: 6 additions & 4 deletions ios/chrome/browser/ui/popup_menu/popup_menu_action_handler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#import "ios/chrome/browser/ui/commands/load_query_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/commands/text_zoom_commands.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_action_handler_commands.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_action_handler_delegate.h"
#import "ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h"
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_table_view_controller.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h"
Expand All @@ -42,7 +42,7 @@ - (void)popupMenuTableViewController:(PopupMenuTableViewController*)sender
didSelectItem:(TableViewItem<PopupMenuItem>*)item
origin:(CGPoint)origin {
DCHECK(self.dispatcher);
DCHECK(self.commandHandler);
DCHECK(self.delegate);

PopupMenuAction identifier = item.actionIdentifier;
switch (identifier) {
Expand All @@ -68,7 +68,7 @@ - (void)popupMenuTableViewController:(PopupMenuTableViewController*)sender
break;
case PopupMenuActionReadLater:
RecordAction(UserMetricsAction("MobileMenuReadLater"));
[self.commandHandler readPageLater];
[self.delegate readPageLater];
break;
case PopupMenuActionPageBookmark:
RecordAction(UserMetricsAction("MobileMenuAddToBookmarks"));
Expand Down Expand Up @@ -110,6 +110,7 @@ - (void)popupMenuTableViewController:(PopupMenuTableViewController*)sender
case PopupMenuActionOpenDownloads:
RecordAction(
UserMetricsAction("MobileDownloadFolderUIShownFromToolsMenu"));
[self.delegate recordDownloadsMetricsPerProfile];
[self.dispatcher showDownloadsFolder];
break;
case PopupMenuActionTextZoom:
Expand Down Expand Up @@ -144,6 +145,7 @@ - (void)popupMenuTableViewController:(PopupMenuTableViewController*)sender
break;
case PopupMenuActionSettings:
RecordAction(UserMetricsAction("MobileMenuSettings"));
[self.delegate recordSettingsMetricsPerProfile];
[self.dispatcher showSettingsFromViewController:self.baseViewController];
break;
case PopupMenuActionCloseTab:
Expand All @@ -152,7 +154,7 @@ - (void)popupMenuTableViewController:(PopupMenuTableViewController*)sender
break;
case PopupMenuActionNavigate:
// No metrics for this item.
[self.commandHandler navigateToPageForItem:item];
[self.delegate navigateToPageForItem:item];
break;
case PopupMenuActionVoiceSearch:
RecordAction(UserMetricsAction("MobileMenuVoiceSearch"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_UI_POPUP_MENU_POPUP_MENU_ACTION_HANDLER_COMMANDS_H_
#define IOS_CHROME_BROWSER_UI_POPUP_MENU_POPUP_MENU_ACTION_HANDLER_COMMANDS_H_
#ifndef IOS_CHROME_BROWSER_UI_POPUP_MENU_POPUP_MENU_ACTION_HANDLER_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_POPUP_MENU_POPUP_MENU_ACTION_HANDLER_DELEGATE_H_

#import <UIKit/UIKit.h>

@protocol PopupMenuItem;
@class TableViewItem;

// Delegate for the PopupMenuActionHandler.
@protocol PopupMenuActionHandlerCommands
@protocol PopupMenuActionHandlerDelegate
// Adds the current page to the reading list.
- (void)readPageLater;
// Navigates to the page associated with |item|.
- (void)navigateToPageForItem:(TableViewItem<PopupMenuItem>*)item;
// Records open settings metric per profile type.
- (void)recordSettingsMetricsPerProfile;
// Records open downloads metric per profile type.
- (void)recordDownloadsMetricsPerProfile;
@end

#endif // IOS_CHROME_BROWSER_UI_POPUP_MENU_POPUP_MENU_ACTION_HANDLER_COMMANDS_H_
#endif // IOS_CHROME_BROWSER_UI_POPUP_MENU_POPUP_MENU_ACTION_HANDLER_DELEGATE_H_
2 changes: 1 addition & 1 deletion ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ - (void)presentPopupOfType:(PopupMenuType)type
static_cast<id<ApplicationCommands, BrowserCommands, FindInPageCommands,
LoadQueryCommands, TextZoomCommands>>(
self.browser->GetCommandDispatcher());
self.actionHandler.commandHandler = self.mediator;
self.actionHandler.delegate = self.mediator;
self.actionHandler.navigationAgent =
WebNavigationBrowserAgent::FromBrowser(self.browser);
tableViewController.delegate = self.actionHandler;
Expand Down
4 changes: 2 additions & 2 deletions ios/chrome/browser/ui/popup_menu/popup_menu_mediator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>

#import "ios/chrome/browser/ui/browser_container/browser_container_consumer.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_action_handler_commands.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_action_handler_delegate.h"
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_ui_updating.h"

namespace bookmarks {
Expand All @@ -29,7 +29,7 @@ class BrowserPolicyConnectorIOS;
// Mediator for the popup menu. This object is in charge of creating and
// updating the items of the popup menu.
@interface PopupMenuMediator
: NSObject <BrowserContainerConsumer, PopupMenuActionHandlerCommands>
: NSObject <BrowserContainerConsumer, PopupMenuActionHandlerDelegate>

// Initializes the mediator with a |type| of popup menu, whether it
// |isIncognito|, a |readingListModel| used to display the badge for the reading
Expand Down
20 changes: 19 additions & 1 deletion ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/feature_list.h"
#import "base/ios/ios_util.h"
#include "base/mac/foundation_util.h"
#import "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h"
#include "components/bookmarks/browser/bookmark_model.h"
Expand All @@ -20,6 +21,7 @@
#import "components/prefs/ios/pref_observer_bridge.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/browser/translate_prefs.h"
#import "ios/chrome/browser/browser_state/chrome_browser_state.h"
Expand Down Expand Up @@ -532,7 +534,7 @@ - (void)setPrefService:(PrefService*)prefService {
bookmarks::prefs::kEditBookmarksEnabled, _prefChangeRegistrar.get());
}

#pragma mark - PopupMenuActionHandlerCommands
#pragma mark - PopupMenuActionHandlerDelegate

- (void)readPageLater {
if (!self.webState)
Expand Down Expand Up @@ -565,6 +567,22 @@ - (void)navigateToPageForItem:(TableViewItem<PopupMenuItem>*)item {
self.webState->GetNavigationManager()->GoToIndex(index);
}

- (void)recordSettingsMetricsPerProfile {
profile_metrics::BrowserProfileType type =
_isIncognito ? profile_metrics::BrowserProfileType::kIncognito
: profile_metrics::BrowserProfileType::kRegular;
base::UmaHistogramEnumeration("Settings.OpenSettingsFromMenu.PerProfileType",
type);
}

- (void)recordDownloadsMetricsPerProfile {
profile_metrics::BrowserProfileType type =
_isIncognito ? profile_metrics::BrowserProfileType::kIncognito
: profile_metrics::BrowserProfileType::kRegular;
base::UmaHistogramEnumeration("Download.OpenDownloadsFromMenu.PerProfileType",
type);
}

#pragma mark - IOSLanguageDetectionTabHelperObserving

- (void)iOSLanguageDetectionTabHelper:
Expand Down

0 comments on commit a5bca6a

Please sign in to comment.