brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.92k stars 2.34k forks source link

[ads] Refactor tab helper, browser manager and tab manager #37039

Closed tmancey closed 7 months ago

btlechowski commented 6 months ago

Verified with

Brave 1.66.110 Chromium: 125.0.6422.60 (Official Build) (64-bit)
Revision de593d76e2ca4d02faa85bf1ca27bcf3ee46793c
OS Linux

User idle detection

Verified idle detection is working: ``` [6955:6955:0516/125247.406913:VERBOSE1:user_idle_detection.cc(46)] User is idle ```

Page content is classified when visiting a website.

``` [7870:7870:0516/150629.773035:VERBOSE1:text_classification_processor.cc(70)] Classified text with the top segment as crypto-crypto ```

Page content is not classified when restoring a tab.

No classification logged: ``` [7870:7870:0516/150713.415824:VERBOSE1:browser_manager.cc(53)] Browser did become active [7870:7870:0516/150713.417406:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 16 (0:0:900 s) [7870:7870:0516/150713.422794:VERBOSE1:browser_manager.cc(70)] Browser did enter foreground [7870:7870:0516/150713.424279:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 01 (0:0:900 s) [7870:7870:0516/150733.103123:INFO:CONSOLE(0)] "Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.", source: (0) [7870:7870:0516/150733.146324:ERROR:interface_endpoint_client.cc(722)] Message 0 rejected by interface blink.mojom.WidgetHost [7870:7870:0516/150733.157667:VERBOSE1:database_server_publisher_banner.cc(129)] Server publisher banner not found [7870:7870:0516/150735.703353:VERBOSE1:browser_manager.cc(53)] Browser did resign active [7870:7870:0516/150735.709745:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 17 (0:0:900 s) [7870:7870:0516/150735.709934:VERBOSE1:browser_manager.cc(70)] Browser did enter background [7870:7870:0516/150735.711757:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 02 (0:0:900 s) ```

Page content is not classified when a page error occurs

Verified page is not classified when page error occurs

User activity events are logged to the console

``` [7870:7870:0516/151030.116120:VERBOSE1:browser_manager.cc(53)] Browser did become active [7870:7870:0516/151030.120294:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 16 (0:0:900 s) [7870:7870:0516/151030.120560:VERBOSE1:browser_manager.cc(70)] Browser did enter foreground [7870:7870:0516/151030.134856:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 01 (0:0:900 s) [7870:7870:0516/151035.672646:ERROR:atom_cache.cc(229)] Add WM_CHANGE_STATE to kAtomsToCache [7870:7870:0516/151035.721650:VERBOSE1:browser_manager.cc(53)] Browser did resign active [7870:7870:0516/151035.729045:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 17 (0:0:900 s) [7870:7870:0516/151035.730007:VERBOSE1:browser_manager.cc(70)] Browser did enter background [7870:7870:0516/151035.733556:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 02 (0:0:900 s) [7870:7870:0516/151037.795885:VERBOSE1:browser_manager.cc(53)] Browser did become active [7870:7870:0516/151037.814712:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 16 (0:0:900 s) [7870:7870:0516/151037.815113:VERBOSE1:browser_manager.cc(70)] Browser did enter foreground [7870:7870:0516/151037.817322:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 01 (0:0:900 s) [7870:7870:0516/151039.432766:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 0B (0:0:900 s) [7870:7870:0516/151039.437893:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 14 (0:0:900 s) [7870:7870:0516/151039.439450:VERBOSE2:tab_manager.cc(240)] Created tab with id 1958786991 [7870:7870:0516/151039.445587:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 0D (0:0:900 s) [7870:7870:0516/151039.448828:VERBOSE2:tab_manager.cc(251)] Tab id 1958786991 did become occluded [7870:7870:0516/151039.452446:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 09 (0:0:900 s) [7870:7870:0516/151039.496200:WARNING:CONSOLE(5)] "crbug/1173575, non-JS module files deprecated.", source: chrome://resources/js/load_time_data_deprecated.js (5) [7870:7870:0516/151040.040627:VERBOSE2:tab_manager.cc(167)] Tab id 1958786991 HTML content changed [7870:7870:0516/151040.041024:VERBOSE1:conversions.cc(57)] Checking for conversions [7870:7870:0516/151040.041590:VERBOSE1:text_embedding_processor.cc(101)] chrome scheme is not supported for processing HTML content [7870:7870:0516/151040.042259:VERBOSE2:tab_manager.cc(184)] Tab id 1958786991 text content changed [7870:7870:0516/151040.042862:VERBOSE1:purchase_intent_processor.cc(46)] chrome scheme is not supported for processing purchase intent [7870:7870:0516/151040.043719:VERBOSE1:text_classification_processor.cc(89)] chrome scheme is not supported for processing text content [7870:7870:0516/151040.048784:VERBOSE1:conversions.cc(120)] There are no matching creative set conversions [7870:7870:0516/151041.987481:VERBOSE1:browser_manager.cc(53)] Browser did resign active [7870:7870:0516/151041.992730:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 17 (0:0:900 s) [7870:7870:0516/151041.993163:VERBOSE1:browser_manager.cc(70)] Browser did enter background [7870:7870:0516/151041.994337:VERBOSE6:user_activity_manager.cc(42)] Triggered event: 02 (0:0:900 s) ```

