9

解决 CEF 76+ 内核默认禁用 Flash 插件提示 “右键点击即可运行 Adobe Flash Player”

 3 years ago
source link: https://www.mycode.net.cn/language/cpp/2867.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

解决 CEF 76+ 内核默认禁用 Flash 插件提示 “右键点击即可运行 Adobe Flash Player”

CEF 76+ 内核在编译后即使增加了 ppapi-flash-pathppapi-flash-version 也无法在页面中使用 Flash,在命令行参数中确定两个参数是生效的,如图:

2019-12-05_17-16-37.png

CEF != Chrome,这里无论你怎么点击右键都没有效果,经过一番查询,在 CEF 论坛中找到了可行方案:https://www.magpcss.org/ceforum/viewtopic.php?f=7&t=17068&start=10

经过一番尝试,发现在我们创建主进程(CreateBrowser)的时候将 profile.default_content_setting_values.plugins 设置为 1 就可以了。具体实现代码如下:

CefRequestContextSettings rcsettings;
CefString(&rcsettings.cache_path).FromWString(app_data_path);
auto request_content = CefRequestContext::CreateContext(rcsettings, new ClientRequestContextHandler);
CefString error;
CefRefPtr<CefValue> value = CefValue::Create();
value->SetInt(1);
request_content->SetPreference("profile.default_content_setting_values.plugins", value, error);
CefBrowserHost::CreateBrowser(window_info, 
    handler, 
    cached_login_addr ? url : "", 
    browser_settings, 
    nullptr, 
    request_content);

在你的代码中,搜索 CreateBrowser 在创建前,修改 profile.default_content_setting_values.plugins 值即可无需用户交互自动开启 Flash 支持。

2019-12-05_17-21-55.png
本条目发布于2019年12月5日。属于C/C++Language分类,被贴了 CEF 标签。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK