Skip to content

Commit

Permalink
Move the embedded view preview flag check to a common function. (#6813)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirh authored Nov 9, 2018
1 parent 316f636 commit f5e5d81
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
4 changes: 1 addition & 3 deletions shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ - (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryURI {
threadLabel.UTF8String, // label
shell::ThreadHost::Type::UI | shell::ThreadHost::Type::GPU | shell::ThreadHost::Type::IO};

bool embedded_views_preview_enabled = [[[NSBundle mainBundle]
objectForInfoDictionaryKey:@(shell::kEmbeddedViewsPreview)] boolValue];
// Lambda captures by pointers to ObjC objects are fine here because the
// create call is
// synchronous.
Expand All @@ -310,7 +308,7 @@ - (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryURI {
return std::make_unique<shell::Rasterizer>(shell.GetTaskRunners());
};

if (embedded_views_preview_enabled) {
if (shell::IsIosEmbeddedViewsPreviewEnabled()) {
// Embedded views requires the gpu and the platform views to be the same.
// The plan is to eventually dynamically merge the threads when there's a
// platform view in the layer tree.
Expand Down
5 changes: 3 additions & 2 deletions shell/platform/darwin/ios/ios_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

namespace shell {

// The name of the Info.plist flag to enable the embedded iOS views preview.
const char* const kEmbeddedViewsPreview = "io.flutter.embedded_views_preview";
// Returns true if the app explicitly specified to use the iOS view embedding
// mechanism which is still in a release preview.
bool IsIosEmbeddedViewsPreviewEnabled();

class IOSSurface {
public:
Expand Down
7 changes: 7 additions & 0 deletions shell/platform/darwin/ios/ios_surface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

namespace shell {

// The name of the Info.plist flag to enable the embedded iOS views preview.
const char* const kEmbeddedViewsPreview = "io.flutter.embedded_views_preview";

bool IsIosEmbeddedViewsPreviewEnabled() {
return [[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue];
}

IOSSurface::IOSSurface(FlutterPlatformViewsController* platform_views_controller)
: platform_views_controller_(platform_views_controller) {}

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/ios_surface_gl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}

flow::ExternalViewEmbedder* IOSSurfaceGL::GetExternalViewEmbedder() {
if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue]) {
if (IsIosEmbeddedViewsPreviewEnabled()) {
return this;
} else {
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/darwin/ios/ios_surface_software.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
}

flow::ExternalViewEmbedder* IOSSurfaceSoftware::GetExternalViewEmbedder() {
if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@(kEmbeddedViewsPreview)] boolValue]) {
if (IsIosEmbeddedViewsPreviewEnabled()) {
return this;
} else {
return nullptr;
Expand Down

0 comments on commit f5e5d81

Please sign in to comment.