1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef XWALK_RUNTIME_COMMON_XWALK_RUNTIME_FEATURES_H_
6 #define XWALK_RUNTIME_COMMON_XWALK_RUNTIME_FEATURES_H_
11 #include "base/command_line.h"
12 #include "base/memory/singleton.h"
16 #define DECLARE_RUNTIME_FEATURE(NAME) static bool is ##NAME## Enabled() \
17 { return GetInstance()->isFeatureEnabled( #NAME ); }
19 class XWalkRuntimeFeatures {
21 // Declare new features here and and define them in xwalk_runtime_features.cc.
22 DECLARE_RUNTIME_FEATURE(SysApps);
23 DECLARE_RUNTIME_FEATURE(RawSocketsAPI);
24 DECLARE_RUNTIME_FEATURE(DeviceCapabilitiesAPI);
25 DECLARE_RUNTIME_FEATURE(StorageAPI);
26 DECLARE_RUNTIME_FEATURE(DialogAPI);
28 void Initialize(const CommandLine* cmd);
29 void DumpFeaturesFlags();
30 static XWalkRuntimeFeatures* GetInstance();
32 enum RuntimeFeatureStatus {
38 struct RuntimeFeature {
40 std::string description;
41 std::string command_line_switch;
42 RuntimeFeatureStatus status;
44 RuntimeFeature() = default;
48 friend struct DefaultSingletonTraits<XWalkRuntimeFeatures>;
49 XWalkRuntimeFeatures();
50 ~XWalkRuntimeFeatures();
51 void AddFeature(const char* name, const char* command_line_switch,
52 const char* description, RuntimeFeatureStatus status);
53 bool isFeatureEnabled(const char* name) const;
54 typedef std::vector<RuntimeFeature> RuntimeFeaturesList;
55 RuntimeFeaturesList runtime_features_;
56 const CommandLine* command_line_;
58 bool experimental_features_enabled_;
63 #endif // XWALK_RUNTIME_COMMON_XWALK_RUNTIME_FEATURES_H_