Skip to content

Commit 527fc4a

Browse files
author
Brian Vaughn
committed
Refactored to remove need for new webNavigation permission
1 parent c100cc7 commit 527fc4a

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

shells/browser/chrome/manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
},
4242

4343
"permissions": [
44-
"webNavigation",
4544
"file:///*",
4645
"http://*/*",
4746
"https://*/*"

shells/browser/firefox/manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
},
4646

4747
"permissions": [
48-
"webNavigation",
4948
"file:///*",
5049
"http://*/*",
5150
"https://*/*"

shells/browser/shared/src/main.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ function createPanelIfReactLoaded() {
117117
localStorageRemoveItem(LOCAL_STORAGE_SUPPORTS_PROFILING_KEY);
118118
}
119119

120+
if (store !== null) {
121+
profilingData = store.profilerStore.profilingData;
122+
}
123+
120124
store = new Store(bridge, {
121125
isProfiling,
122126
supportsReloadAndProfile: getBrowserName() === 'Chrome',
@@ -266,21 +270,6 @@ function createPanelIfReactLoaded() {
266270

267271
chrome.devtools.network.onNavigated.removeListener(checkPageForReact);
268272

269-
// Shutdown bridge before a new page is loaded.
270-
chrome.webNavigation.onBeforeNavigate.addListener(
271-
function onBeforeNavigate(details) {
272-
// Ignore navigation events from other tabs (or from within frames).
273-
if (details.tabId !== tabId || details.frameId !== 0) {
274-
return;
275-
}
276-
277-
// `bridge.shutdown()` will remove all listeners we added, so we don't have to.
278-
bridge.shutdown();
279-
280-
profilingData = store.profilerStore.profilingData;
281-
}
282-
);
283-
284273
// Re-initialize DevTools panel when a new page is loaded.
285274
chrome.devtools.network.onNavigated.addListener(function onNavigated() {
286275
// Re-initialize saved filters on navigation,

src/devtools/views/DevTools.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import '@reach/menu-button/styles.css';
66
import '@reach/tooltip/styles.css';
77

8-
import React, { useMemo, useState } from 'react';
8+
import React, { useEffect, useMemo, useState } from 'react';
99
import Store from '../store';
1010
import { BridgeContext, StoreContext } from './context';
1111
import Components from './Components/Components';
@@ -103,6 +103,16 @@ export default function DevTools({
103103
[canViewElementSourceFunction, viewElementSourceFunction]
104104
);
105105

106+
useEffect(() => {
107+
return () => {
108+
try {
109+
bridge.shutdown()
110+
} catch (error) {
111+
// Attempting to use a disconnected port.
112+
}
113+
};
114+
}, [bridge]);
115+
106116
return (
107117
<BridgeContext.Provider value={bridge}>
108118
<StoreContext.Provider value={store}>

0 commit comments

Comments
 (0)