MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Browser / messageHandler

Function messageHandler

wvbrowser_ui/controls_ui/default.js:10–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8};
9
10const messageHandler = event => {
11 var message = event.data.message;
12 var args = event.data.args;
13
14 switch (message) {
15 case commands.MG_UPDATE_URI:
16 if (isValidTabId(args.tabId)) {
17 const tab = tabs.get(args.tabId);
18 let previousURI = tab.uri;
19
20 // Update the tab state
21 tab.uri = args.uri;
22 tab.uriToShow = args.uriToShow;
23 tab.canGoBack = args.canGoBack;
24 tab.canGoForward = args.canGoForward;
25
26 // If the tab is active, update the controls UI
27 if (args.tabId == activeTabId) {
28 updateNavigationUI(message);
29 }
30
31 isFavorite(tab.uri, (isFavorite) => {
32 tab.isFavorite = isFavorite;
33 updateFavoriteIcon();
34 });
35
36 // Don't add history entry if URI has not changed
37 if (tab.uri == previousURI) {
38 break;
39 }
40
41 // Filter URIs that should not appear in history
42 if (!tab.uri || tab.uri == 'about:blank') {
43 tab.historyItemId = INVALID_HISTORY_ID;
44 break;
45 }
46
47 if (tab.uriToShow && tab.uriToShow.substring(0, 10) == 'browser://') {
48 tab.historyItemId = INVALID_HISTORY_ID;
49 break;
50 }
51
52 addHistoryItem(historyItemFromTab(args.tabId), (id) => {
53 tab.historyItemId = id;
54 });
55 }
56 break;
57 case commands.MG_NAV_STARTING:
58 if (isValidTabId(args.tabId)) {
59 // Update the tab state
60 tabs.get(args.tabId).isLoading = true;
61
62 // If the tab is active, update the controls UI
63 if (args.tabId == activeTabId) {
64 updateNavigationUI(message);
65 }
66 }
67 break;

Callers

nothing calls this directly

Calls 15

isValidTabIdFunction · 0.85
updateNavigationUIFunction · 0.85
isFavoriteFunction · 0.85
updateFavoriteIconFunction · 0.85
addHistoryItemFunction · 0.85
historyItemFromTabFunction · 0.85
refreshTabsFunction · 0.85
updateHistoryItemFunction · 0.85
toggleOptionsDropdownFunction · 0.85
updateFaviconURIFunction · 0.85
closeWindowFunction · 0.85
closeTabFunction · 0.85

Tested by

no test coverage detected