Skip to content

Commit

Permalink
Fix a crash when SegmentationPlatform is disabled
Browse files Browse the repository at this point in the history
BringYourOwnTabsIOS feature depends on SegmentationPlatform and crashes
if the latter is disabled. This CL fixes that by adding a feature check
before building `BringAndroidTabsToIOSService`.

Addtionally, the service is not built when BringYourOwnTabsIOS itself is
disabled.

"--disable-features=SegmentationPlatform"

Test: run in the ios simulator with
Bug: 1474365
Change-Id: I0b0854e0621835a081fccdbd18f777add0367993
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4798048
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1187175}
  • Loading branch information
hferreiro authored and Chromium LUCI CQ committed Aug 23, 2023
1 parent 02a3527 commit 085a52e
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

#import "ios/chrome/browser/bring_android_tabs/bring_android_tabs_to_ios_service_factory.h"

#import "base/feature_list.h"
#import "components/keyed_service/ios/browser_state_dependency_manager.h"
#import "components/pref_registry/pref_registry_syncable.h"
#import "components/segmentation_platform/embedder/default_model/device_switcher_result_dispatcher.h"
#import "components/segmentation_platform/public/features.h"
#import "ios/chrome/browser/bring_android_tabs/bring_android_tabs_to_ios_service.h"
#import "ios/chrome/browser/bring_android_tabs/features.h"
#import "ios/chrome/browser/first_run/first_run.h"
#import "ios/chrome/browser/segmentation_platform/segmentation_platform_service_factory.h"
#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
Expand Down Expand Up @@ -60,6 +63,13 @@
std::unique_ptr<KeyedService>
BringAndroidTabsToIOSServiceFactory::BuildServiceInstanceFor(
web::BrowserState* context) const {
// SegmentationPlatform is required for BringYourOwnTabsIOS to work.
if (!base::FeatureList::IsEnabled(kBringYourOwnTabsIOS) ||
!base::FeatureList::IsEnabled(
segmentation_platform::features::kSegmentationPlatformFeature)) {
return nullptr;
}

ChromeBrowserState* browser_state =
ChromeBrowserState::FromBrowserState(context);
PrefService* browser_state_prefs =
Expand Down

0 comments on commit 085a52e

Please sign in to comment.