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(
158158 },
159159 );
160160
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+
161171 sendResponse (defaultResponse);
162172}
163173
Original file line number Diff line number Diff line change @@ -42,14 +42,12 @@ void _copyAppId(String appId) {
4242 final clipboard = window.navigator.clipboard;
4343 if (clipboard == null ) return ;
4444 clipboard.writeText (appId);
45- _showCopiedMessage (appId);
45+ _notifyCopiedSuccess (appId);
4646}
4747
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) {
246246 final chromeError = chrome.runtime.lastError;
247247 if (chromeError != null ) {
248248 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 );
256250 return ;
257251 }
258252 }),
@@ -720,16 +714,10 @@ Future<bool> _showWarning(
720714
721715Future <bool > _showWarningNotification (String message) {
722716 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 ((_) {
733721 completer.complete (true );
734722 }),
735723 );
Original file line number Diff line number Diff line change 11{
22 "name" : " Dart Debug Extension" ,
3- "version" : " 1.38 " ,
3+ "version" : " 1.40 " ,
44 "manifest_version" : 2 ,
55 "devtools_page" : " static_assets/devtools.html" ,
66 "browser_action" : {
2525 {
2626 "matches" : [" <all_urls>" ],
2727 "js" : [" detector.dart.js" , " copier.dart.js" ],
28- "css" : [" static_assets/styles.css" ],
2928 "run_at" : " document_end"
3029 }
3130 ],
Original file line number Diff line number Diff line change 11{
22 "name" : " Dart Debug Extension" ,
3- "version" : " 1.38 " ,
3+ "version" : " 1.40 " ,
44 "manifest_version" : 3 ,
55 "devtools_page" : " static_assets/devtools.html" ,
66 "action" : {
3232 {
3333 "matches" : [" <all_urls>" ],
3434 "js" : [" detector.dart.js" , " copier.dart.js" ],
35- "css" : [" static_assets/styles.css" ],
3635 "run_at" : " document_end"
3736 }
3837 ],
Original file line number Diff line number Diff line change 7575}
7676
7777.snackbar {
78- top : 0px ;
78+ bottom : 0px ;
7979 color : # eeeeee ;
8080 font-family : Roboto, 'Helvetica Neue' , sans-serif;
8181 left : 0px ;
@@ -113,44 +113,22 @@ h6 {
113113
114114@-webkit-keyframes fadein {
115115 from {
116- top : 0 ;
116+ bottom : 0 ;
117117 opacity : 0 ;
118118 }
119119 to {
120- top : 0px ;
120+ bottom : 0px ;
121121 opacity : 1 ;
122122 }
123123}
124124
125125@keyframes fadein {
126126 from {
127- top : 0 ;
127+ bottom : 0 ;
128128 opacity : 0 ;
129129 }
130130 to {
131- top : 0px ;
131+ bottom : 0px ;
132132 opacity : 1 ;
133133 }
134134}
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) {
6969 return completer.future;
7070}
7171
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+
7291Future <bool > injectScript (String scriptName, {required int tabId}) async {
7392 if (isMV3) {
7493 await promiseToFuture (
You can’t perform that action at this time.
0 commit comments