@@ -93,7 +93,9 @@ Future<void> _handleRuntimeMessages(
9393 }
9494 // Save the debug info for the Dart app in storage:
9595 await setStorageObject <DebugInfo >(
96- type: StorageObject .debugInfo, value: debugInfo, tabId: dartTab.id);
96+ type: StorageObject .debugInfo,
97+ value: _addTabUrl (debugInfo, tabUrl: dartTab.url),
98+ tabId: dartTab.id);
9799 // Update the icon to show that a Dart app has been detected:
98100 final currentTab = await activeTab;
99101 if (currentTab? .id == dartTab.id) {
@@ -137,10 +139,13 @@ Future<void> _handleRuntimeMessages(
137139
138140Future <void > _detectNavigationAwayFromDartApp (
139141 NavigationInfo navigationInfo) async {
142+ // Ignore any navigation events within the page itself (e.g., opening a link,
143+ // reloading an IFRAME, etc):
144+ if (_isInternalNavigation (navigationInfo)) return ;
140145 final tabId = navigationInfo.tabId;
141146 final debugInfo = await _fetchDebugInfo (navigationInfo.tabId);
142147 if (debugInfo == null ) return ;
143- if (debugInfo.appUrl != navigationInfo.url) {
148+ if (debugInfo.tabUrl != navigationInfo.url) {
144149 _setDefaultIcon ();
145150 await clearStaleDebugSession (tabId);
146151 await removeStorageObject (type: StorageObject .debugInfo, tabId: tabId);
@@ -152,6 +157,29 @@ Future<void> _detectNavigationAwayFromDartApp(
152157 }
153158}
154159
160+ bool _isInternalNavigation (NavigationInfo navigationInfo) {
161+ return [
162+ 'auto_subframe' ,
163+ 'form_submit' ,
164+ 'link' ,
165+ 'manual_subframe' ,
166+ ].contains (navigationInfo.transitionType);
167+ }
168+
169+ DebugInfo _addTabUrl (DebugInfo debugInfo, {required String tabUrl}) {
170+ return DebugInfo ((b) => b
171+ ..appEntrypointPath = debugInfo.appEntrypointPath
172+ ..appId = debugInfo.appId
173+ ..appInstanceId = debugInfo.appInstanceId
174+ ..appOrigin = debugInfo.appOrigin
175+ ..appUrl = debugInfo.appUrl
176+ ..authUrl = debugInfo.authUrl
177+ ..extensionUrl = debugInfo.extensionUrl
178+ ..isInternalBuild = debugInfo.isInternalBuild
179+ ..isFlutterApp = debugInfo.isFlutterApp
180+ ..tabUrl = tabUrl);
181+ }
182+
155183Future <void > _updateIcon (int activeTabId) async {
156184 final debugInfo = await _fetchDebugInfo (activeTabId);
157185 if (debugInfo == null ) {
0 commit comments