@@ -38,6 +38,9 @@ const _allowedEvents = {'Overlay.inspectNodeRequested'};
38
38
// Map of Chrome tab ID to encoded vm service protocol URI.
39
39
final _tabIdToEncodedUri = < int , String > {};
40
40
41
+ // Map of Chrome tab ID to warnings for that tab.
42
+ final _tabIdToWarning = < int , String > {};
43
+
41
44
final _debuggableTabs = < int > {};
42
45
43
46
final _tabsToAttach = < Tab > {};
@@ -67,6 +70,12 @@ void main() {
67
70
var callback = allowInterop ((List <Tab > tabs) async {
68
71
currentTab = tabs[0 ];
69
72
if (! _debuggableTabs.contains (currentTab.id)) return ;
73
+
74
+ if (_tabIdToWarning.containsKey (currentTab.id)) {
75
+ alert (_tabIdToWarning[currentTab.id]);
76
+ return ;
77
+ }
78
+
70
79
attach (Debuggee (tabId: currentTab.id), '1.3' , allowInterop (() async {
71
80
if (lastError != null ) {
72
81
String alertMessage;
@@ -100,6 +109,10 @@ void main() {
100
109
101
110
onMessageAddListener (allowInterop (
102
111
(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
+ }
103
116
_debuggableTabs.add (sender.tab.id);
104
117
_updateIcon ();
105
118
// TODO(grouma) - We can conditionally auto start debugging here.
@@ -362,9 +375,20 @@ void _updateIcon() {
362
375
var query = QueryInfo (active: true , currentWindow: true );
363
376
queryTabs (query, allowInterop ((List tabs) {
364
377
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):
366
389
setIcon (IconInfo (path: 'dart.png' ));
367
390
} else {
391
+ // Set the default icon (grey):
368
392
setIcon (IconInfo (path: 'dart_grey.png' ));
369
393
}
370
394
}));
@@ -514,6 +538,7 @@ class Request {
514
538
external int get tabId;
515
539
external String get name;
516
540
external dynamic get options;
541
+ external String get warning;
517
542
external factory Request ({int tabId, String name, dynamic options});
518
543
}
519
544
0 commit comments