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
|
@ -19,6 +19,7 @@
|
|||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/persistent_dictionary.h"
|
||||
|
||||
|
@ -79,7 +80,7 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
|
|||
if (options.Get("parent", &parent) && !parent.IsEmpty())
|
||||
parent_window_.Reset(isolate, parent.ToV8());
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
// Offscreen windows are always created frameless.
|
||||
mate::Dictionary web_preferences;
|
||||
bool offscreen;
|
||||
|
|
|
@ -23,7 +23,7 @@ View::~View() {
|
|||
delete view_;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||
void View::SetLayoutManager(mate::Handle<LayoutManager> layout_manager) {
|
||||
layout_manager_.Reset(isolate(), layout_manager->GetWrapper());
|
||||
view()->SetLayoutManager(layout_manager->TakeOver());
|
||||
|
@ -53,7 +53,7 @@ mate::WrappableBase* View::New(mate::Arguments* args) {
|
|||
void View::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "View"));
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("setLayoutManager", &View::SetLayoutManager)
|
||||
.SetMethod("addChildView", &View::AddChildView)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/views/atom_api_layout_manager.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "ui/views/view.h"
|
||||
|
||||
|
@ -23,7 +24,7 @@ class View : public mate::TrackableObject<View> {
|
|||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
#if BUILDFLAG(ENABLE_VIEW_API)
|
||||
void SetLayoutManager(mate::Handle<LayoutManager> layout_manager);
|
||||
void AddChildView(mate::Handle<View> view);
|
||||
void AddChildViewAt(mate::Handle<View> view, size_t index);
|
||||
|
|
|
@ -21,11 +21,6 @@
|
|||
#include "atom/browser/lib/bluetooth_chooser.h"
|
||||
#include "atom/browser/native_window.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/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
|
@ -91,6 +86,12 @@
|
|||
#include "ui/display/screen.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)
|
||||
#include "ui/aura/window.h"
|
||||
#endif
|
||||
|
@ -237,7 +238,7 @@ struct Converter<atom::api::WebContents::Type> {
|
|||
*out = Type::BROWSER_VIEW;
|
||||
} else if (type == "webview") {
|
||||
*out = Type::WEB_VIEW;
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
} else if (type == "offscreen") {
|
||||
*out = Type::OFF_SCREEN;
|
||||
#endif
|
||||
|
@ -338,7 +339,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
type_ = BACKGROUND_PAGE;
|
||||
else if (options.Get("isBrowserView", &b) && b)
|
||||
type_ = BROWSER_VIEW;
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
else if (options.Get(options::kOffscreen, &b) && b)
|
||||
type_ = OFF_SCREEN;
|
||||
#endif
|
||||
|
@ -372,7 +373,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
new WebViewGuestDelegate(embedder_->web_contents(), this));
|
||||
params.guest_delegate = guest_delegate_.get();
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
if (embedder_ && embedder_->IsOffScreen()) {
|
||||
auto* view = new OffScreenWebContentsView(
|
||||
false, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||
|
@ -384,7 +385,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
} else {
|
||||
#endif
|
||||
web_contents = content::WebContents::Create(params);
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
}
|
||||
} else if (IsOffScreen()) {
|
||||
bool transparent = false;
|
||||
|
@ -1605,7 +1606,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
|||
blink::WebMouseEvent mouse_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||
if (IsOffScreen()) {
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
GetOffScreenRenderWidgetHostView()->SendMouseEvent(mouse_event);
|
||||
#endif
|
||||
} else {
|
||||
|
@ -1625,7 +1626,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
|||
blink::WebMouseWheelEvent mouse_wheel_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
|
||||
if (IsOffScreen()) {
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
GetOffScreenRenderWidgetHostView()->SendMouseWheelEvent(
|
||||
mouse_wheel_event);
|
||||
#endif
|
||||
|
@ -1757,77 +1758,50 @@ void WebContents::AttachToIframe(content::WebContents* embedder_web_contents,
|
|||
}
|
||||
|
||||
bool WebContents::IsOffScreen() const {
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
return type_ == OFF_SCREEN;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
|
||||
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
}
|
||||
|
||||
void WebContents::StartPainting() {
|
||||
if (!IsOffScreen())
|
||||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetPainting(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebContents::StopPainting() {
|
||||
if (!IsOffScreen())
|
||||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetPainting(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WebContents::IsPainting() const {
|
||||
if (!IsOffScreen())
|
||||
return false;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||
return osr_wcv && osr_wcv->IsPainting();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebContents::SetFrameRate(int frame_rate) {
|
||||
if (!IsOffScreen())
|
||||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetFrameRate(frame_rate);
|
||||
#endif
|
||||
}
|
||||
|
||||
int WebContents::GetFrameRate() const {
|
||||
if (!IsOffScreen())
|
||||
return 0;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_wcv = GetOffScreenWebContentsView();
|
||||
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebContents::Invalidate() {
|
||||
if (IsOffScreen()) {
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
auto* osr_rwhv = GetOffScreenRenderWidgetHostView();
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->Invalidate();
|
||||
|
@ -2064,11 +2038,13 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("isGuest", &WebContents::IsGuest)
|
||||
.SetMethod("attachToIframe", &WebContents::AttachToIframe)
|
||||
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
.SetMethod("startPainting", &WebContents::StartPainting)
|
||||
.SetMethod("stopPainting", &WebContents::StopPainting)
|
||||
.SetMethod("isPainting", &WebContents::IsPainting)
|
||||
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
|
||||
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
|
||||
#endif
|
||||
.SetMethod("invalidate", &WebContents::Invalidate)
|
||||
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
|
||||
.SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/common/favicon_url.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "printing/backend/print_backend.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
@ -49,7 +50,7 @@ class WebContentsZoomController;
|
|||
class WebViewGuestDelegate;
|
||||
class FrameSubscriber;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
class OffScreenWebContentsView;
|
||||
class OffScreenRenderWidgetHostView;
|
||||
#endif
|
||||
|
@ -208,12 +209,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
|
||||
// Methods for offscreen rendering
|
||||
bool IsOffScreen() const;
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
||||
void StartPainting();
|
||||
void StopPainting();
|
||||
bool IsPainting() const;
|
||||
void SetFrameRate(int frame_rate);
|
||||
int GetFrameRate() const;
|
||||
#endif
|
||||
void Invalidate();
|
||||
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
|
||||
|
||||
|
@ -416,7 +419,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
|
||||
uint32_t GetNextRequestId() { return ++request_id_; }
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
|
||||
OffScreenRenderWidgetHostView* GetOffScreenRenderWidgetHostView() const;
|
||||
#endif
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "content/public/common/url_constants.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "device/geolocation/public/cpp/location_provider.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
#include "ppapi/host/ppapi_host.h"
|
||||
|
@ -69,13 +70,13 @@
|
|||
#include "net/ssl/client_cert_store.h"
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_PEPPER_FLASH)
|
||||
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
#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"
|
||||
#endif // defined(OVERRIDE_LOCATION_PROVIDER)
|
||||
#endif // BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
|
@ -360,7 +361,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
|||
}
|
||||
|
||||
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
||||
#if defined(ENABLE_PEPPER_FLASH)
|
||||
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
host->GetPpapiHost()->AddHostFactoryFilter(
|
||||
base::WrapUnique(new ChromeBrowserPepperHostFactory(host)));
|
||||
#endif
|
||||
|
@ -510,7 +511,7 @@ std::unique_ptr<net::ClientCertStore> AtomBrowserClient::CreateClientCertStore(
|
|||
|
||||
std::unique_ptr<device::LocationProvider>
|
||||
AtomBrowserClient::OverrideSystemLocationProvider() {
|
||||
#if defined(OVERRIDE_LOCATION_PROVIDER)
|
||||
#if BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)
|
||||
return std::make_unique<FakeLocationProvider>();
|
||||
#else
|
||||
return nullptr;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "content/public/common/service_manager_connection.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "services/device/public/mojom/constants.mojom.h"
|
||||
#include "services/service_manager/public/cpp/connector.h"
|
||||
#include "ui/base/idle/idle.h"
|
||||
|
@ -33,9 +34,9 @@
|
|||
#include "ui/events/devices/x11/touch_factory_x11.h"
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
#include "atom/browser/atom_web_ui_controller_factory.h"
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "atom/browser/ui/cocoa/views_delegate_mac.h"
|
||||
|
@ -206,10 +207,10 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
|||
base::Bind(&v8::Isolate::LowMemoryNotification,
|
||||
base::Unretained(js_env_->isolate())));
|
||||
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
content::WebUIControllerFactory::RegisterFactory(
|
||||
AtomWebUIControllerFactory::GetInstance());
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
brightray::BrowserMainParts::PreMainMessageLoopRun();
|
||||
bridge_task_runner_->MessageLoopIsReady();
|
||||
|
|
|
@ -10,15 +10,16 @@
|
|||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "content/public/browser/stream_info.h"
|
||||
#include "net/url_request/url_request.h"
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
|
@ -26,7 +27,7 @@ namespace atom {
|
|||
|
||||
namespace {
|
||||
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
void OnPdfResourceIntercepted(
|
||||
const GURL& original_url,
|
||||
int render_process_host_id,
|
||||
|
@ -65,7 +66,7 @@ void OnPdfResourceIntercepted(
|
|||
params.frame_tree_node_id = frame_host->GetFrameTreeNodeId();
|
||||
web_contents->GetController().LoadURLWithParams(params);
|
||||
}
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -76,7 +77,7 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
|||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) {
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
const content::ResourceRequestInfo* info =
|
||||
content::ResourceRequestInfo::ForRequest(request);
|
||||
|
||||
|
@ -96,7 +97,7 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
|||
info->GetWebContentsGetterForRequest()));
|
||||
return true;
|
||||
}
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
|
||||
#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/common/atom_constants.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "net/base/escape.h"
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -29,11 +31,11 @@ AtomWebUIControllerFactory::~AtomWebUIControllerFactory() {}
|
|||
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& url) const {
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
if (url.host() == kPdfViewerUIHost) {
|
||||
return const_cast<AtomWebUIControllerFactory*>(this);
|
||||
}
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
return content::WebUI::kNoWebUI;
|
||||
}
|
||||
|
@ -53,7 +55,7 @@ bool AtomWebUIControllerFactory::UseWebUIBindingsForURL(
|
|||
content::WebUIController*
|
||||
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
|
||||
const GURL& url) const {
|
||||
#if defined(ENABLE_PDF_VIEWER)
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
if (url.host() == kPdfViewerUIHost) {
|
||||
base::StringPairs 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();
|
||||
return new PdfViewerUI(browser_context, web_ui, src);
|
||||
}
|
||||
#endif // defined(ENABLE_PDF_VIEWER)
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "atom/browser/native_window_views.h"
|
||||
#include "atom/browser/ui/autofill_popup.h"
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
@ -17,7 +18,7 @@
|
|||
#include "ui/gfx/geometry/vector2d.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_view_proxy.h"
|
||||
#endif
|
||||
|
@ -135,7 +136,7 @@ void AutofillPopup::CreateView(content::RenderFrameHost* frame_host,
|
|||
view_ = new AutofillPopupView(this, parent->GetWidget());
|
||||
view_->Show();
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
if (offscreen) {
|
||||
auto* rwhv = frame_host->GetView();
|
||||
if (embedder_frame_host != nullptr) {
|
||||
|
|
|
@ -44,7 +44,7 @@ AutofillPopupView::~AutofillPopupView() {
|
|||
|
||||
RemoveObserver();
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
if (view_proxy_.get()) {
|
||||
view_proxy_->ResetView();
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ void AutofillPopupView::DoUpdateBoundsAndRedrawPopup() {
|
|||
return;
|
||||
|
||||
GetWidget()->SetBounds(popup_->popup_bounds_);
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
if (view_proxy_.get()) {
|
||||
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
|
|||
gfx::Canvas* draw_canvas = canvas;
|
||||
SkBitmap bitmap;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
std::unique_ptr<cc::SkiaPaintCanvas> paint_canvas;
|
||||
if (view_proxy_.get()) {
|
||||
bitmap.allocN32Pixels(popup_->popup_bounds_in_view().width(),
|
||||
|
@ -260,7 +260,7 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
|
|||
DrawAutofillEntry(draw_canvas, i, line_rect);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
if (view_proxy_.get()) {
|
||||
view_proxy_->SetBounds(popup_->popup_bounds_in_view());
|
||||
view_proxy_->SetBitmap(bitmap);
|
||||
|
|
|
@ -9,18 +9,20 @@
|
|||
|
||||
#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 "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "ui/accessibility/ax_node_data.h"
|
||||
#include "ui/views/drag_controller.h"
|
||||
#include "ui/views/focus/widget_focus_manager.h"
|
||||
#include "ui/views/widget/widget_delegate.h"
|
||||
#include "ui/views/widget/widget_observer.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
#include "atom/browser/osr/osr_view_proxy.h"
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
|
||||
const int kPopupBorderThickness = 1;
|
||||
|
@ -137,7 +139,7 @@ class AutofillPopupView : public views::WidgetDelegateView,
|
|||
// The index of the currently selected line
|
||||
base::Optional<int> selected_line_;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
std::unique_ptr<OffscreenViewProxy> view_proxy_;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
#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 <memory>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
#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 <memory>
|
||||
#include <string>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue