File tree Expand file tree Collapse file tree 7 files changed +48
-57
lines changed
dwds/debug_extension_mv3/web Expand file tree Collapse file tree 7 files changed +48
-57
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,16 @@ Future<void> _handleRuntimeMessages(
158
158
},
159
159
);
160
160
161
+ interceptMessage <String >(
162
+ message: jsRequest,
163
+ expectedType: MessageType .appId,
164
+ expectedSender: Script .copier,
165
+ expectedRecipient: Script .background,
166
+ messageHandler: (String appId) {
167
+ displayNotification ('Copied app ID: $appId ' );
168
+ },
169
+ );
170
+
161
171
sendResponse (defaultResponse);
162
172
}
163
173
Original file line number Diff line number Diff line change @@ -42,14 +42,12 @@ void _copyAppId(String appId) {
42
42
final clipboard = window.navigator.clipboard;
43
43
if (clipboard == null ) return ;
44
44
clipboard.writeText (appId);
45
- _showCopiedMessage (appId);
45
+ _notifyCopiedSuccess (appId);
46
46
}
47
47
48
- Future <void > _showCopiedMessage (String appId) async {
49
- final snackbar = document.createElement ('div' );
50
- snackbar.setInnerHtml ('Copied app ID: <i>$appId </i>' );
51
- snackbar.classes.addAll (['snackbar' , 'snackbar--info' , 'show' ]);
52
- document.body? .append (snackbar);
53
- await Future .delayed (Duration (seconds: 4 ));
54
- snackbar.remove ();
55
- }
48
+ Future <bool > _notifyCopiedSuccess (String appId) => sendRuntimeMessage (
49
+ type: MessageType .appId,
50
+ body: appId,
51
+ sender: Script .copier,
52
+ recipient: Script .background,
53
+ );
Original file line number Diff line number Diff line change @@ -246,13 +246,7 @@ _enableExecutionContextReporting(int tabId) {
246
246
final chromeError = chrome.runtime.lastError;
247
247
if (chromeError != null ) {
248
248
final errorMessage = _translateChromeError (chromeError.message);
249
- chrome.notifications.create (
250
- // notificationId
251
- null ,
252
- NotificationOptions (message: errorMessage),
253
- // callback
254
- null ,
255
- );
249
+ displayNotification (errorMessage, isError: true );
256
250
return ;
257
251
}
258
252
}),
@@ -720,16 +714,10 @@ Future<bool> _showWarning(
720
714
721
715
Future <bool > _showWarningNotification (String message) {
722
716
final completer = Completer <bool >();
723
- chrome.notifications.create (
724
- // notificationId
725
- null ,
726
- NotificationOptions (
727
- title: '[Error] Dart Debug Extension' ,
728
- message: message,
729
- iconUrl: 'static_assets/dart.png' ,
730
- type: 'basic' ,
731
- ),
732
- allowInterop ((_) {
717
+ displayNotification (
718
+ message,
719
+ isError: true ,
720
+ callback: allowInterop ((_) {
733
721
completer.complete (true );
734
722
}),
735
723
);
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " Dart Debug Extension" ,
3
- "version" : " 1.38 " ,
3
+ "version" : " 1.40 " ,
4
4
"manifest_version" : 2 ,
5
5
"devtools_page" : " static_assets/devtools.html" ,
6
6
"browser_action" : {
25
25
{
26
26
"matches" : [" <all_urls>" ],
27
27
"js" : [" detector.dart.js" , " copier.dart.js" ],
28
- "css" : [" static_assets/styles.css" ],
29
28
"run_at" : " document_end"
30
29
}
31
30
],
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " Dart Debug Extension" ,
3
- "version" : " 1.38 " ,
3
+ "version" : " 1.40 " ,
4
4
"manifest_version" : 3 ,
5
5
"devtools_page" : " static_assets/devtools.html" ,
6
6
"action" : {
32
32
{
33
33
"matches" : [" <all_urls>" ],
34
34
"js" : [" detector.dart.js" , " copier.dart.js" ],
35
- "css" : [" static_assets/styles.css" ],
36
35
"run_at" : " document_end"
37
36
}
38
37
],
Original file line number Diff line number Diff line change 75
75
}
76
76
77
77
.snackbar {
78
- top : 0px ;
78
+ bottom : 0px ;
79
79
color : # eeeeee ;
80
80
font-family : Roboto, 'Helvetica Neue' , sans-serif;
81
81
left : 0px ;
@@ -113,44 +113,22 @@ h6 {
113
113
114
114
@-webkit-keyframes fadein {
115
115
from {
116
- top : 0 ;
116
+ bottom : 0 ;
117
117
opacity : 0 ;
118
118
}
119
119
to {
120
- top : 0px ;
120
+ bottom : 0px ;
121
121
opacity : 1 ;
122
122
}
123
123
}
124
124
125
125
@keyframes fadein {
126
126
from {
127
- top : 0 ;
127
+ bottom : 0 ;
128
128
opacity : 0 ;
129
129
}
130
130
to {
131
- top : 0px ;
131
+ bottom : 0px ;
132
132
opacity : 1 ;
133
133
}
134
134
}
135
-
136
- @-webkit-keyframes fadeout {
137
- from {
138
- top : 0px ;
139
- opacity : 1 ;
140
- }
141
- to {
142
- top : 0 ;
143
- opacity : 0 ;
144
- }
145
- }
146
-
147
- @keyframes fadeout {
148
- from {
149
- top : 0px ;
150
- opacity : 1 ;
151
- }
152
- to {
153
- top : 0 ;
154
- opacity : 0 ;
155
- }
156
- }
Original file line number Diff line number Diff line change @@ -69,6 +69,25 @@ Future<bool> removeTab(int tabId) {
69
69
return completer.future;
70
70
}
71
71
72
+ void displayNotification (
73
+ String message, {
74
+ bool isError = false ,
75
+ Function ? callback,
76
+ }) {
77
+ chrome.notifications.create (
78
+ // notificationId
79
+ null ,
80
+ NotificationOptions (
81
+ title: '${isError ? '[Error] ' : '' }Dart Debug Extension' ,
82
+ message: message,
83
+ iconUrl:
84
+ isError ? 'static_assets/dart_warning.png' : 'static_assets/dart.png' ,
85
+ type: 'basic' ,
86
+ ),
87
+ callback,
88
+ );
89
+ }
90
+
72
91
Future <bool > injectScript (String scriptName, {required int tabId}) async {
73
92
if (isMV3) {
74
93
await promiseToFuture (
You can’t perform that action at this time.
0 commit comments