1b987b50fSBen Roth// Copyright 2015-present 650 Industries. All rights reserved. 2b987b50fSBen Roth 3*7c3ed0c0SDouglas Lowder#import "EXAbstractLoader.h" 400fcd3c6SBen Roth#import "EXEnvironment.h" 500fcd3c6SBen Roth#import "EXFileDownloader.h" 600fcd3c6SBen Roth#import "EXHomeModuleManager.h" 700fcd3c6SBen Roth#import "EXManifestResource.h" 800fcd3c6SBen Roth#import "EXKernel.h" 9b987b50fSBen Roth#import "EXKernelLinkingManager.h" 10b987b50fSBen Roth#import "EXReactAppManager.h" 11b987b50fSBen Roth 12b987b50fSBen Roth@implementation EXHomeModuleManager 13b987b50fSBen Roth 14f67462bcSTomasz Sapeta// TODO: (@tsapeta) Move all of those dev menu methods out of here and make them independent of the kernel. 15b987b50fSBen Roth 16b987b50fSBen Roth- (BOOL)homeModuleShouldEnableDevtools:(__unused EXHomeModule *)module 17b987b50fSBen Roth{ 18b987b50fSBen Roth EXKernelAppRecord *visibleApp = [EXKernel sharedInstance].visibleApp; 19b987b50fSBen Roth return ( 20b987b50fSBen Roth visibleApp != [EXKernel sharedInstance].appRegistry.homeAppRecord && 21b987b50fSBen Roth [visibleApp.appManager enablesDeveloperTools] 22b987b50fSBen Roth ); 23b987b50fSBen Roth return NO; 24b987b50fSBen Roth} 25b987b50fSBen Roth 26b987b50fSBen Roth- (NSDictionary<NSString *, NSString *> *)devMenuItemsForHomeModule:(EXHomeModule *)module 27b987b50fSBen Roth{ 28b987b50fSBen Roth return [[EXKernel sharedInstance].visibleApp.appManager devMenuItems]; 29b987b50fSBen Roth} 30b987b50fSBen Roth 31b987b50fSBen Roth- (void)homeModule:(EXHomeModule *)module didSelectDevMenuItemWithKey:(NSString *)key 32b987b50fSBen Roth{ 33b987b50fSBen Roth [[EXKernel sharedInstance].visibleApp.appManager selectDevMenuItemWithKey:key]; 3424a0cefbSTomasz Sapeta [module requestToCloseDevMenu]; 35b987b50fSBen Roth} 36b987b50fSBen Roth 37b987b50fSBen Roth- (void)homeModuleDidSelectRefresh:(EXHomeModule *)module 38b987b50fSBen Roth{ 39b333b418SBrent Vatne [[EXKernel sharedInstance] reloadVisibleApp]; 4024a0cefbSTomasz Sapeta [module requestToCloseDevMenu]; 41b987b50fSBen Roth} 42b987b50fSBen Roth 43b987b50fSBen Roth- (void)homeModuleDidSelectGoToHome:(EXHomeModule *)module 44b987b50fSBen Roth{ 45b987b50fSBen Roth if ([EXKernel sharedInstance].browserController) { 46b987b50fSBen Roth dispatch_async(dispatch_get_main_queue(), ^{ 47b987b50fSBen Roth [[EXKernel sharedInstance].browserController moveHomeToVisible]; 48b987b50fSBen Roth }); 49b987b50fSBen Roth } 5024a0cefbSTomasz Sapeta [module requestToCloseDevMenu]; 51b987b50fSBen Roth} 52b987b50fSBen Roth 532fcba380SBen Roth- (void)homeModuleDidSelectQRReader:(EXHomeModule *)module 542fcba380SBen Roth{ 552fcba380SBen Roth if ([EXKernel sharedInstance].browserController) { 562fcba380SBen Roth [EXUtil performSynchronouslyOnMainThread:^{ 572fcba380SBen Roth [[EXKernel sharedInstance].browserController showQRReader]; 582fcba380SBen Roth }]; 592fcba380SBen Roth } 602fcba380SBen Roth} 612fcba380SBen Roth 62b987b50fSBen Roth- (void)homeModule:(__unused EXHomeModule *)module didOpenUrl:(NSString *)url 63b987b50fSBen Roth{ 64b987b50fSBen Roth [[EXKernel sharedInstance].serviceRegistry.linkingManager openUrl:url isUniversalLink:NO]; 65b987b50fSBen Roth} 66b987b50fSBen Roth 6766169681SBen Roth- (void)homeModule:(EXHomeModule *)homeModule didFinishNux:(BOOL)isNuxFinished 6866169681SBen Roth{ 6966169681SBen Roth if ([EXKernel sharedInstance].browserController) { 7066169681SBen Roth [[EXKernel sharedInstance].browserController setIsNuxFinished:isNuxFinished]; 7166169681SBen Roth } 7266169681SBen Roth} 7366169681SBen Roth 7466169681SBen Roth- (BOOL)homeModuleShouldFinishNux:(EXHomeModule *)homeModule 7566169681SBen Roth{ 7666169681SBen Roth if ([EXKernel sharedInstance].browserController) { 7766169681SBen Roth return [[EXKernel sharedInstance].browserController isNuxFinished]; 7866169681SBen Roth } 7966169681SBen Roth return NO; 8066169681SBen Roth} 8166169681SBen Roth 82b987b50fSBen Roth@end 83