Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 56c7cd99 authored by uazo's avatar uazo Committed by GitHub
Browse files

[AUTO][FILECONTROL] - version 143.0.7499.40 (#2516)

[AUTO][FILECONTROL] - version 143.0.7499.40
parents 03ac6cfc 2251675b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
142.0.7444.176
143.0.7499.40
+49 −22
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@
#include "android_webview/browser/aw_contents.h"
#include "android_webview/browser/aw_contents_client_bridge.h"
#include "android_webview/browser/aw_contents_io_thread_client.h"
#include "android_webview/browser/aw_contents_statics.h"
#include "android_webview/browser/aw_cookie_access_policy.h"
#include "android_webview/browser/aw_devtools_manager_delegate.h"
#include "android_webview/browser/aw_feature_list_creator.h"
#include "android_webview/browser/aw_http_auth_handler.h"
#include "android_webview/browser/aw_origin_matched_header.h"
#include "android_webview/browser/aw_policy_blocklist_service_factory.h"
#include "android_webview/browser/aw_settings.h"
#include "android_webview/browser/aw_speech_recognition_manager_delegate.h"
#include "android_webview/browser/aw_web_contents_delegate.h"
@@ -61,6 +63,7 @@
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/path_service.h"
@@ -78,6 +81,7 @@
#include "components/page_load_metrics/browser/metrics_navigation_throttle.h"
#include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
#include "components/policy/content/policy_blocklist_navigation_throttle.h"
#include "components/policy/content/safe_search_service.h"
#include "components/policy/core/browser/browser_policy_connector_base.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/content/browser/async_check_tracker.h"
@@ -87,6 +91,7 @@
#include "components/safe_browsing/core/common/hashprefix_realtime/hash_realtime_utils.h"
#include "components/url_matcher/url_matcher.h"
#include "components/url_matcher/url_util.h"
#include "components/user_prefs/user_prefs.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
@@ -172,7 +177,6 @@ bool g_created_network_context_params = false;
// On apps targeting API level O or later, check cleartext is enforced.
bool g_check_cleartext_permitted = false;


// Get async check tracker to make Safe Browsing v5 check asynchronous
base::WeakPtr<AsyncCheckTracker> GetAsyncCheckTracker(
    const base::RepeatingCallback<content::WebContents*()>& wc_getter,
@@ -210,8 +214,15 @@ std::string GetUserAgent() {

  if (base::FeatureList::IsEnabled(
          features::kWebViewReduceUAAndroidVersionDeviceModel)) {
    return embedder_support::BuildUnifiedPlatformUAFromProductAndExtraOs(
        product, "; wv");
    // The user-agent reduction feature for WebView, when enabled, should
    // produce a consistent, unified platform string to ensure predictable
    // behavior. This hardcoded value prevents device-specific platform details
    // (e.g., "X11; Linux" on desktop devices) from appearing in the reduced
    // User-Agent. The "Linux; Android 10; K; wv" string matches the expected
    // format for a reduced WebView User-Agent.
    constexpr char kUnifiedPlatformOsInfoWebview[] = "Linux; Android 10; K; wv";
    return embedder_support::BuildUserAgentFromOSAndProduct(
        kUnifiedPlatformOsInfoWebview, product);
  }

  return embedder_support::BuildUserAgentFromProductAndExtraOSInfo(
@@ -403,7 +414,7 @@ bool AwContentBrowserClient::IsHandledURL(const GURL& url) {
    return true;
  }

  const std::string scheme = url.scheme();
  const std::string scheme = url.GetScheme();
  DCHECK_EQ(scheme, base::ToLowerASCII(scheme));
  static const char* const kProtocolList[] = {
      url::kHttpScheme,         url::kHttpsScheme,
@@ -451,6 +462,29 @@ void AwContentBrowserClient::AppendExtraCommandLineSwitches(
    command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
                                   kSwitchNames);
  }

  if (base::FeatureList::IsEnabled(
          features::kWebViewConfigurableLibraryPrefetch)) {
    RendererLibraryPrefetchMode mode = GetRendererLibraryPrefetchMode();
    switch (mode) {
      case RendererLibraryPrefetchMode::kDisabled:
        command_line->AppendSwitchASCII(
            switches::kWebViewRendererLibraryPrefetch,
            switches::kWebViewRendererLibraryPrefetchDisabled);
        break;
      case RendererLibraryPrefetchMode::kEnabled:
        command_line->AppendSwitchASCII(
            switches::kWebViewRendererLibraryPrefetch,
            switches::kWebViewRendererLibraryPrefetchEnabled);
        break;
      default:
        // kDefault or unknown values are ignored. But sanitize for histograms.
        mode = RendererLibraryPrefetchMode::kDefault;
        break;
    }
    base::UmaHistogramEnumeration("Android.WebView.RendererLibraryPrefetchMode",
                                  mode);
  }
}

std::string AwContentBrowserClient::GetApplicationLocale() {
@@ -628,10 +662,8 @@ void AwContentBrowserClient::OverrideWebPreferences(
    aw_settings->PopulateWebPreferences(web_prefs);
  }

  // This preference is needed for back-forward transitions, but they are not
  // enabled for webview (crbug.com/361600214).
  web_prefs->increment_local_surface_id_for_mainframe_same_doc_navigation =
      false;
  // Back-forward transitions are not enabled for webview (crbug.com/361600214).
  web_prefs->should_screenshot_on_mainframe_same_doc_navigation = false;

  AwWebContentsDelegate* delegate =
      static_cast<AwWebContentsDelegate*>(web_contents->GetDelegate());
@@ -663,9 +695,12 @@ void AwContentBrowserClient::CreateThrottlesForNavigation(
  navigation_interception::InterceptNavigationDelegate::MaybeCreateAndAdd(
      registry, navigation_interception::SynchronyMode::kSync);

  AwBrowserContext* context =
      AwBrowserContext::FromWebContents(navigation_handle.GetWebContents());
  registry.AddThrottle(std::make_unique<PolicyBlocklistNavigationThrottle>(
      registry,
      AwBrowserContext::FromWebContents(navigation_handle.GetWebContents())));
      registry, user_prefs::UserPrefs::Get(context),
      AwPolicyBlocklistServiceFactory::GetForBrowserContext(context),
      SafeSearchFactory::GetForBrowserContext(context)));

  AwSafeBrowsingNavigationThrottle::MaybeCreateAndAdd(registry);

@@ -1428,18 +1463,6 @@ AwContentBrowserClient::GetAttributionReportingOsRegistrars(
  NOTREACHED();
}

network::mojom::IpProtectionProxyBypassPolicy
AwContentBrowserClient::GetIpProtectionProxyBypassPolicy() {
  // The exact WebView-specific exclusion policy that is used will depend
  // on android_webview::features::kWebViewIpProtectionExclusionCriteria
  return network::mojom::IpProtectionProxyBypassPolicy::kExclusionList;
}

bool AwContentBrowserClient::WillProvidePublicFirstPartySets() {
  return base::CommandLine::ForCurrentProcess()->HasSwitch(
      switches::kWebViewFpsComponent);
}

bool AwContentBrowserClient::IsFullCookieAccessAllowed(
    content::BrowserContext* browser_context,
    content::WebContents* web_contents,
@@ -1495,4 +1518,8 @@ bool AwContentBrowserClient::IsSharedStorageSelectURLAllowed(
  return base::FeatureList::IsEnabled(network::features::kSharedStorageAPI);
}

bool AwContentBrowserClient::ShouldAnimateBackForwardTransitions() {
  return false;
}

}  // namespace android_webview
+25 −15
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

#include "android_webview/browser/aw_field_trials.h"

#include "android_webview/browser/metrics/aw_metrics_service_client.h"
#include "android_webview/common/aw_features.h"
#include "android_webview/common/aw_switches.h"
#include "base/allocator/partition_alloc_features.h"
@@ -24,7 +25,6 @@
#include "gpu/config/gpu_finch_features.h"
#include "media/audio/audio_features.h"
#include "media/base/media_switches.h"
#include "mojo/public/cpp/bindings/features.h"
#include "net/base/features.h"
#include "services/network/public/cpp/features.h"
#include "services/tracing/public/cpp/tracing_features.h"
@@ -37,12 +37,11 @@

void AwFieldTrials::OnVariationsSetupComplete() {
  // Persistent histograms must be enabled ASAP, but depends on Features.
  base::FilePath metrics_dir;
  if (base::PathService::Get(base::DIR_ANDROID_APP_DATA, &metrics_dir)) {
    InstantiatePersistentHistogramsWithFeaturesAndCleanup(metrics_dir);
  } else {
    NOTREACHED();
  }
  android_webview::AwMetricsServiceClient* metrics_service_client =
      android_webview::AwMetricsServiceClient::GetInstance();
  metrics_service_client->SetUpMetricsDir();
  InstantiatePersistentHistogramsWithFeaturesAndCleanup(
      metrics_service_client->GetMetricsDir());
}

// TODO(crbug.com/40271903): Consider to migrate all WebView feature overrides
@@ -66,15 +65,18 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
  aw_feature_overrides.DisableFeature(
      blink::features::kAboutBlankPageRespectsDarkModeOnUserAction);

  // TODO(crbug.com/433304196): Remove this once webview experiment has
  // concluded.
  aw_feature_overrides.DisableFeature(
      blink::features::kAsyncTouchMovesImmediatelyAfterScroll);

  // Disable enforcing `noopener` on Blob URL navigations on WebView.
  aw_feature_overrides.DisableFeature(
      blink::features::kEnforceNoopenerOnBlobURLNavigation);

#if BUILDFLAG(ENABLE_VALIDATING_COMMAND_DECODER)
  // Disable the passthrough on WebView.
  aw_feature_overrides.DisableFeature(
      ::features::kDefaultPassthroughCommandDecoder);
#endif

  // HDR does not support webview yet. See crbug.com/1493153 for an explanation.
  aw_feature_overrides.DisableFeature(ui::kAndroidHDR);
@@ -201,8 +203,10 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
  aw_feature_overrides.DisableFeature(::features::kFedCm);

  // Disable Digital Credentials API on WebView.
  aw_feature_overrides.DisableFeature(::features::kWebIdentityDigitalCredentials);
  aw_feature_overrides.DisableFeature(::features::kWebIdentityDigitalCredentialsCreation);
  aw_feature_overrides.DisableFeature(
      ::features::kWebIdentityDigitalCredentials);
  aw_feature_overrides.DisableFeature(
      ::features::kWebIdentityDigitalCredentialsCreation);

  // TODO(crbug.com/40272633): Web MIDI permission prompt for all usage.
  aw_feature_overrides.DisableFeature(blink::features::kBlockMidiByDefault);
@@ -217,10 +221,6 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
  // enabling site isolation. See crbug.com/356170748.
  aw_feature_overrides.DisableFeature(blink::features::kPaintHoldingForIframes);

  // Default Nav Transition does not support WebView.
  // TODO(crbug.com/434928245): cleanup this feature gate in M141.
  aw_feature_overrides.DisableFeature(blink::features::kBackForwardTransitions);

  // Disabling this feature for WebView, since it can switch focus when scrolled
  // in cases with multiple views which can trigger HTML focus changes that
  // aren't intended. See crbug.com/378779896, crbug.com/373672168 for more
@@ -303,12 +303,22 @@ void AwFieldTrials::RegisterFeatureOverrides(base::FeatureList* feature_list) {
  aw_feature_overrides.DisableFeature(
      features::kAAudioPerStreamDeviceSelection);

  // WebView exposes text autosizing to apps via setLayoutAlgorithm(), so
  // we keep text autosizing support in WebView for now. Further WebView
  // work will take place in https://crbug.com/391990606.
  aw_feature_overrides.DisableFeature(blink::features::kForceOffTextAutosizing);

  // Local Network Access restrictions should not be enforced in WebView.
  // The LNA permission is auto-granted in WebView, but the permission
  // policy currently blocks iframes from using it. crbug.com/442879527
  aw_feature_overrides.DisableFeature(
      network::features::kLocalNetworkAccessChecks);

  // Disable background media for WebView, until we have consensus on long-term
  // behavior crbug.com/453706851
  aw_feature_overrides.DisableFeature(
      features::kAndroidEnableBackgroundMediaLargeFormFactors);

  // SystemTracing is enabled by default only in WebView for now.
  aw_feature_overrides.EnableFeature(features::kEnablePerfettoSystemTracing);
}
+23 −12
Original line number Diff line number Diff line
@@ -24,21 +24,21 @@ by a child template that "extends" this file.

    <uses-feature android:glEsVersion="0x00030000" />


    <!-- Needed for
          * servicing requests from websites to obtain location through the Web Geolocation API,
            which, however, is further gated on the user expressly granting the geolocation
            permission to individual web origins
          * supporting bluetooth discovery pre-S
          * providing a geolocation header to the default search engine; used to annotate omnibox
            suggestions, search prefetch and search navigation requests.
    -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-permission-sdk-23 android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!--
      Enable runtime permissions as uses-permission in tip of tree builds
      only for ease of development on Android L and earlier. For consumer
      channels use "runtime permission" uses-permission-sdk-23 which provides
      permission on Android M and later without a prompt.
    -->
    {% if channel in ['default'] %}
        <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
    {% endif %}

    <uses-permission-sdk-23 android:name="android.permission.ACCESS_ADSERVICES_ATTRIBUTION" />
    <uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
    <uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_CONNECT"/>
@@ -64,6 +64,8 @@ by a child template that "extends" this file.

    <uses-permission-sdk-23 android:name="android.permission.READ_CONTACTS"/>
    <uses-permission-sdk-23 android:name="android.permission.REORDER_TASKS"/>

    <!--  Needed for allowing downloaded APKs to be installed. -->
    <uses-permission-sdk-23 android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

    <uses-permission android:name="android.permission.CAMERA" />
@@ -90,11 +92,20 @@ by a child template that "extends" this file.
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-permission android:name="android.permission.NFC"/>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- Needed to determine whether an app installed on the device should handle a web navigation.  -->
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission-sdk-23 android:name="android.permission.READ_MEDIA_AUDIO"/>

    <!-- Needed for handling media-viewing Intents from other apps for images and video on low end
         or managed devices (eg. crbug.com/40546519), monitoring of screenshots if permission has
         been previously granted (doesn't request independently) (crbug.com/40520892), and
         Chromium's custom photo picker used on Android S and below (crbug.com/40489056) -->
    <uses-permission-sdk-23 android:name="android.permission.READ_MEDIA_IMAGES"/>
    <uses-permission-sdk-23 android:name="android.permission.READ_MEDIA_VIDEO"/>

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <!--
@@ -593,7 +604,7 @@ by a child template that "extends" this file.
            @android:style/Theme.NoDisplay can't be used here.
        -->
        <activity android:name="org.chromium.chrome.browser.sync.ui.SyncTrustedVaultProxyActivity"
            android:theme="@style/Theme.Material3.DayNight"
            android:theme="@style/Theme.Material3Expressive.DayNight"
            android:excludeFromRecents="true"
            android:exported="false">
        </activity>
@@ -1214,7 +1225,7 @@ by a child template that "extends" this file.
            android:excludeFromRecents="true"
            android:exported="true"
            android:noHistory="true"
            android:theme="@style/Theme.Material3.DayNight"
            android:theme="@style/Theme.Material3Expressive.DayNight"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize" >
        </activity>

+74 −35
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
    private final @Nullable Intent mKeepAliveServiceIntent;
    private final @Nullable Bundle mAnimationBundle;

    private final int mUiType;
    private int mUiType;
    private final int mTitleVisibilityState;
    private final @Nullable String mMediaViewerUrl;
    private final boolean mEnableEmbeddedMediaExperience;
@@ -589,11 +589,6 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
            }
        }

        mOpenInBrowserState =
                IntentUtils.safeGetIntExtra(
                        intent,
                        EXTRA_OPEN_IN_BROWSER_STATE,
                        OpenInBrowserButtonState.OPEN_IN_BROWSER_STATE_DEFAULT);
        if (mUiType == CustomTabsUiType.POPUP) {
            mShareState = CustomTabsIntent.SHARE_STATE_OFF;
        } else {
@@ -611,12 +606,15 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
        List<Bundle> menuItems =
                IntentUtils.getParcelableArrayListExtra(intent, CustomTabsIntent.EXTRA_MENU_ITEMS);

        addOpenInBrowserOption(intent, context);
        mOpenInBrowserState =
                IntentUtils.safeGetIntExtra(
                        intent,
                        EXTRA_OPEN_IN_BROWSER_STATE,
                        OpenInBrowserButtonState.OPEN_IN_BROWSER_STATE_DEFAULT);
        int oibState = adjustOpenInBrowserOption(intent);
        maybeAddOpenInBrowserOption(context, oibState);
        updateExtraMenuItems(menuItems);
        // Disable CCT share options for automotive. See b/300292495.
        if (ShareUtils.enableShareForAutomotive(true)) {
            addShareOption(intent, context);
        }
        maybeAddShareOption(intent, context);

        boolean isTwa =
                mSession != null
@@ -639,6 +637,9 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
        mTrustedWebActivityDisplayMode = resolveTwaDisplayMode();
        mTrustedWebActivityDisplayOverrideMode = resolveTwaDisplayOverrideMode();

        // After TWA checks, update custom tabs ui types. Order seems to matter
        // here.
        mUiType = getCustomTabsUiType(requestedUiType);
        int intentVisibilityState =
                IntentUtils.safeGetIntExtra(
                        intent,
@@ -818,12 +819,12 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
    }

    /**
     * Get the verified custom tabs UI type, according to the intent extras, and whether
     * the intent is trusted.
     * Get the verified custom tabs UI type, according to the intent extras, and whether the intent
     * is trusted.
     *
     * If the intent extras include a valid EXTRA_NETWORK, consider that the custom tab is
     * used for captive portal scenarios especially and the UI hides the "Open in Chrome browser"
     * menu item accordingly.
     * <p>If the intent extras include a valid EXTRA_NETWORK, consider that the custom tab is used
     * for captive portal scenarios especially and the UI hides the "Open in Chrome browser" menu
     * item accordingly.
     *
     * @param requestedUiType requested UI type in the intent, unqualified
     * @return verified UI type
@@ -831,6 +832,9 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
    @BrowserServicesIntentDataProvider.CustomTabsUiType
    private int getCustomTabsUiType(int requestedUiType) {
        if (mNetwork != null) return CustomTabsUiType.NETWORK_BOUND_TAB;
        if (isTrustedWebActivity() && resolveDisplayMode() == DisplayMode.MINIMAL_UI) {
            return CustomTabsUiType.TRUSTED_WEB_ACTIVITY;
        }
        if (!isTrustedIntent()) {
            if (VersionInfo.isLocalBuild()) Log.w(TAG, FIRST_PARTY_PITFALL_MSG);
            return CustomTabsUiType.DEFAULT;
@@ -942,10 +946,12 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
     *       {@link CustomTabsIntent#EXTRA_DEFAULT_SHARE_MENU_ITEM}.
     * </ul>
     */
    private void addShareOption(Intent intent, Context context) {
    private void maybeAddShareOption(Intent intent, Context context) {
        // Disable CCT share options for automotive. See crbug.com/300292495.
        if (!ShareUtils.enableShareForAutomotive(true)) return;

        if (mShareState == CustomTabsIntent.SHARE_STATE_DEFAULT) {
            if (mToolbarButtons.isEmpty()
                    || (isCpaOnlyOpenInBrowserDefault() && canAddMoreToolbarItems())) {
            if (canAddShareAction()) {
                mToolbarButtons.add(
                        CustomButtonParamsImpl.createShareButton(
                                context, getColorProvider().getToolbarColor()));
@@ -953,8 +959,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
                mShowShareItemInMenu = true;
            }
        } else if (mShareState == CustomTabsIntent.SHARE_STATE_ON) {
            if (mToolbarButtons.isEmpty()
                    || (isCpaOnlyOpenInBrowserDefault() && canAddMoreToolbarItems())) {
            if (canAddShareAction()) {
                mToolbarButtons.add(
                        CustomButtonParamsImpl.createShareButton(
                                context, getColorProvider().getToolbarColor()));
@@ -970,7 +975,21 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
        }
    }

    private void addOpenInBrowserOption(Intent intent, Context context) {
    private boolean canAddShareAction() {
        if (!ChromeFeatureList.sCctAdaptiveButton.isEnabled()) return mToolbarButtons.isEmpty();

        if (!canAddMoreToolbarItems()) return false;

        if (mShareState == CustomTabsIntent.SHARE_STATE_OFF) {
            return false;
        } else if (mShareState == CustomTabsIntent.SHARE_STATE_ON) {
            return true;
        } else { // mShareState == CustomTabsIntent.SHARE_STATE_DEFAULT
            return mToolbarButtons.isEmpty();
        }
    }

    private int adjustOpenInBrowserOption(Intent intent) {
        boolean usingInteractiveOmnibox =
                CustomTabsConnection.getInstance().shouldEnableOmniboxForIntent(this);

@@ -992,19 +1011,41 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
                    && IntentUtils.safeGetBooleanExtra(
                            intent, EXTRA_OPEN_IN_BROWSER_BUTTON_ALLOWED, false)) {
                openInBrowserState = CustomTabsButtonState.BUTTON_STATE_ON;
            } else {
            } else if (!isCpaOnlyOpenInBrowserDefault()) {
                openInBrowserState = CustomTabsButtonState.BUTTON_STATE_OFF;
            }
        }

        if (openInBrowserState == CustomTabsButtonState.BUTTON_STATE_ON) {
            if (mToolbarButtons.isEmpty()
                    || (isCpaOnlyOpenInBrowserDefault() && canAddMoreToolbarItems())) {
        return openInBrowserState;
    }

    private void maybeAddOpenInBrowserOption(Context context, int oibState) {
        if (canAddOpenInBrowserAction(oibState)) {
            mToolbarButtons.add(
                    CustomButtonParamsImpl.createOpenInBrowserButton(
                            context, getColorProvider().getToolbarColor()));
        }
    }

    private boolean canAddOpenInBrowserAction(int oibState) {
        if (!ChromeFeatureList.sCctAdaptiveButton.isEnabled()
                && oibState == CustomTabsButtonState.BUTTON_STATE_ON) {
            return mToolbarButtons.isEmpty();
        }

        if (!canAddMoreToolbarItems()) return false;

        if (oibState == CustomTabsButtonState.BUTTON_STATE_OFF) {
            return false;
        } else if (oibState == CustomTabsButtonState.BUTTON_STATE_ON) {
            return mToolbarButtons.isEmpty() || mShareState != CustomTabsIntent.SHARE_STATE_ON;
        } else { // oibState == CustomTabsButtonState.BUTTON_STATE_DEFAULT
            // Give SHARE a higher precedence than OIB. OIB is visible only in CPA+OIB
            // experiment arm where SHARE is explicitly off.
            return mToolbarButtons.isEmpty()
                    && isCpaOnlyOpenInBrowserDefault()
                    && mShareState == CustomTabsIntent.SHARE_STATE_OFF;
        }
    }

    private @Nullable String resolveUrlToLoad(Intent intent) {
@@ -1690,10 +1731,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid

    @Override
    public boolean isInteractiveOmniboxEnabled() {
        return ChromeFeatureList.sSearchInCCT.isEnabled()
                && isPackageNameInList(
                        getClientPackageName(),
                        ChromeFeatureList.sSearchinCctOmniboxAllowedPackageNames.getValue());
        return ChromeFeatureList.sSearchInCCT.isEnabled();
    }

    @Override
@@ -1857,7 +1895,8 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
    }

    private boolean isCpaOnlyOpenInBrowserDefault() {
        return ChromeFeatureList.sCctAdaptiveButtonContextualOnly.getValue()
        return ChromeFeatureList.sCctAdaptiveButton.isEnabled()
                && ChromeFeatureList.sCctAdaptiveButtonContextualOnly.getValue()
                && ChromeFeatureList.sCctAdaptiveButtonDefaultVariant.getValue()
                        == AdaptiveToolbarButtonVariant.OPEN_IN_BROWSER;
    }
Loading