1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/dom_distiller/core/dom_distiller_features.h"
#include <string>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "components/dom_distiller/core/dom_distiller_switches.h"
#include "components/dom_distiller/core/pref_names.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/feature_map.h"
#include "base/no_destructor.h"
#include "components/dom_distiller/core/android/jni_headers/DomDistillerFeatureMap_jni.h"
#endif
namespace dom_distiller {
bool IsDomDistillerEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDomDistiller);
}
bool ShouldStartDistillabilityService() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDistillabilityService);
}
BASE_FEATURE(kReaderModeUseReadability,
"ReaderModeUseReadability",
base::FEATURE_DISABLED_BY_DEFAULT);
constexpr base::FeatureParam<bool> kReaderModeUseReadabilityUseDisiller{
&kReaderModeUseReadability, /*name=*/"use_distiller",
/*default_value=*/false};
bool ShouldUseReadabilityDistiller() {
return base::FeatureList::IsEnabled(kReaderModeUseReadability) &&
kReaderModeUseReadabilityUseDisiller.Get();
}
#if BUILDFLAG(IS_ANDROID)
// Feature declarations below -- alphabetical order.
BASE_FEATURE(kReaderModeAutoDistill,
"ReaderModeAutoDistill",
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kReaderModeDistillInApp,
"ReaderModeDistillInApp",
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kReaderModeImprovements,
"ReaderModeImprovements",
base::FEATURE_DISABLED_BY_DEFAULT);
namespace android {
static jlong JNI_DomDistillerFeatureMap_GetNativeMap(JNIEnv* env) {
static const base::Feature* const kFeaturesExposedToJava[] = {
&kReaderModeAutoDistill, &kReaderModeDistillInApp,
&kReaderModeImprovements, &kReaderModeUseReadability};
static base::NoDestructor<base::android::FeatureMap> kFeatureMap(
kFeaturesExposedToJava);
return reinterpret_cast<jlong>(kFeatureMap.get());
}
} // namespace android
#endif // BUILDFLAG(IS_ANDROID)
} // namespace dom_distiller
|