[iOS] Notify FeatureEngagementTracker of Chrome Opened Event

Desktop / Chromium - Cooper Knaak [google.com] - 13 July 2017 22:42 EDT

This CL sends a notification to the FeatureEngagementTracker when the user opens Chrome both from a cold start and a warm start.

Warm starts include backgrounding the app and reopening it, launching another app from Chrome and returning to it, and locking then unlocking the screen when Chrome is in the foreground.

-[AppState applicationWillEnterForeground: ... ] handles the warm start event because it is called whenever the app is taken out of the background (except on the initial launch, which is a cold start).

The cold start event must occur in the startup flow, a complex process, so finding a good place for the notification is tricky. It needs to be called exactly once, and it needs a ChromeBrowserState object.-[MainController startUpBrowserForegroundInitialization] was chosen for a couple reasons.
- It's called as part of the startup flow (necessary to make the chrome launched event accurate).
- It's only called once. startUpBrowserToStage, which calls startUpBrowserForegroundInitialization, keeps track of what stage of initialization the app is in and makes sure it is not called twice.
- This is where the ChromeBrowserState object is initialized. The FeatureEngagementTrackerFactory uses ChromeBrowserState to store and retrieve the FeatureEngagementTracker.

Locking then unlocking the screen with Chrome in the foreground is considered a warm start because applicationWillEnterForeground is called. Although this is not necessarily desired behavior, there's no way to determine whether the app is returning from the lock screen. This slightly increases the potential number of times the Chrome Opened Event is fired, so in-product help promotions relying on this event should increase the number of times this event must have fired to compensate.

R=edchin@chromium.org, gchatz@chromium.org

Bug: 738164 Change-Id: I656297a800600672931c785fcac0fd6dcd4996aa Reviewed-on: https://chromium-review.googlesource.com/558666 Commit-Queue: Cooper Knaak

82a2c84 [iOS] Notify FeatureEngagementTracker of Chrome Opened Event
ios/chrome/app/BUILD.gn | 2 ++
ios/chrome/app/DEPS | 2 ++
ios/chrome/app/application_delegate/BUILD.gn | 2 ++
ios/chrome/app/application_delegate/app_state.mm | 10 ++++++++++
ios/chrome/app/main_controller.mm | 8 ++++++++
5 files changed, 24 insertions(+)

Upstream: git.chromium.org

  • Share