add features module to detect availability of build time features at runtime

This commit is contained in:
deepak1556 2018-03-15 22:56:25 +09:00 committed by Aleksei Kuzmin
parent 4b39d17e5f
commit e24c0dda5d
11 changed files with 62 additions and 44 deletions

View file

@ -2,10 +2,6 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ENABLE_PDF_VIEWER
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
#endif // defined(ENABLE_PDF_VIEWER)
#include "atom/browser/ui/webui/pdf_viewer_handler.h"
#include "atom/common/atom_constants.h"

View file

@ -2,13 +2,13 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ENABLE_PDF_VIEWER
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
#endif // defined(ENABLE_PDF_VIEWER)
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
#define ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
#ifndef ENABLE_PDF_VIEWER
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled") // NOLINT
#endif // defined(ENABLE_PDF_VIEWER)
#include <string>
#include "atom/browser/web_contents_zoom_controller.h"

View file

@ -2,10 +2,6 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ENABLE_PDF_VIEWER
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
#endif // defined(ENABLE_PDF_VIEWER)
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
#include <map>

View file

@ -2,13 +2,13 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ENABLE_PDF_VIEWER
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled")
#endif // defined(ENABLE_PDF_VIEWER)
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
#define ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
#ifndef ENABLE_PDF_VIEWER
#error("This header can only be used when enable_pdf_viewer gyp flag is enabled") // NOLINT
#endif // defined(ENABLE_PDF_VIEWER)
#include <string>
#include "base/macros.h"

View file

@ -0,0 +1,28 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/common/node_includes.h"
#include "native_mate/dictionary.h"
namespace {
bool IsPDFViewerEnabled() {
#if defined(ENABLE_PDF_VIEWER)
return true;
#else
return false;
#endif
}
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_features, Initialize)

View file

@ -53,6 +53,7 @@
V(atom_common_asar) \
V(atom_common_clipboard) \
V(atom_common_crash_reporter) \
V(atom_common_features) \
V(atom_common_native_image) \
V(atom_common_notification) \
V(atom_common_screen) \