build: define compile time features with buildflag header (#14840)
* build: define compile time features with buildflag header * refactor: switch to BUILDFLAG(ENABLE_DESKTOP_CAPTURER) * refactor: switch to BUILDFLAG(ENABLE_RUN_AS_NODE) * refactor: switch to BUILDFLAG(ENABLE_OSR) * refactor: switch to BUILDFLAG(ENABLE_VIEW_API) * refactor: switch to BUILDFLAG(ENABLE_PEPPER_FLASH) * refactor: switch to BUILDFLAG(OVERRIDE_LOCATION_PROVIDER) * refactor: switch to BUILDFLAG(ENABLE_PDF_VIEWER)
This commit is contained in:
parent
4af922c9a2
commit
a24ad6bc14
31 changed files with 172 additions and 209 deletions
54
BUILD.gn
54
BUILD.gn
|
@ -1,5 +1,6 @@
|
||||||
import("build/asar.gni")
|
import("build/asar.gni")
|
||||||
import("build/npm.gni")
|
import("build/npm.gni")
|
||||||
|
import("buildflags/buildflags.gni")
|
||||||
import("electron_paks.gni")
|
import("electron_paks.gni")
|
||||||
import("filenames.gni")
|
import("filenames.gni")
|
||||||
import("//build/config/locales.gni")
|
import("//build/config/locales.gni")
|
||||||
|
@ -30,22 +31,6 @@ electron_project_name = branding.project_name
|
||||||
electron_product_name = branding.product_name
|
electron_product_name = branding.product_name
|
||||||
electron_mac_bundle_id = branding.mac_bundle_id
|
electron_mac_bundle_id = branding.mac_bundle_id
|
||||||
|
|
||||||
declare_args() {
|
|
||||||
enable_desktop_capturer = true
|
|
||||||
enable_run_as_node = true
|
|
||||||
enable_osr = true
|
|
||||||
enable_view_api = false
|
|
||||||
|
|
||||||
# Provide a fake location provider for mocking
|
|
||||||
# the geolocation responses. Disable it if you
|
|
||||||
# need to test with chromium's location provider.
|
|
||||||
# Should not be enabled for release build.
|
|
||||||
enable_fake_location_provider = !is_official_build
|
|
||||||
|
|
||||||
# Enable flash plugin support.
|
|
||||||
enable_pepper_flash = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_mas_build) {
|
if (is_mas_build) {
|
||||||
assert(is_mac,
|
assert(is_mac,
|
||||||
"It doesn't make sense to build a MAS build on a non-mac platform")
|
"It doesn't make sense to build a MAS build on a non-mac platform")
|
||||||
|
@ -58,25 +43,6 @@ config("branding") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("features") {
|
|
||||||
defines = []
|
|
||||||
if (enable_desktop_capturer) {
|
|
||||||
defines += [ "ENABLE_DESKTOP_CAPTURER=1" ]
|
|
||||||
}
|
|
||||||
if (enable_run_as_node) {
|
|
||||||
defines += [ "ENABLE_RUN_AS_NODE=1" ]
|
|
||||||
}
|
|
||||||
if (enable_osr) {
|
|
||||||
defines += [ "ENABLE_OSR=1" ]
|
|
||||||
}
|
|
||||||
if (enable_view_api) {
|
|
||||||
defines += [ "ENABLE_VIEW_API" ]
|
|
||||||
}
|
|
||||||
if (enable_pepper_flash) {
|
|
||||||
defines += [ "ENABLE_PEPPER_FLASH" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
npm_action("atom_browserify_sandbox") {
|
npm_action("atom_browserify_sandbox") {
|
||||||
deps = [
|
deps = [
|
||||||
":atom_js2c_copy",
|
":atom_js2c_copy",
|
||||||
|
@ -95,7 +61,7 @@ npm_action("atom_browserify_sandbox") {
|
||||||
"-r",
|
"-r",
|
||||||
"./lib/sandboxed_renderer/api/exports/child_process.js:child_process",
|
"./lib/sandboxed_renderer/api/exports/child_process.js:child_process",
|
||||||
"-t",
|
"-t",
|
||||||
"aliasify"
|
"aliasify",
|
||||||
]
|
]
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
|
@ -209,14 +175,12 @@ static_library("electron_lib") {
|
||||||
configs += [ "//v8:external_startup_data" ]
|
configs += [ "//v8:external_startup_data" ]
|
||||||
configs += [ "//third_party/electron_node:node_internals" ]
|
configs += [ "//third_party/electron_node:node_internals" ]
|
||||||
|
|
||||||
public_configs = [
|
public_configs = [ ":branding" ]
|
||||||
":branding",
|
|
||||||
":features",
|
|
||||||
]
|
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":atom_js2c",
|
":atom_js2c",
|
||||||
"brightray",
|
"brightray",
|
||||||
|
"buildflags",
|
||||||
"chromium_src:chrome",
|
"chromium_src:chrome",
|
||||||
"native_mate",
|
"native_mate",
|
||||||
"//base",
|
"//base",
|
||||||
|
@ -307,7 +271,6 @@ static_library("electron_lib") {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_fake_location_provider) {
|
if (enable_fake_location_provider) {
|
||||||
defines += [ "OVERRIDE_LOCATION_PROVIDER" ]
|
|
||||||
sources += [
|
sources += [
|
||||||
"atom/browser/fake_location_provider.cc",
|
"atom/browser/fake_location_provider.cc",
|
||||||
"atom/browser/fake_location_provider.h",
|
"atom/browser/fake_location_provider.h",
|
||||||
|
@ -530,7 +493,10 @@ if (is_mac) {
|
||||||
mac_framework_bundle("electron_framework") {
|
mac_framework_bundle("electron_framework") {
|
||||||
output_name = electron_framework_name
|
output_name = electron_framework_name
|
||||||
framework_version = electron_framework_version
|
framework_version = electron_framework_version
|
||||||
framework_contents = [ "Resources", "Libraries" ]
|
framework_contents = [
|
||||||
|
"Resources",
|
||||||
|
"Libraries",
|
||||||
|
]
|
||||||
public_deps = [
|
public_deps = [
|
||||||
":electron_lib",
|
":electron_lib",
|
||||||
]
|
]
|
||||||
|
@ -671,11 +637,11 @@ if (is_mac) {
|
||||||
} else {
|
} else {
|
||||||
windows_manifest("electron_app_manifest") {
|
windows_manifest("electron_app_manifest") {
|
||||||
sources = [
|
sources = [
|
||||||
|
"atom/browser/resources/win/disable_window_filtering.manifest",
|
||||||
|
"atom/browser/resources/win/dpi_aware.manifest",
|
||||||
as_invoker_manifest,
|
as_invoker_manifest,
|
||||||
common_controls_manifest,
|
common_controls_manifest,
|
||||||
default_compatibility_manifest,
|
default_compatibility_manifest,
|
||||||
"atom/browser/resources/win/dpi_aware.manifest",
|
|
||||||
"atom/browser/resources/win/disable_window_filtering.manifest",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "content/public/common/content_constants.h"
|
#include "content/public/common/content_constants.h"
|
||||||
#include "content/public/common/pepper_plugin_info.h"
|
#include "content/public/common/pepper_plugin_info.h"
|
||||||
#include "content/public/common/user_agent.h"
|
#include "content/public/common/user_agent.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
#include "url/url_constants.h"
|
#include "url/url_constants.h"
|
||||||
|
@ -30,10 +31,10 @@
|
||||||
#include "media/base/video_codecs.h"
|
#include "media/base/video_codecs.h"
|
||||||
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
#include "atom/common/atom_constants.h"
|
#include "atom/common/atom_constants.h"
|
||||||
#include "pdf/pdf.h"
|
#include "pdf/pdf.h"
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ bool IsWidevineAvailable(base::FilePath* cdm_path,
|
||||||
}
|
}
|
||||||
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
#endif // defined(WIDEVINE_CDM_AVAILABLE)
|
||||||
|
|
||||||
#if defined(ENABLE_PEPPER_FLASH)
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
|
content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
|
||||||
const std::string& version) {
|
const std::string& version) {
|
||||||
content::PepperPluginInfo plugin;
|
content::PepperPluginInfo plugin;
|
||||||
|
@ -127,10 +128,10 @@ void AddPepperFlashFromCommandLine(
|
||||||
|
|
||||||
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version));
|
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version));
|
||||||
}
|
}
|
||||||
#endif // defined(ENABLE_PEPPER_FLASH)
|
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
|
|
||||||
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
content::PepperPluginInfo pdf_info;
|
content::PepperPluginInfo pdf_info;
|
||||||
pdf_info.is_internal = true;
|
pdf_info.is_internal = true;
|
||||||
pdf_info.is_out_of_process = true;
|
pdf_info.is_out_of_process = true;
|
||||||
|
@ -147,7 +148,7 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
|
||||||
chrome_pdf::PPP_ShutdownModule;
|
chrome_pdf::PPP_ShutdownModule;
|
||||||
pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
|
pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
|
||||||
plugins->push_back(pdf_info);
|
plugins->push_back(pdf_info);
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
||||||
|
@ -198,9 +199,9 @@ void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||||
void AtomContentClient::AddPepperPlugins(
|
void AtomContentClient::AddPepperPlugins(
|
||||||
std::vector<content::PepperPluginInfo>* plugins) {
|
std::vector<content::PepperPluginInfo>* plugins) {
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
#if defined(ENABLE_PEPPER_FLASH)
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
AddPepperFlashFromCommandLine(command_line, plugins);
|
AddPepperFlashFromCommandLine(command_line, plugins);
|
||||||
#endif // defined(ENABLE_PEPPER_FLASH)
|
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
ComputeBuiltInPlugins(plugins);
|
ComputeBuiltInPlugins(plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
#define ATOM_APP_ATOM_LIBRARY_MAIN_H_
|
#define ATOM_APP_ATOM_LIBRARY_MAIN_H_
|
||||||
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
__attribute__((visibility("default"))) int AtomMain(int argc, char* argv[]);
|
__attribute__((visibility("default"))) int AtomMain(int argc, char* argv[]);
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||||
__attribute__((visibility("default"))) int AtomInitializeICUandStartNode(
|
__attribute__((visibility("default"))) int AtomInitializeICUandStartNode(
|
||||||
int argc,
|
int argc,
|
||||||
char* argv[]);
|
char* argv[]);
|
||||||
|
|
|
@ -23,7 +23,7 @@ int AtomMain(int argc, char* argv[]) {
|
||||||
return content::ContentMain(params);
|
return content::ContentMain(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||||
int AtomInitializeICUandStartNode(int argc, char* argv[]) {
|
int AtomInitializeICUandStartNode(int argc, char* argv[]) {
|
||||||
base::AtExitManager atexit_manager;
|
base::AtExitManager atexit_manager;
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
base::mac::ScopedNSAutoreleasePool pool;
|
||||||
|
|
|
@ -35,14 +35,14 @@
|
||||||
#include "atom/common/atom_command_line.h"
|
#include "atom/common/atom_command_line.h"
|
||||||
#include "base/at_exit.h"
|
#include "base/at_exit.h"
|
||||||
#include "base/i18n/icu_util.h"
|
#include "base/i18n/icu_util.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||||
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
|
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_RUN_AS_NODE) || defined(OS_WIN)
|
|
||||||
bool IsEnvSet(const char* name) {
|
bool IsEnvSet(const char* name) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
size_t required_size;
|
size_t required_size;
|
||||||
|
@ -53,7 +53,6 @@ bool IsEnvSet(const char* name) {
|
||||||
return indicator && indicator[0] != '\0';
|
return indicator && indicator[0] != '\0';
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -93,7 +92,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||||
bool run_as_node = IsEnvSet(kRunAsNode);
|
bool run_as_node = IsEnvSet(kRunAsNode);
|
||||||
#else
|
#else
|
||||||
bool run_as_node = false;
|
bool run_as_node = false;
|
||||||
|
@ -120,7 +119,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||||
atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); });
|
atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); });
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||||
if (run_as_node) {
|
if (run_as_node) {
|
||||||
std::vector<char*> argv(arguments.argc);
|
std::vector<char*> argv(arguments.argc);
|
||||||
std::transform(
|
std::transform(
|
||||||
|
@ -156,7 +155,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||||
#elif defined(OS_LINUX) // defined(OS_WIN)
|
#elif defined(OS_LINUX) // defined(OS_WIN)
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||||
if (IsEnvSet(kRunAsNode)) {
|
if (IsEnvSet(kRunAsNode)) {
|
||||||
base::i18n::InitializeICU();
|
base::i18n::InitializeICU();
|
||||||
base::AtExitManager atexit_manager;
|
base::AtExitManager atexit_manager;
|
||||||
|
@ -175,7 +174,7 @@ int main(int argc, char* argv[]) {
|
||||||
#else // defined(OS_LINUX)
|
#else // defined(OS_LINUX)
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
||||||
if (IsEnvSet(kRunAsNode)) {
|
if (IsEnvSet(kRunAsNode)) {
|
||||||
return AtomInitializeICUandStartNode(argc, argv);
|
return AtomInitializeICUandStartNode(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
|
||||||
|
|
||||||
#include "atom/app/node_main.h"
|
#include "atom/app/node_main.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -119,5 +117,3 @@ int NodeMain(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ENABLE_RUN_AS_NODE
|
|
||||||
|
|
|
@ -5,14 +5,10 @@
|
||||||
#ifndef ATOM_APP_NODE_MAIN_H_
|
#ifndef ATOM_APP_NODE_MAIN_H_
|
||||||
#define ATOM_APP_NODE_MAIN_H_
|
#define ATOM_APP_NODE_MAIN_H_
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
int NodeMain(int argc, char* argv[]);
|
int NodeMain(int argc, char* argv[]);
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ENABLE_RUN_AS_NODE
|
|
||||||
|
|
||||||
#endif // ATOM_APP_NODE_MAIN_H_
|
#endif // ATOM_APP_NODE_MAIN_H_
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "native_mate/persistent_dictionary.h"
|
#include "native_mate/persistent_dictionary.h"
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
|
||||||
if (options.Get("parent", &parent) && !parent.IsEmpty())
|
if (options.Get("parent", &parent) && !parent.IsEmpty())
|
||||||
parent_window_.Reset(isolate, parent.ToV8());
|
parent_window_.Reset(isolate, parent.ToV8());
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
// Offscreen windows are always created frameless.
|
// Offscreen windows are always created frameless.
|
||||||
mate::Dictionary web_preferences;
|
mate::Dictionary web_preferences;
|
||||||
bool offscreen;
|
bool offscreen;
|
||||||
|
|
|
@ -23,7 +23,7 @@ View::~View() {
|
||||||
delete view_;
|
delete view_;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_VIEW_API)
|
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||||
void View::SetLayoutManager(mate::Handle<LayoutManager> layout_manager) {
|
void View::SetLayoutManager(mate::Handle<LayoutManager> layout_manager) {
|
||||||
layout_manager_.Reset(isolate(), layout_manager->GetWrapper());
|
layout_manager_.Reset(isolate(), layout_manager->GetWrapper());
|
||||||
view()->SetLayoutManager(layout_manager->TakeOver());
|
view()->SetLayoutManager(layout_manager->TakeOver());
|
||||||
|
@ -53,7 +53,7 @@ mate::WrappableBase* View::New(mate::Arguments* args) {
|
||||||
void View::BuildPrototype(v8::Isolate* isolate,
|
void View::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "View"));
|
prototype->SetClassName(mate::StringToV8(isolate, "View"));
|
||||||
#if defined(ENABLE_VIEW_API)
|
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("setLayoutManager", &View::SetLayoutManager)
|
.SetMethod("setLayoutManager", &View::SetLayoutManager)
|
||||||
.SetMethod("addChildView", &View::AddChildView)
|
.SetMethod("addChildView", &View::AddChildView)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/browser/api/views/atom_api_layout_manager.h"
|
#include "atom/browser/api/views/atom_api_layout_manager.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "ui/views/view.h"
|
#include "ui/views/view.h"
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ class View : public mate::TrackableObject<View> {
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
||||||
#if defined(ENABLE_VIEW_API)
|
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||||
void SetLayoutManager(mate::Handle<LayoutManager> layout_manager);
|
void SetLayoutManager(mate::Handle<LayoutManager> layout_manager);
|
||||||
void AddChildView(mate::Handle<View> view);
|
void AddChildView(mate::Handle<View> view);
|
||||||
void AddChildViewAt(mate::Handle<View> view, size_t index);
|
void AddChildViewAt(mate::Handle<View> view, size_t index);
|
||||||
|
|
|
@ -21,11 +21,6 @@
|
||||||
#include "atom/browser/lib/bluetooth_chooser.h"
|
#include "atom/browser/lib/bluetooth_chooser.h"
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
#include "atom/browser/net/atom_network_delegate.h"
|
#include "atom/browser/net/atom_network_delegate.h"
|
||||||
#if defined(ENABLE_OSR)
|
|
||||||
#include "atom/browser/osr/osr_output_device.h"
|
|
||||||
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
|
||||||
#include "atom/browser/osr/osr_web_contents_view.h"
|
|
||||||
#endif
|
|
||||||
#include "atom/browser/ui/drag_util.h"
|
#include "atom/browser/ui/drag_util.h"
|
||||||
#include "atom/browser/web_contents_permission_helper.h"
|
#include "atom/browser/web_contents_permission_helper.h"
|
||||||
#include "atom/browser/web_contents_preferences.h"
|
#include "atom/browser/web_contents_preferences.h"
|
||||||
|
@ -91,6 +86,12 @@
|
||||||
#include "ui/display/screen.h"
|
#include "ui/display/screen.h"
|
||||||
#include "ui/events/base_event_utils.h"
|
#include "ui/events/base_event_utils.h"
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
|
#include "atom/browser/osr/osr_output_device.h"
|
||||||
|
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
||||||
|
#include "atom/browser/osr/osr_web_contents_view.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -237,7 +238,7 @@ struct Converter<atom::api::WebContents::Type> {
|
||||||
*out = Type::BROWSER_VIEW;
|
*out = Type::BROWSER_VIEW;
|
||||||
} else if (type == "webview") {
|
} else if (type == "webview") {
|
||||||
*out = Type::WEB_VIEW;
|
*out = Type::WEB_VIEW;
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
} else if (type == "offscreen") {
|
} else if (type == "offscreen") {
|
||||||
*out = Type::OFF_SCREEN;
|
*out = Type::OFF_SCREEN;
|
||||||
#endif
|
#endif
|
||||||
|
@ -338,7 +339,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
type_ = BACKGROUND_PAGE;
|
type_ = BACKGROUND_PAGE;
|
||||||
else if (options.Get("isBrowserView", &b) && b)
|
else if (options.Get("isBrowserView", &b) && b)
|
||||||
type_ = BROWSER_VIEW;
|
type_ = BROWSER_VIEW;
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
else if (options.Get(options::kOffscreen, &b) && b)
|
else if (options.Get(options::kOffscreen, &b) && b)
|
||||||
type_ = OFF_SCREEN;
|
type_ = OFF_SCREEN;
|
||||||
#endif
|
#endif
|
||||||
|
@ -372,7 +373,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
new WebViewGuestDelegate(embedder_->web_contents(), this));
|
new WebViewGuestDelegate(embedder_->web_contents(), this));
|
||||||
params.guest_delegate = guest_delegate_.get();
|
params.guest_delegate = guest_delegate_.get();
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
if (embedder_ && embedder_->IsOffScreen()) {
|
if (embedder_ && embedder_->IsOffScreen()) {
|
||||||
auto* view = new OffScreenWebContentsView(
|
auto* view = new OffScreenWebContentsView(
|
||||||
false, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
false, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||||
|
@ -384,7 +385,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
web_contents = content::WebContents::Create(params);
|
web_contents = content::WebContents::Create(params);
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
}
|
}
|
||||||
} else if (IsOffScreen()) {
|
} else if (IsOffScreen()) {
|
||||||
bool transparent = false;
|
bool transparent = false;
|
||||||
|
@ -1605,7 +1606,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
blink::WebMouseEvent mouse_event;
|
blink::WebMouseEvent mouse_event;
|
||||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||||
if (IsOffScreen()) {
|
if (IsOffScreen()) {
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
GetOffScreenRenderWidgetHostView()->SendMouseEvent(mouse_event);
|
GetOffScreenRenderWidgetHostView()->SendMouseEvent(mouse_event);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
@ -1625,7 +1626,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
blink::WebMouseWheelEvent mouse_wheel_event;
|
blink::WebMouseWheelEvent mouse_wheel_event;
|
||||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
|
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
|
||||||
if (IsOffScreen()) {
|
if (IsOffScreen()) {
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
GetOffScreenRenderWidgetHostView()->SendMouseWheelEvent(
|
GetOffScreenRenderWidgetHostView()->SendMouseWheelEvent(
|
||||||
mouse_wheel_event);
|
mouse_wheel_event);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1757,77 +1758,50 @@ void WebContents::AttachToIframe(content::WebContents* embedder_web_contents,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::IsOffScreen() const {
|
bool WebContents::IsOffScreen() const {
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
return type_ == OFF_SCREEN;
|
return type_ == OFF_SCREEN;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
|
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
|
||||||
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
|
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::StartPainting() {
|
void WebContents::StartPainting() {
|
||||||
if (!IsOffScreen())
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
|
||||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||||
if (osr_wcv)
|
if (osr_wcv)
|
||||||
osr_wcv->SetPainting(true);
|
osr_wcv->SetPainting(true);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::StopPainting() {
|
void WebContents::StopPainting() {
|
||||||
if (!IsOffScreen())
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
|
||||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||||
if (osr_wcv)
|
if (osr_wcv)
|
||||||
osr_wcv->SetPainting(false);
|
osr_wcv->SetPainting(false);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::IsPainting() const {
|
bool WebContents::IsPainting() const {
|
||||||
if (!IsOffScreen())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
|
||||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||||
return osr_wcv && osr_wcv->IsPainting();
|
return osr_wcv && osr_wcv->IsPainting();
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::SetFrameRate(int frame_rate) {
|
void WebContents::SetFrameRate(int frame_rate) {
|
||||||
if (!IsOffScreen())
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
|
||||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||||
if (osr_wcv)
|
if (osr_wcv)
|
||||||
osr_wcv->SetFrameRate(frame_rate);
|
osr_wcv->SetFrameRate(frame_rate);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int WebContents::GetFrameRate() const {
|
int WebContents::GetFrameRate() const {
|
||||||
if (!IsOffScreen())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
|
||||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||||
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
|
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void WebContents::Invalidate() {
|
void WebContents::Invalidate() {
|
||||||
if (IsOffScreen()) {
|
if (IsOffScreen()) {
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
auto* osr_rwhv = GetOffScreenRenderWidgetHostView();
|
auto* osr_rwhv = GetOffScreenRenderWidgetHostView();
|
||||||
if (osr_rwhv)
|
if (osr_rwhv)
|
||||||
osr_rwhv->Invalidate();
|
osr_rwhv->Invalidate();
|
||||||
|
@ -2064,11 +2038,13 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("isGuest", &WebContents::IsGuest)
|
.SetMethod("isGuest", &WebContents::IsGuest)
|
||||||
.SetMethod("attachToIframe", &WebContents::AttachToIframe)
|
.SetMethod("attachToIframe", &WebContents::AttachToIframe)
|
||||||
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
|
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
|
||||||
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
.SetMethod("startPainting", &WebContents::StartPainting)
|
.SetMethod("startPainting", &WebContents::StartPainting)
|
||||||
.SetMethod("stopPainting", &WebContents::StopPainting)
|
.SetMethod("stopPainting", &WebContents::StopPainting)
|
||||||
.SetMethod("isPainting", &WebContents::IsPainting)
|
.SetMethod("isPainting", &WebContents::IsPainting)
|
||||||
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
|
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
|
||||||
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
|
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
|
||||||
|
#endif
|
||||||
.SetMethod("invalidate", &WebContents::Invalidate)
|
.SetMethod("invalidate", &WebContents::Invalidate)
|
||||||
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
|
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
|
||||||
.SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
|
.SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
#include "content/public/common/favicon_url.h"
|
#include "content/public/common/favicon_url.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "printing/backend/print_backend.h"
|
#include "printing/backend/print_backend.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
|
@ -49,7 +50,7 @@ class WebContentsZoomController;
|
||||||
class WebViewGuestDelegate;
|
class WebViewGuestDelegate;
|
||||||
class FrameSubscriber;
|
class FrameSubscriber;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
class OffScreenWebContentsView;
|
class OffScreenWebContentsView;
|
||||||
class OffScreenRenderWidgetHostView;
|
class OffScreenRenderWidgetHostView;
|
||||||
#endif
|
#endif
|
||||||
|
@ -208,12 +209,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
|
|
||||||
// Methods for offscreen rendering
|
// Methods for offscreen rendering
|
||||||
bool IsOffScreen() const;
|
bool IsOffScreen() const;
|
||||||
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
||||||
void StartPainting();
|
void StartPainting();
|
||||||
void StopPainting();
|
void StopPainting();
|
||||||
bool IsPainting() const;
|
bool IsPainting() const;
|
||||||
void SetFrameRate(int frame_rate);
|
void SetFrameRate(int frame_rate);
|
||||||
int GetFrameRate() const;
|
int GetFrameRate() const;
|
||||||
|
#endif
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
|
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
|
||||||
|
|
||||||
|
@ -416,7 +419,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
|
|
||||||
uint32_t GetNextRequestId() { return ++request_id_; }
|
uint32_t GetNextRequestId() { return ++request_id_; }
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
|
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
|
||||||
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
|
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
#include "content/public/common/url_constants.h"
|
#include "content/public/common/url_constants.h"
|
||||||
#include "content/public/common/web_preferences.h"
|
#include "content/public/common/web_preferences.h"
|
||||||
#include "device/geolocation/public/cpp/location_provider.h"
|
#include "device/geolocation/public/cpp/location_provider.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "net/base/escape.h"
|
#include "net/base/escape.h"
|
||||||
#include "net/ssl/ssl_cert_request_info.h"
|
#include "net/ssl/ssl_cert_request_info.h"
|
||||||
#include "ppapi/host/ppapi_host.h"
|
#include "ppapi/host/ppapi_host.h"
|
||||||
|
@ -69,13 +70,13 @@
|
||||||
#include "net/ssl/client_cert_store.h"
|
#include "net/ssl/client_cert_store.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_PEPPER_FLASH)
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
|
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
|
||||||
#endif // defined(ENABLE_PEPPER_FLASH)
|
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
|
|
||||||
#if defined(OVERRIDE_LOCATION_PROVIDER)
|
#if BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)
|
||||||
#include "atom/browser/fake_location_provider.h"
|
#include "atom/browser/fake_location_provider.h"
|
||||||
#endif // defined(OVERRIDE_LOCATION_PROVIDER)
|
#endif // BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
|
@ -360,7 +361,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
||||||
#if defined(ENABLE_PEPPER_FLASH)
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
host->GetPpapiHost()->AddHostFactoryFilter(
|
host->GetPpapiHost()->AddHostFactoryFilter(
|
||||||
base::WrapUnique(new ChromeBrowserPepperHostFactory(host)));
|
base::WrapUnique(new ChromeBrowserPepperHostFactory(host)));
|
||||||
#endif
|
#endif
|
||||||
|
@ -510,7 +511,7 @@ std::unique_ptr<net::ClientCertStore> AtomBrowserClient::CreateClientCertStore(
|
||||||
|
|
||||||
std::unique_ptr<device::LocationProvider>
|
std::unique_ptr<device::LocationProvider>
|
||||||
AtomBrowserClient::OverrideSystemLocationProvider() {
|
AtomBrowserClient::OverrideSystemLocationProvider() {
|
||||||
#if defined(OVERRIDE_LOCATION_PROVIDER)
|
#if BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)
|
||||||
return std::make_unique<FakeLocationProvider>();
|
return std::make_unique<FakeLocationProvider>();
|
||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "content/public/browser/child_process_security_policy.h"
|
#include "content/public/browser/child_process_security_policy.h"
|
||||||
#include "content/public/common/result_codes.h"
|
#include "content/public/common/result_codes.h"
|
||||||
#include "content/public/common/service_manager_connection.h"
|
#include "content/public/common/service_manager_connection.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "services/device/public/mojom/constants.mojom.h"
|
#include "services/device/public/mojom/constants.mojom.h"
|
||||||
#include "services/service_manager/public/cpp/connector.h"
|
#include "services/service_manager/public/cpp/connector.h"
|
||||||
#include "ui/base/idle/idle.h"
|
#include "ui/base/idle/idle.h"
|
||||||
|
@ -33,9 +34,9 @@
|
||||||
#include "ui/events/devices/x11/touch_factory_x11.h"
|
#include "ui/events/devices/x11/touch_factory_x11.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
#include "atom/browser/atom_web_ui_controller_factory.h"
|
#include "atom/browser/atom_web_ui_controller_factory.h"
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
#include "atom/browser/ui/cocoa/views_delegate_mac.h"
|
#include "atom/browser/ui/cocoa/views_delegate_mac.h"
|
||||||
|
@ -206,10 +207,10 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
base::Bind(&v8::Isolate::LowMemoryNotification,
|
base::Bind(&v8::Isolate::LowMemoryNotification,
|
||||||
base::Unretained(js_env_->isolate())));
|
base::Unretained(js_env_->isolate())));
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
content::WebUIControllerFactory::RegisterFactory(
|
content::WebUIControllerFactory::RegisterFactory(
|
||||||
AtomWebUIControllerFactory::GetInstance());
|
AtomWebUIControllerFactory::GetInstance());
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
||||||
bridge_task_runner_->MessageLoopIsReady();
|
bridge_task_runner_->MessageLoopIsReady();
|
||||||
|
|
|
@ -10,15 +10,16 @@
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/download_manager.h"
|
#include "content/public/browser/download_manager.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "net/base/escape.h"
|
#include "net/base/escape.h"
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
#include "atom/common/atom_constants.h"
|
#include "atom/common/atom_constants.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "content/public/browser/stream_info.h"
|
#include "content/public/browser/stream_info.h"
|
||||||
#include "net/url_request/url_request.h"
|
#include "net/url_request/url_request.h"
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
void OnPdfResourceIntercepted(
|
void OnPdfResourceIntercepted(
|
||||||
const GURL& original_url,
|
const GURL& original_url,
|
||||||
int render_process_host_id,
|
int render_process_host_id,
|
||||||
|
@ -65,7 +66,7 @@ void OnPdfResourceIntercepted(
|
||||||
params.frame_tree_node_id = frame_host->GetFrameTreeNodeId();
|
params.frame_tree_node_id = frame_host->GetFrameTreeNodeId();
|
||||||
web_contents->GetController().LoadURLWithParams(params);
|
web_contents->GetController().LoadURLWithParams(params);
|
||||||
}
|
}
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||||
const std::string& mime_type,
|
const std::string& mime_type,
|
||||||
GURL* origin,
|
GURL* origin,
|
||||||
std::string* payload) {
|
std::string* payload) {
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
const content::ResourceRequestInfo* info =
|
const content::ResourceRequestInfo* info =
|
||||||
content::ResourceRequestInfo::ForRequest(request);
|
content::ResourceRequestInfo::ForRequest(request);
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||||
info->GetWebContentsGetterForRequest()));
|
info->GetWebContentsGetterForRequest()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,16 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#include "electron/buildflags/buildflags.h"
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
|
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
|
||||||
#include "atom/common/atom_constants.h"
|
#include "atom/common/atom_constants.h"
|
||||||
#include "base/strings/string_split.h"
|
#include "base/strings/string_split.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "net/base/escape.h"
|
#include "net/base/escape.h"
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -29,11 +31,11 @@ AtomWebUIControllerFactory::~AtomWebUIControllerFactory() {}
|
||||||
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
|
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
|
||||||
content::BrowserContext* browser_context,
|
content::BrowserContext* browser_context,
|
||||||
const GURL& url) const {
|
const GURL& url) const {
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
if (url.host() == kPdfViewerUIHost) {
|
if (url.host() == kPdfViewerUIHost) {
|
||||||
return const_cast<AtomWebUIControllerFactory*>(this);
|
return const_cast<AtomWebUIControllerFactory*>(this);
|
||||||
}
|
}
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
return content::WebUI::kNoWebUI;
|
return content::WebUI::kNoWebUI;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +55,7 @@ bool AtomWebUIControllerFactory::UseWebUIBindingsForURL(
|
||||||
content::WebUIController*
|
content::WebUIController*
|
||||||
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
||||||
const GURL& url) const {
|
const GURL& url) const {
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
if (url.host() == kPdfViewerUIHost) {
|
if (url.host() == kPdfViewerUIHost) {
|
||||||
base::StringPairs toplevel_params;
|
base::StringPairs toplevel_params;
|
||||||
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
|
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
|
||||||
|
@ -75,7 +77,7 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
||||||
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
|
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
|
||||||
return new PdfViewerUI(browser_context, web_ui, src);
|
return new PdfViewerUI(browser_context, web_ui, src);
|
||||||
}
|
}
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "atom/browser/native_window_views.h"
|
#include "atom/browser/native_window_views.h"
|
||||||
#include "atom/browser/ui/autofill_popup.h"
|
#include "atom/browser/ui/autofill_popup.h"
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "ui/display/display.h"
|
#include "ui/display/display.h"
|
||||||
#include "ui/display/screen.h"
|
#include "ui/display/screen.h"
|
||||||
#include "ui/gfx/geometry/point.h"
|
#include "ui/gfx/geometry/point.h"
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
#include "ui/gfx/geometry/vector2d.h"
|
#include "ui/gfx/geometry/vector2d.h"
|
||||||
#include "ui/gfx/text_utils.h"
|
#include "ui/gfx/text_utils.h"
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
#include "atom/browser/osr/osr_render_widget_host_view.h"
|
||||||
#include "atom/browser/osr/osr_view_proxy.h"
|
#include "atom/browser/osr/osr_view_proxy.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -135,7 +136,7 @@ void AutofillPopup::CreateView(content::RenderFrameHost* frame_host,
|
||||||
view_ = new AutofillPopupView(this, parent->GetWidget());
|
view_ = new AutofillPopupView(this, parent->GetWidget());
|
||||||
view_->Show();
|
view_->Show();
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
if (offscreen) {
|
if (offscreen) {
|
||||||
auto* rwhv = frame_host->GetView();
|
auto* rwhv = frame_host->GetView();
|
||||||
if (embedder_frame_host != nullptr) {
|
if (embedder_frame_host != nullptr) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ AutofillPopupView::~AutofillPopupView() {
|
||||||
|
|
||||||
RemoveObserver();
|
RemoveObserver();
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
if (view_proxy_.get()) {
|
if (view_proxy_.get()) {
|
||||||
view_proxy_->ResetView();
|
view_proxy_->ResetView();
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ void AutofillPopupView::DoUpdateBoundsAndRedrawPopup() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GetWidget()->SetBounds(popup_->popup_bounds_);
|
GetWidget()->SetBounds(popup_->popup_bounds_);
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
if (view_proxy_.get()) {
|
if (view_proxy_.get()) {
|
||||||
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
|
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
|
||||||
gfx::Canvas* draw_canvas = canvas;
|
gfx::Canvas* draw_canvas = canvas;
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
std::unique_ptr<cc::SkiaPaintCanvas> paint_canvas;
|
std::unique_ptr<cc::SkiaPaintCanvas> paint_canvas;
|
||||||
if (view_proxy_.get()) {
|
if (view_proxy_.get()) {
|
||||||
bitmap.allocN32Pixels(popup_->popup_bounds_in_view().width(),
|
bitmap.allocN32Pixels(popup_->popup_bounds_in_view().width(),
|
||||||
|
@ -260,7 +260,7 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
|
||||||
DrawAutofillEntry(draw_canvas, i, line_rect);
|
DrawAutofillEntry(draw_canvas, i, line_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
if (view_proxy_.get()) {
|
if (view_proxy_.get()) {
|
||||||
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
|
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
|
||||||
view_proxy_->SetBitmap(bitmap);
|
view_proxy_->SetBitmap(bitmap);
|
||||||
|
|
|
@ -9,18 +9,20 @@
|
||||||
|
|
||||||
#include "atom/browser/ui/autofill_popup.h"
|
#include "atom/browser/ui/autofill_popup.h"
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
|
||||||
#include "atom/browser/osr/osr_view_proxy.h"
|
|
||||||
#endif
|
|
||||||
#include "base/optional.h"
|
#include "base/optional.h"
|
||||||
#include "content/public/browser/native_web_keyboard_event.h"
|
#include "content/public/browser/native_web_keyboard_event.h"
|
||||||
#include "content/public/browser/render_widget_host.h"
|
#include "content/public/browser/render_widget_host.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "ui/accessibility/ax_node_data.h"
|
#include "ui/accessibility/ax_node_data.h"
|
||||||
#include "ui/views/drag_controller.h"
|
#include "ui/views/drag_controller.h"
|
||||||
#include "ui/views/focus/widget_focus_manager.h"
|
#include "ui/views/focus/widget_focus_manager.h"
|
||||||
#include "ui/views/widget/widget_delegate.h"
|
#include "ui/views/widget/widget_delegate.h"
|
||||||
#include "ui/views/widget/widget_observer.h"
|
#include "ui/views/widget/widget_observer.h"
|
||||||
|
|
||||||
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
|
#include "atom/browser/osr/osr_view_proxy.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
const int kPopupBorderThickness = 1;
|
const int kPopupBorderThickness = 1;
|
||||||
|
@ -137,7 +139,7 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
||||||
// The index of the currently selected line
|
// The index of the currently selected line
|
||||||
base::Optional<int> selected_line_;
|
base::Optional<int> selected_line_;
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if BUILDFLAG(ENABLE_OSR)
|
||||||
std::unique_ptr<OffscreenViewProxy> view_proxy_;
|
std::unique_ptr<OffscreenViewProxy> view_proxy_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_HANDLER_H_
|
||||||
#define 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 <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
|
#ifndef ATOM_BROWSER_UI_WEBUI_PDF_VIEWER_UI_H_
|
||||||
#define 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 <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#include "atom/common/node_includes.h" // NOLINT(build/include_alpha)
|
#include "atom/common/node_includes.h" // NOLINT(build/include_alpha)
|
||||||
|
@ -10,43 +11,23 @@
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsDesktopCapturerEnabled() {
|
bool IsDesktopCapturerEnabled() {
|
||||||
#if defined(ENABLE_DESKTOP_CAPTURER)
|
return BUILDFLAG(ENABLE_DESKTOP_CAPTURER);
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsOffscreenRenderingEnabled() {
|
bool IsOffscreenRenderingEnabled() {
|
||||||
#if defined(ENABLE_OSR)
|
return BUILDFLAG(ENABLE_OSR);
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsPDFViewerEnabled() {
|
bool IsPDFViewerEnabled() {
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
return BUILDFLAG(ENABLE_PDF_VIEWER);
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsFakeLocationProviderEnabled() {
|
bool IsFakeLocationProviderEnabled() {
|
||||||
#if defined(OVERRIDE_LOCATION_PROVIDER)
|
return BUILDFLAG(OVERRIDE_LOCATION_PROVIDER);
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsViewApiEnabled() {
|
bool IsViewApiEnabled() {
|
||||||
#if defined(ENABLE_VIEW_API)
|
return BUILDFLAG(ENABLE_VIEW_API);
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
|
|
|
@ -24,13 +24,13 @@ const char kSecureProtocolDescription[] =
|
||||||
"The connection to this site is using a strong protocol version "
|
"The connection to this site is using a strong protocol version "
|
||||||
"and cipher suite.";
|
"and cipher suite.";
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
const char kPdfPluginMimeType[] = "application/x-google-chrome-pdf";
|
const char kPdfPluginMimeType[] = "application/x-google-chrome-pdf";
|
||||||
const char kPdfPluginPath[] = "chrome://pdf-viewer/";
|
const char kPdfPluginPath[] = "chrome://pdf-viewer/";
|
||||||
const char kPdfPluginSrc[] = "src";
|
const char kPdfPluginSrc[] = "src";
|
||||||
|
|
||||||
const char kPdfViewerUIOrigin[] = "chrome://pdf-viewer/";
|
const char kPdfViewerUIOrigin[] = "chrome://pdf-viewer/";
|
||||||
const char kPdfViewerUIHost[] = "pdf-viewer";
|
const char kPdfViewerUIHost[] = "pdf-viewer";
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef ATOM_COMMON_ATOM_CONSTANTS_H_
|
#ifndef ATOM_COMMON_ATOM_CONSTANTS_H_
|
||||||
#define ATOM_COMMON_ATOM_CONSTANTS_H_
|
#define ATOM_COMMON_ATOM_CONSTANTS_H_
|
||||||
|
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
// Header to ignore CORS.
|
// Header to ignore CORS.
|
||||||
|
@ -20,7 +22,7 @@ extern const char kValidCertificateDescription[];
|
||||||
extern const char kSecureProtocol[];
|
extern const char kSecureProtocol[];
|
||||||
extern const char kSecureProtocolDescription[];
|
extern const char kSecureProtocolDescription[];
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
// The MIME type used for the PDF plugin.
|
// The MIME type used for the PDF plugin.
|
||||||
extern const char kPdfPluginMimeType[];
|
extern const char kPdfPluginMimeType[];
|
||||||
extern const char kPdfPluginPath[];
|
extern const char kPdfPluginPath[];
|
||||||
|
@ -29,7 +31,7 @@ extern const char kPdfPluginSrc[];
|
||||||
// Constants for PDF viewer webui.
|
// Constants for PDF viewer webui.
|
||||||
extern const char kPdfViewerUIOrigin[];
|
extern const char kPdfViewerUIOrigin[];
|
||||||
extern const char kPdfViewerUIHost[];
|
extern const char kPdfViewerUIHost[];
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "base/trace_event/trace_event.h"
|
#include "base/trace_event/trace_event.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/common/content_paths.h"
|
#include "content/public/common/content_paths.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
@ -81,10 +82,10 @@
|
||||||
// implementation when calling the NODE_BUILTIN_MODULE_CONTEXT_AWARE.
|
// implementation when calling the NODE_BUILTIN_MODULE_CONTEXT_AWARE.
|
||||||
#define V(modname) void _register_##modname();
|
#define V(modname) void _register_##modname();
|
||||||
ELECTRON_BUILTIN_MODULES(V)
|
ELECTRON_BUILTIN_MODULES(V)
|
||||||
#if defined(ENABLE_VIEW_API)
|
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||||
ELECTRON_VIEW_MODULES(V)
|
ELECTRON_VIEW_MODULES(V)
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_DESKTOP_CAPTURER)
|
#if BUILDFLAG(ENABLE_DESKTOP_CAPTURER)
|
||||||
ELECTRON_DESKTOP_CAPTURER_MODULE(V)
|
ELECTRON_DESKTOP_CAPTURER_MODULE(V)
|
||||||
#endif
|
#endif
|
||||||
#undef V
|
#undef V
|
||||||
|
@ -182,10 +183,10 @@ NodeBindings::~NodeBindings() {
|
||||||
void NodeBindings::RegisterBuiltinModules() {
|
void NodeBindings::RegisterBuiltinModules() {
|
||||||
#define V(modname) _register_##modname();
|
#define V(modname) _register_##modname();
|
||||||
ELECTRON_BUILTIN_MODULES(V)
|
ELECTRON_BUILTIN_MODULES(V)
|
||||||
#if defined(ENABLE_VIEW_API)
|
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||||
ELECTRON_VIEW_MODULES(V)
|
ELECTRON_VIEW_MODULES(V)
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_DESKTOP_CAPTURER)
|
#if BUILDFLAG(ENABLE_DESKTOP_CAPTURER)
|
||||||
ELECTRON_DESKTOP_CAPTURER_MODULE(V)
|
ELECTRON_DESKTOP_CAPTURER_MODULE(V)
|
||||||
#endif
|
#endif
|
||||||
#undef V
|
#undef V
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "third_party/blink/public/web/blink.h"
|
#include "third_party/blink/public/web/blink.h"
|
||||||
#include "third_party/blink/public/web/web_custom_element.h" // NOLINT(build/include_alpha)
|
#include "third_party/blink/public/web/web_custom_element.h" // NOLINT(build/include_alpha)
|
||||||
|
@ -42,13 +43,13 @@
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
#include "atom/common/atom_constants.h"
|
#include "atom/common/atom_constants.h"
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
#if defined(ENABLE_PEPPER_FLASH)
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
#include "chrome/renderer/pepper/pepper_helper.h"
|
#include "chrome/renderer/pepper/pepper_helper.h"
|
||||||
#endif // defined(ENABLE_PEPPER_FLASH)
|
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -165,17 +166,17 @@ void RendererClientBase::RenderFrameCreated(
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
new AutofillAgent(render_frame);
|
new AutofillAgent(render_frame);
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_PEPPER_FLASH)
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||||
new PepperHelper(render_frame);
|
new PepperHelper(render_frame);
|
||||||
#endif
|
#endif
|
||||||
new ContentSettingsObserver(render_frame);
|
new ContentSettingsObserver(render_frame);
|
||||||
new printing::PrintWebViewHelper(render_frame);
|
new printing::PrintWebViewHelper(render_frame);
|
||||||
|
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
// Allow access to file scheme from pdf viewer.
|
// Allow access to file scheme from pdf viewer.
|
||||||
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
||||||
GURL(kPdfViewerUIOrigin), "file", "", true);
|
GURL(kPdfViewerUIOrigin), "file", "", true);
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
||||||
|
@ -212,9 +213,9 @@ bool RendererClientBase::OverrideCreatePlugin(
|
||||||
blink::WebPlugin** plugin) {
|
blink::WebPlugin** plugin) {
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
if (params.mime_type.Utf8() == content::kBrowserPluginMimeType ||
|
if (params.mime_type.Utf8() == content::kBrowserPluginMimeType ||
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
params.mime_type.Utf8() == kPdfPluginMimeType ||
|
params.mime_type.Utf8() == kPdfPluginMimeType ||
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
command_line->HasSwitch(switches::kEnablePlugins))
|
command_line->HasSwitch(switches::kEnablePlugins))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "brightray/browser/browser_client.h"
|
#include "brightray/browser/browser_client.h"
|
||||||
#include "brightray/common/content_client.h"
|
#include "brightray/common/content_client.h"
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
#include "ui/base/resource/resource_bundle.h"
|
||||||
#include "ui/base/ui_base_switches.h"
|
#include "ui/base/ui_base_switches.h"
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ void LoadResourceBundle(const std::string& locale) {
|
||||||
bundle.ReloadLocaleResources(locale);
|
bundle.ReloadLocaleResources(locale);
|
||||||
bundle.AddDataPackFromPath(pak_dir.Append(FILE_PATH_LITERAL("resources.pak")),
|
bundle.AddDataPackFromPath(pak_dir.Append(FILE_PATH_LITERAL("resources.pak")),
|
||||||
ui::SCALE_FACTOR_NONE);
|
ui::SCALE_FACTOR_NONE);
|
||||||
#if defined(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
NOTIMPLEMENTED()
|
NOTIMPLEMENTED()
|
||||||
<< "Hi, whoever's fixing PDF support! Thanks! The pdf "
|
<< "Hi, whoever's fixing PDF support! Thanks! The pdf "
|
||||||
"viewer resources haven't been ported over to the GN build yet, so "
|
"viewer resources haven't been ported over to the GN build yet, so "
|
||||||
|
@ -68,7 +69,7 @@ void LoadResourceBundle(const std::string& locale) {
|
||||||
bundle.AddDataPackFromPath(
|
bundle.AddDataPackFromPath(
|
||||||
pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")),
|
pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")),
|
||||||
ui::GetSupportedScaleFactors()[0]);
|
ui::GetSupportedScaleFactors()[0]);
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
}
|
}
|
||||||
|
|
||||||
MainDelegate::MainDelegate() {}
|
MainDelegate::MainDelegate() {}
|
||||||
|
|
20
buildflags/BUILD.gn
Normal file
20
buildflags/BUILD.gn
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (c) 2018 GitHub, Inc.
|
||||||
|
# Use of this source code is governed by the MIT license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
import("//build/buildflag_header.gni")
|
||||||
|
import("//electron/buildflags/buildflags.gni")
|
||||||
|
|
||||||
|
buildflag_header("buildflags") {
|
||||||
|
header = "buildflags.h"
|
||||||
|
|
||||||
|
flags = [
|
||||||
|
"ENABLE_DESKTOP_CAPTURER=$enable_desktop_capturer",
|
||||||
|
"ENABLE_RUN_AS_NODE=$enable_run_as_node",
|
||||||
|
"ENABLE_OSR=$enable_osr",
|
||||||
|
"ENABLE_VIEW_API=$enable_view_api",
|
||||||
|
"ENABLE_PEPPER_FLASH=$enable_pepper_flash",
|
||||||
|
"ENABLE_PDF_VIEWER=$enable_pdf_viewer",
|
||||||
|
"OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider",
|
||||||
|
]
|
||||||
|
}
|
25
buildflags/buildflags.gni
Normal file
25
buildflags/buildflags.gni
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Copyright (c) 2018 GitHub, Inc.
|
||||||
|
# Use of this source code is governed by the MIT license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
declare_args() {
|
||||||
|
enable_desktop_capturer = true
|
||||||
|
|
||||||
|
# Allow running Electron as a node binary.
|
||||||
|
enable_run_as_node = true
|
||||||
|
|
||||||
|
enable_osr = true
|
||||||
|
|
||||||
|
enable_view_api = false
|
||||||
|
|
||||||
|
enable_pdf_viewer = false
|
||||||
|
|
||||||
|
# Provide a fake location provider for mocking
|
||||||
|
# the geolocation responses. Disable it if you
|
||||||
|
# need to test with chromium's location provider.
|
||||||
|
# Should not be enabled for release build.
|
||||||
|
enable_fake_location_provider = !is_official_build
|
||||||
|
|
||||||
|
# Enable flash plugin support.
|
||||||
|
enable_pepper_flash = true
|
||||||
|
}
|
|
@ -2,10 +2,6 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// 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 "components/pdf/renderer/pepper_pdf_host.h"
|
#include "components/pdf/renderer/pepper_pdf_host.h"
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// 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 COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
#ifndef COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
||||||
#define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
#define COMPONENTS_PDF_RENDERER_PEPPER_PDF_HOST_H_
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue