mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for loading extensions (issue #1947)
- Add CefRequestContext::LoadExtension, CefExtension, CefExtensionHandler and related methods/interfaces. - Add chrome://extensions-support that lists supported Chrome APIs. - Add CefBrowserHost::SetAutoResizeEnabled and CefDisplayHandler::OnAutoResize to support browser resize based on preferred web contents size. - views: Add support for custom CefMenuButton popups. - cefclient: Run with `--load-extension=set_page_color` command-line flag for an extension loading example. Add `--use-views` on Windows and Linux for an even better example.
This commit is contained in:
@ -119,11 +119,10 @@ void RunRequestTest(CefRefPtr<CefBrowser> browser) {
|
||||
}
|
||||
|
||||
void RunNewWindowTest(CefRefPtr<CefBrowser> browser) {
|
||||
MainContext::Get()->GetRootWindowManager()->CreateRootWindow(
|
||||
true, // Show controls.
|
||||
browser->GetHost()->IsWindowRenderingDisabled(),
|
||||
CefRect(), // Use default system size.
|
||||
std::string()); // Use default URL.
|
||||
RootWindowConfig config;
|
||||
config.with_controls = true;
|
||||
config.with_osr = browser->GetHost()->IsWindowRenderingDisabled();
|
||||
MainContext::Get()->GetRootWindowManager()->CreateRootWindow(config);
|
||||
}
|
||||
|
||||
void RunPopupWindowTest(CefRefPtr<CefBrowser> browser) {
|
||||
@ -680,8 +679,9 @@ void SetupResourceManager(CefRefPtr<CefResourceManager> resource_manager) {
|
||||
// Add provider for bundled resource files.
|
||||
#if defined(OS_WIN)
|
||||
// Read resources from the binary.
|
||||
resource_manager->AddProvider(CreateBinaryResourceProvider(test_origin), 100,
|
||||
std::string());
|
||||
resource_manager->AddProvider(
|
||||
CreateBinaryResourceProvider(test_origin, std::string()), 100,
|
||||
std::string());
|
||||
#elif defined(OS_POSIX)
|
||||
// Read resources from a directory on disk.
|
||||
std::string resource_dir;
|
||||
@ -693,6 +693,14 @@ void SetupResourceManager(CefRefPtr<CefResourceManager> resource_manager) {
|
||||
}
|
||||
|
||||
void Alert(CefRefPtr<CefBrowser> browser, const std::string& message) {
|
||||
if (browser->GetHost()->GetExtension()) {
|
||||
// Alerts originating from extension hosts should instead be displayed in
|
||||
// the active browser.
|
||||
browser = MainContext::Get()->GetRootWindowManager()->GetActiveBrowser();
|
||||
if (!browser)
|
||||
return;
|
||||
}
|
||||
|
||||
// Escape special characters in the message.
|
||||
std::string msg = StringReplace(message, "\\", "\\\\");
|
||||
msg = StringReplace(msg, "'", "\\'");
|
||||
|
Reference in New Issue
Block a user