User activity events are not logged to the console upon tab restoration

Verified not logged

Site visits and page landings are occurring

``` [7870:7870:0516/151251.922824:VERBOSE1:confirmations.cc(97)] Successfully processed view confirmation for ad_notification with transaction id acba2fd2-d778-45db-9925-1bec2953315f and creative instance id 4cda3ae7-1f70-4bca-b361-ca01d6a8f1ed ``` ``` [7870:7870:0516/151302.935437:VERBOSE1:confirmations.cc(97)] Successfully processed click confirmation for ad_notification with transaction id 555d5b40-7154-4f25-bc25-645c0385f636 and creative instance id 4cda3ae7-1f70-4bca-b361-ca01d6a8f1ed ``` ``` [7870:7870:0516/151308.476544:VERBOSE1:confirmations.cc(97)] Successfully processed landed confirmation for ad_notification with transaction id 480a11d4-50f6-485c-890b-fc7c1e1bebdd and creative instance id 4cda3ae7-1f70-4bca-b361-ca01d6a8f1ed ```

Conversions are triggered

``` [9682:9682:0516/160642.058169:VERBOSE1:confirmations.cc(97)] Successfully processed conversion confirmation for ad_notification with transaction id b3f6bbdc-9e0b-4b3c-aa96-b2a4470555c2 and creative instance id 4cda3ae7-1f70-4bca-b361-ca01d6a8f1ed ```

Purchase intent is being tracked

``` [9682:9682:0516/160804.376499:VERBOSE1:purchase_intent_processor.cc(89)] Extracting purchase intent signal from search query [9682:9682:0516/160804.376863:VERBOSE1:purchase_intent_processor.cc(100)] Extracted purchase intent signal from search query ```

Orphaned inline content ads are purged.

Logged https://github.com/brave/brave-browser/issues/38373

Push notification ads are being served

``` [7870:7870:0516/151251.922824:VERBOSE1:confirmations.cc(97)] Successfully processed view confirmation for ad_notification with transaction id acba2fd2-d778-45db-9925-1bec2953315f and creative instance id 4cda3ae7-1f70-4bca-b361-ca01d6a8f1ed ```

The browser becomes/resigns active appropriately

``` [11388:11388:0516/162533.510001:VERBOSE1:browser_manager.cc(53)] Browser did resign active [11388:11388:0516/162537.136718:VERBOSE1:browser_manager.cc(53)] Browser did become active ```

The browser enters the foreground/background appropriately

``` [11388:11388:0516/162257.365642:VERBOSE1:browser_manager.cc(70)] Browser did enter foreground [11388:11388:0516/162258.458710:VERBOSE1:browser_manager.cc(70)] Browser did enter background ```

Frequent tab switching should not cause race conditions

Verified frequent tab switching can not cause race conditions

Close each tab individually.

Closing works