1 Star 0 Fork 1

lebu9527/WebView2Browser

forked from qmutz/WebView2Browser 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BrowserWindow.h 3.41 KB
一键复制 编辑 原始数据 按行查看 历史
Christopher Wang 提交于 2020-04-24 05:32 +08:00 . User/chwan/update api (#12)
// Copyright (C) Microsoft Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include "framework.h"
#include "Tab.h"
class BrowserWindow
{
public:
static const int c_uiBarHeight = 70;
static const int c_optionsDropdownHeight = 108;
static const int c_optionsDropdownWidth = 200;
static ATOM RegisterClass(_In_ HINSTANCE hInstance);
static LRESULT CALLBACK WndProcStatic(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static BOOL LaunchWindow(_In_ HINSTANCE hInstance, _In_ int nCmdShow);
static std::wstring GetAppDataDirectory();
std::wstring GetFullPathFor(LPCWSTR relativePath);
HRESULT HandleTabURIUpdate(size_t tabId, ICoreWebView2* webview);
HRESULT HandleTabHistoryUpdate(size_t tabId, ICoreWebView2* webview);
HRESULT HandleTabNavStarting(size_t tabId, ICoreWebView2* webview);
HRESULT HandleTabNavCompleted(size_t tabId, ICoreWebView2* webview, ICoreWebView2NavigationCompletedEventArgs* args);
HRESULT HandleTabSecurityUpdate(size_t tabId, ICoreWebView2* webview, ICoreWebView2DevToolsProtocolEventReceivedEventArgs* args);
void HandleTabCreated(size_t tabId, bool shouldBeActive);
HRESULT HandleTabMessageReceived(size_t tabId, ICoreWebView2* webview, ICoreWebView2WebMessageReceivedEventArgs* eventArgs);
int GetDPIAwareBound(int bound);
static void CheckFailure(HRESULT hr, LPCWSTR errorMessage);
protected:
HINSTANCE m_hInst = nullptr; // Current app instance
HWND m_hWnd = nullptr;
static WCHAR s_windowClass[MAX_LOADSTRING]; // The window class name
static WCHAR s_title[MAX_LOADSTRING]; // The title bar text
int m_minWindowWidth = 0;
int m_minWindowHeight = 0;
Microsoft::WRL::ComPtr<ICoreWebView2Environment> m_uiEnv;
Microsoft::WRL::ComPtr<ICoreWebView2Environment> m_contentEnv;
Microsoft::WRL::ComPtr<ICoreWebView2Controller> m_controlsController;
Microsoft::WRL::ComPtr<ICoreWebView2Controller> m_optionsController;
Microsoft::WRL::ComPtr<ICoreWebView2> m_controlsWebView;
Microsoft::WRL::ComPtr<ICoreWebView2> m_optionsWebView;
std::map<size_t,std::unique_ptr<Tab>> m_tabs;
size_t m_activeTabId = 0;
EventRegistrationToken m_controlsUIMessageBrokerToken = {}; // Token for the UI message handler in controls WebView
EventRegistrationToken m_controlsZoomToken = {};
EventRegistrationToken m_optionsUIMessageBrokerToken = {}; // Token for the UI message handler in options WebView
EventRegistrationToken m_optionsZoomToken = {};
EventRegistrationToken m_lostOptionsFocus = {}; // Token for the lost focus handler in options WebView
Microsoft::WRL::ComPtr<ICoreWebView2WebMessageReceivedEventHandler> m_uiMessageBroker;
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow);
HRESULT InitUIWebViews();
HRESULT CreateBrowserControlsWebView();
HRESULT CreateBrowserOptionsWebView();
HRESULT ClearContentCache();
HRESULT ClearControlsCache();
HRESULT ClearContentCookies();
HRESULT ClearControlsCookies();
void SetUIMessageBroker();
HRESULT ResizeUIWebViews();
void UpdateMinWindowSize();
HRESULT PostJsonToWebView(web::json::value jsonObj, ICoreWebView2* webview);
HRESULT SwitchToTab(size_t tabId);
std::wstring GetFilePathAsURI(std::wstring fullPath);
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lebu2018/WebView2Browser.git
git@gitee.com:lebu2018/WebView2Browser.git
lebu2018
WebView2Browser
WebView2Browser
master

搜索帮助