mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Set enable_alloy_bootstrap=false to build with Alloy bootstrap code removed. Extension API is documented as deprecated in comments but not compiled out with this arg.
This commit is contained in:
@ -6,7 +6,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
@ -135,6 +137,39 @@ class CefGetExtensionLoadFileCallbackImpl
|
||||
IMPLEMENT_REFCOUNTING(CefGetExtensionLoadFileCallbackImpl);
|
||||
};
|
||||
|
||||
CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabId(
|
||||
int tab_id,
|
||||
content::BrowserContext* browser_context) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(browser_context);
|
||||
if (tab_id < 0 || !browser_context) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto cef_browser_context =
|
||||
CefBrowserContext::FromBrowserContext(browser_context);
|
||||
|
||||
for (const auto& browser_info :
|
||||
CefBrowserInfoManager::GetInstance()->GetBrowserInfoList()) {
|
||||
auto current_browser =
|
||||
AlloyBrowserHostImpl::FromBaseChecked(browser_info->browser());
|
||||
if (current_browser && current_browser->GetIdentifier() == tab_id) {
|
||||
// Make sure we're operating in the same CefBrowserContext.
|
||||
if (CefBrowserContext::FromBrowserContext(
|
||||
current_browser->GetBrowserContext()) == cef_browser_context) {
|
||||
return current_browser;
|
||||
} else {
|
||||
LOG(WARNING) << "Browser with tabId " << tab_id
|
||||
<< " cannot be accessed because is uses a different "
|
||||
"CefRequestContext";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefExtensionFunctionDetails::CefExtensionFunctionDetails(
|
||||
|
Reference in New Issue
Block a user