18
18
#include " atom/browser/lib/bluetooth_chooser.h"
19
19
#include " atom/browser/native_window.h"
20
20
#include " atom/browser/net/atom_network_delegate.h"
21
+ #if defined(ENABLE_OSR)
21
22
#include " atom/browser/osr/osr_output_device.h"
22
23
#include " atom/browser/osr/osr_render_widget_host_view.h"
23
24
#include " atom/browser/osr/osr_web_contents_view.h"
25
+ #endif
24
26
#include " atom/browser/ui/drag_util.h"
25
27
#include " atom/browser/web_contents_permission_helper.h"
26
28
#include " atom/browser/web_contents_preferences.h"
@@ -228,8 +230,10 @@ struct Converter<atom::api::WebContents::Type> {
228
230
*out = Type::BROWSER_VIEW;
229
231
} else if (type == " webview" ) {
230
232
*out = Type::WEB_VIEW;
233
+ #if defined(ENABLE_OSR)
231
234
} else if (type == " offscreen" ) {
232
235
*out = Type::OFF_SCREEN;
236
+ #endif
233
237
} else {
234
238
return false ;
235
239
}
@@ -314,8 +318,10 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
314
318
type_ = BACKGROUND_PAGE;
315
319
else if (options.Get (" isBrowserView" , &b) && b)
316
320
type_ = BROWSER_VIEW;
321
+ #if defined(ENABLE_OSR)
317
322
else if (options.Get (" offscreen" , &b) && b)
318
323
type_ = OFF_SCREEN;
324
+ #endif
319
325
320
326
// Init embedder earlier
321
327
options.Get (" embedder" , &embedder_);
@@ -345,6 +351,7 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
345
351
guest_delegate_.reset (new WebViewGuestDelegate);
346
352
params.guest_delegate = guest_delegate_.get ();
347
353
354
+ #if defined(ENABLE_OSR)
348
355
if (embedder_ && embedder_->IsOffScreen ()) {
349
356
auto * view = new OffScreenWebContentsView (false ,
350
357
base::Bind (&WebContents::OnPaint, base::Unretained (this )));
@@ -354,7 +361,9 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
354
361
web_contents = content::WebContents::Create (params);
355
362
view->SetWebContents (web_contents);
356
363
} else {
364
+ #endif
357
365
web_contents = content::WebContents::Create (params);
366
+ #if defined(ENABLE_OSR)
358
367
}
359
368
} else if (IsOffScreen ()) {
360
369
bool transparent = false ;
@@ -368,6 +377,7 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
368
377
369
378
web_contents = content::WebContents::Create (params);
370
379
view->SetWebContents (web_contents);
380
+ #endif
371
381
} else {
372
382
content::WebContents::CreateParams params (session->browser_context ());
373
383
web_contents = content::WebContents::Create (params);
@@ -1558,7 +1568,11 @@ bool WebContents::IsGuest() const {
1558
1568
}
1559
1569
1560
1570
bool WebContents::IsOffScreen () const {
1571
+ #if defined(ENABLE_OSR)
1561
1572
return type_ == OFF_SCREEN;
1573
+ #else
1574
+ return false ;
1575
+ #endif
1562
1576
}
1563
1577
1564
1578
bool WebContents::IsOffScreenOrEmbedderOffscreen () const {
@@ -1573,56 +1587,72 @@ void WebContents::StartPainting() {
1573
1587
if (!IsOffScreen ())
1574
1588
return ;
1575
1589
1590
+ #if defined(ENABLE_OSR)
1576
1591
auto * osr_rwhv = static_cast <OffScreenRenderWidgetHostView*>(
1577
1592
web_contents ()->GetRenderWidgetHostView ());
1578
1593
if (osr_rwhv)
1579
1594
osr_rwhv->SetPainting (true );
1595
+ #endif
1580
1596
}
1581
1597
1582
1598
void WebContents::StopPainting () {
1583
1599
if (!IsOffScreen ())
1584
1600
return ;
1585
1601
1602
+ #if defined(ENABLE_OSR)
1586
1603
auto * osr_rwhv = static_cast <OffScreenRenderWidgetHostView*>(
1587
1604
web_contents ()->GetRenderWidgetHostView ());
1588
1605
if (osr_rwhv)
1589
1606
osr_rwhv->SetPainting (false );
1607
+ #endif
1590
1608
}
1591
1609
1592
1610
bool WebContents::IsPainting () const {
1593
1611
if (!IsOffScreen ())
1594
1612
return false ;
1595
1613
1614
+ #if defined(ENABLE_OSR)
1596
1615
const auto * osr_rwhv = static_cast <OffScreenRenderWidgetHostView*>(
1597
1616
web_contents ()->GetRenderWidgetHostView ());
1598
1617
return osr_rwhv && osr_rwhv->IsPainting ();
1618
+ #else
1619
+ return false ;
1620
+ #endif
1599
1621
}
1600
1622
1601
1623
void WebContents::SetFrameRate (int frame_rate) {
1602
1624
if (!IsOffScreen ())
1603
1625
return ;
1604
1626
1627
+ #if defined(ENABLE_OSR)
1605
1628
auto * osr_rwhv = static_cast <OffScreenRenderWidgetHostView*>(
1606
1629
web_contents ()->GetRenderWidgetHostView ());
1607
1630
if (osr_rwhv)
1608
1631
osr_rwhv->SetFrameRate (frame_rate);
1632
+ #endif
1609
1633
}
1610
1634
1611
1635
int WebContents::GetFrameRate () const {
1612
1636
if (!IsOffScreen ())
1613
1637
return 0 ;
1614
1638
1639
+ #if defined(ENABLE_OSR)
1615
1640
const auto * osr_rwhv = static_cast <OffScreenRenderWidgetHostView*>(
1616
1641
web_contents ()->GetRenderWidgetHostView ());
1617
1642
return osr_rwhv ? osr_rwhv->GetFrameRate () : 0 ;
1643
+ #else
1644
+ return 0 ;
1645
+ #endif
1618
1646
}
1619
1647
1620
1648
void WebContents::Invalidate () {
1621
1649
if (IsOffScreen ()) {
1650
+ #if defined(ENABLE_OSR)
1622
1651
auto * osr_rwhv = static_cast <OffScreenRenderWidgetHostView*>(
1623
1652
web_contents ()->GetRenderWidgetHostView ());
1624
1653
if (osr_rwhv)
1625
1654
osr_rwhv->Invalidate ();
1655
+ #endif
1626
1656
} else {
1627
1657
const auto window = owner_window ();
1628
1658
if (window)
@@ -1795,7 +1825,9 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
1795
1825
.SetMethod (" startDrag" , &WebContents::StartDrag)
1796
1826
.SetMethod (" setSize" , &WebContents::SetSize)
1797
1827
.SetMethod (" isGuest" , &WebContents::IsGuest)
1828
+ #if defined(ENABLE_OSR)
1798
1829
.SetMethod (" isOffscreen" , &WebContents::IsOffScreen)
1830
+ #endif
1799
1831
.SetMethod (" startPainting" , &WebContents::StartPainting)
1800
1832
.SetMethod (" stopPainting" , &WebContents::StopPainting)
1801
1833
.SetMethod (" isPainting" , &WebContents::IsPainting)
0 commit comments