Mac OS/WebView: Why Flash and other plugins are not available when a local page is loaded?

ε祈祈猫儿з 提交于 2019-12-24 09:39:45

问题


We are working on Objective C application for desktop Mac.

We use WebView component to display HTML pages.

When the page is loaded from the local file system, Flash movies are not displayed on the page. As it turned out the problem is not exactly about Flash. Most WebView plugins are missing.

When the page is loaded from the Internet, Flash is displayed properly and there are many plugins available.

The problem does not occur on my Mac, but it happens to 30% of our customers. It is reproduced on MacBook (not MacBook air), Mac OS version is 10.5.8.

Guys, please help us, I have no idea how to tackle this. This is the only obstacle preventing us from the product release.

Why WebView plugins are not available when a local page is loaded?

What can be the source of the problem - Safari configuration, Mac security settings, some software installed?

How can I reproduce the problem on my Mac?

This is our WebView initialization code for local page loading.

IBOutlet WebView* webView;
...

[[webView preferences] setPlugInsEnabled:YES];    
WebFrame *mainFrame = [webView mainFrame];

NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
NSURL* url = [NSURL fileURLWithPath:path];  

NSURLRequest *request = [NSURLRequest requestWithURL:url];
   [mainFrame loadRequest:request];

Have you noticed any flaws?

UPDATE 1

Test application

Source code

UPDATE 2

Minimal test, I have left only the code necessary to open the local page. No diagnostic window displayed. Test application, simple

Full source code for Application Delegate of the simple test

#import "WebViewAppDelegate.h"

#import <WebKit/WebView.h>
#import <WebKit/WebFrame.h>

@implementation WebViewAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    [[webView preferences] setPlugInsEnabled:YES];

    WebFrame *mainFrame = [webView mainFrame];
    NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
    NSURL* url = [NSURL fileURLWithPath:path];  

    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [mainFrame loadRequest:request];

}

@end

回答1:


ok,

running v2 from the download failed, I still got the plugins alert and no crab

so I rebuilt the xcode project and included 10.5 as a target, then manually moved the html and swf into contents and it reports all the safari plugins and runs on 10.5.8

so although your plist says 10.5 [min] your sdk target was/is 10.6, so it won't run on 10.5

john




回答2:


your plugins and alert may be blocking your linked js, the crab does not run in your webview here.

I can run the swf in another apps webview by pointing to the html file in package contents and that's without any 'plugins' enabled.

you might try adding WebKitDeveloperExtras booleen true to your prefs file so you can check with webinspector.




回答3:


I ran it in a Google 'SketchUp' WebDialog, the Nib file has the exact option settings as yours. If your unfamiliar with SU it has a Ruby Console available and you can write or serve html files to it. The free version and a little ruby is all that's required. john



来源:https://stackoverflow.com/questions/5855165/mac-os-webview-why-flash-and-other-plugins-are-not-available-when-a-local-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!