chrome_feature_list.cc 3.48 KB
Newer Older
1
2
3
4
5
6
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/android/chrome_feature_list.h"

7
8
#include <stddef.h>

9
10
11
12
#include <string>

#include "base/android/jni_string.h"
#include "base/feature_list.h"
13
#include "base/macros.h"
14
#include "chrome/common/chrome_features.h"
15
#include "components/offline_pages/offline_page_feature.h"
16
#include "content/public/common/content_features.h"
17
18
19
20
21
22
23
24
25
26
#include "jni/ChromeFeatureList_jni.h"

using base::android::ConvertJavaStringToUTF8;

namespace chrome {
namespace android {

namespace {

// Array of features exposed through the Java ChromeFeatureList API. Entries in
27
28
// this array may either refer to features defined in the header of this file or
// in other locations in the code base (e.g. chrome/, components/, etc).
29
const base::Feature* kFeaturesExposedToJava[] = {
30
31
    &features::kCredentialManagementAPI,
    &features::kSimplifiedFullscreenUI,
32
    &kAndroidPayIntegrationV1,
33
    &kImportantSitesInCBD,
34
    &kMediaStyleNotification,
35
    &kNTPFakeOmniboxTextFeature,
36
    &kNTPMaterialDesign,
37
    &kNTPOfflinePagesFeature,
38
    &kNTPSnippetsFeature,
39
    &kNTPToolbarFeature,
40
    &kPhysicalWebFeature,
41
    &kPhysicalWebIgnoreOtherClientsFeature,
42
    &kReadItLaterInMenu,
43
    &kSystemDownloadManager,
44
    &offline_pages::kOfflinePagesBackgroundLoadingFeature,
45
    &offline_pages::kOfflinePagesCTFeature,  // See crbug.com/620421.
46
47
48
49
};

}  // namespace

50
51
52
const base::Feature kImportantSitesInCBD{"ImportantSitesInCBD",
                                         base::FEATURE_DISABLED_BY_DEFAULT};

53
const base::Feature kMediaStyleNotification {
54
  "MediaStyleNotification", base::FEATURE_ENABLED_BY_DEFAULT
55
56
};

57
58
59
const base::Feature kNTPMaterialDesign{"NTPMaterialDesign",
                                       base::FEATURE_ENABLED_BY_DEFAULT};

60
61
62
63
const base::Feature kNTPOfflinePagesFeature {
  "NTPOfflinePages", base::FEATURE_DISABLED_BY_DEFAULT
};

64
65
66
67
const base::Feature kNTPSnippetsFeature {
  "NTPSnippets", base::FEATURE_DISABLED_BY_DEFAULT
};

68
69
70
71
const base::Feature kNTPToolbarFeature {
  "NTPToolbar", base::FEATURE_ENABLED_BY_DEFAULT
};

72
73
74
75
const base::Feature kNTPFakeOmniboxTextFeature {
  "NTPFakeOmniboxText", base::FEATURE_DISABLED_BY_DEFAULT
};

76
77
78
79
const base::Feature kAndroidPayIntegrationV1 {
  "AndroidPayIntegrationV1", base::FEATURE_ENABLED_BY_DEFAULT
};

80
const base::Feature kPhysicalWebFeature {
cco3's avatar
cco3 committed
81
  "PhysicalWeb", base::FEATURE_ENABLED_BY_DEFAULT
82
83
};

84
85
86
87
const base::Feature kPhysicalWebIgnoreOtherClientsFeature {
  "PhysicalWebIgnoreOtherClients", base::FEATURE_DISABLED_BY_DEFAULT
};

88
89
90
91
const base::Feature kReadItLaterInMenu {
  "ReadItLaterInMenu", base::FEATURE_DISABLED_BY_DEFAULT
};

92
93
94
95
const base::Feature kSystemDownloadManager {
  "SystemDownloadManager", base::FEATURE_ENABLED_BY_DEFAULT
};

96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
static jboolean IsEnabled(JNIEnv* env,
                          const JavaParamRef<jclass>& clazz,
                          const JavaParamRef<jstring>& jfeature_name) {
  const std::string feature_name = ConvertJavaStringToUTF8(env, jfeature_name);
  for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) {
    if (kFeaturesExposedToJava[i]->name == feature_name)
      return base::FeatureList::IsEnabled(*kFeaturesExposedToJava[i]);
  }
  // Features queried via this API must be present in |kFeaturesExposedToJava|.
  NOTREACHED();
  return false;
}

bool RegisterChromeFeatureListJni(JNIEnv* env) {
  return RegisterNativesImpl(env);
}

}  // namespace android
}  // namespace chrome