Skip to content

多实例支持 #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ doc/api/
.buildlog/
.history
.svn/
.vs/
migrate_working_dir/

# IntelliJ related
Expand Down
25 changes: 13 additions & 12 deletions common/webview_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// can be found in the LICENSE file.

#include "webview_app.h"
#include "webview_handler.h"

#include <string>

Expand Down Expand Up @@ -76,28 +77,28 @@ class SimpleBrowserViewDelegate : public CefBrowserViewDelegate {

} // namespace

WebviewApp::WebviewApp(CefRefPtr<WebviewHandler> handler) {
m_handler = handler;
}
WebviewApp::WebviewApp(std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> plugin_channel)
: plugin_channel_(std::move(plugin_channel)) {}

void WebviewApp::OnContextInitialized() {
CEF_REQUIRE_UI_THREAD();

plugin_channel_->InvokeMethod("onCEFInitialized", nullptr);
}

void WebviewApp::CreateBrowser(CefRefPtr<WebviewHandler> handler) {
// Specify CEF browser settings here.
CefBrowserSettings browser_settings;
browser_settings.windowless_frame_rate = 60;
std::string url = "https://www.flutter.dev/";

std::string url = "about:blank";

CefWindowInfo window_info;
window_info.SetAsWindowless(nullptr);

// Create the first browser window.
CefBrowserHost::CreateBrowser(window_info, m_handler, url, browser_settings,
nullptr, nullptr);
CefBrowserHost::CreateBrowser(window_info, handler, url, browser_settings,
nullptr, nullptr);
}

CefRefPtr<CefClient> WebviewApp::GetDefaultClient() {
// Called when a new browser window is created via the Chrome runtime UI.
return WebviewHandler::GetInstance();
return nullptr;
}
10 changes: 6 additions & 4 deletions common/webview_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// Implement application-level callbacks for the browser process.
class WebviewApp : public CefApp, public CefBrowserProcessHandler {
public:
WebviewApp(CefRefPtr<WebviewHandler> handler);
WebviewApp(std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> plugin_channel);

// CefApp methods:
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
return this;
Expand All @@ -32,9 +32,11 @@ class WebviewApp : public CefApp, public CefBrowserProcessHandler {
// CefBrowserProcessHandler methods:
void OnContextInitialized() override;
CefRefPtr<CefClient> GetDefaultClient() override;


void WebviewApp::CreateBrowser(CefRefPtr<WebviewHandler> handler);

private:
CefRefPtr<WebviewHandler> m_handler;
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> plugin_channel_;
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(WebviewApp);
};
Expand Down
Loading