Skip to content

Commit

Permalink
Merge pull request #245 from ThinBridge/fix-enable-pdf-extension-to-work
Browse files Browse the repository at this point in the history
Fix IsEnablePDFExtension to work
  • Loading branch information
kenhys authored Dec 4, 2024
2 parents 4ed9c92 + 3cea70a commit 86b0225
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,15 @@ void ClientApp::OnBeforeCommandLineProcessing(const CefString& process_type, Cef
// command_line->AppendSwitch(_T("disable-extensions"));
//command_line->AppendSwitchWithValue(_T("proxy-server"),_T("127.0.0.1:8080"));

#if CHROME_VERSION_MAJOR < 126
//pdf
//CEF126.2.7以降、disable-pdf-extensionオプションが非サポートになった。
//そのため、CEF126以降では、ClientHandler::OnAfterCreatedでPreferenceを指定することで同等の処理を行う。
//https://github.com/cefsharp/CefSharp/issues/4880
if (!theApp.m_AppSettings.IsEnablePDFExtension())
command_line->AppendSwitch(_T("disable-pdf-extension"));
#endif


////flash
//2020-12-31 EOL
Expand Down
14 changes: 14 additions & 0 deletions client_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser)
REQUIRE_UI_THREAD();
PROC_TIME(OnAfterCreated)

#if CHROME_VERSION_MAJOR >= 126
//CEF126.2.7以降、disable-pdf-extensionオプションが非サポートになった。
//そのため、CEF126以降では、ClientHandler::OnAfterCreatedでPreferenceを指定することで同等の処理を行う。
//https://github.com/cefsharp/CefSharp/issues/4880
if (!theApp.m_AppSettings.IsEnablePDFExtension())
{
CefRefPtr<CefRequestContext> requestContext = browser->GetHost()->GetRequestContext();
CefString error;
CefRefPtr<CefValue> value = CefValue::Create();
value->SetBool(true);
requestContext->SetPreference("plugins.always_open_pdf_externally", value, error);
}
#endif

// get browser ID
INT nBrowserId = browser->GetIdentifier();

Expand Down

0 comments on commit 86b0225

Please sign in to comment.