@@ -38,6 +38,9 @@ const _allowedEvents = {'Overlay.inspectNodeRequested'};
3838// Map of Chrome tab ID to encoded vm service protocol URI.
3939final _tabIdToEncodedUri = < int , String > {};
4040
41+ // Map of Chrome tab ID to warnings for that tab.
42+ final _tabIdToWarning = < int , String > {};
43+
4144final _debuggableTabs = < int > {};
4245
4346final _tabsToAttach = < Tab > {};
@@ -67,6 +70,12 @@ void main() {
6770 var callback = allowInterop ((List <Tab > tabs) async {
6871 currentTab = tabs[0 ];
6972 if (! _debuggableTabs.contains (currentTab.id)) return ;
73+
74+ if (_tabIdToWarning.containsKey (currentTab.id)) {
75+ alert (_tabIdToWarning[currentTab.id]);
76+ return ;
77+ }
78+
7079 attach (Debuggee (tabId: currentTab.id), '1.3' , allowInterop (() async {
7180 if (lastError != null ) {
7281 String alertMessage;
@@ -100,6 +109,10 @@ void main() {
100109
101110 onMessageAddListener (allowInterop (
102111 (Request request, Sender sender, Function sendResponse) async {
112+ // Register any warnings for the tab:
113+ if (request.warning != '' ) {
114+ _tabIdToWarning[sender.tab.id] = request.warning;
115+ }
103116 _debuggableTabs.add (sender.tab.id);
104117 _updateIcon ();
105118 // TODO(grouma) - We can conditionally auto start debugging here.
@@ -362,9 +375,20 @@ void _updateIcon() {
362375 var query = QueryInfo (active: true , currentWindow: true );
363376 queryTabs (query, allowInterop ((List tabs) {
364377 var tabList = List <Tab >.from (tabs);
365- if (tabList.isEmpty || _debuggableTabs.contains (tabList.first.id)) {
378+ // If tabList is empty, the user has likely navigated to a different window.
379+ // Therefore, do not update the icon:
380+ if (tabList.isEmpty || tabList.first == null || tabList.first.id == null ) {
381+ return ;
382+ }
383+
384+ if (_tabIdToWarning.containsKey (tabList.first.id)) {
385+ // Set the warning icon (red):
386+ setIcon (IconInfo (path: 'dart_warning.png' ));
387+ } else if (_debuggableTabs.contains (tabList.first.id)) {
388+ // Set the debuggable icon (blue):
366389 setIcon (IconInfo (path: 'dart.png' ));
367390 } else {
391+ // Set the default icon (grey):
368392 setIcon (IconInfo (path: 'dart_grey.png' ));
369393 }
370394 }));
@@ -514,6 +538,7 @@ class Request {
514538 external int get tabId;
515539 external String get name;
516540 external dynamic get options;
541+ external String get warning;
517542 external factory Request ({int tabId, String name, dynamic options});
518543}
519544
0 commit comments