Skip to content

Commit 969f41f

Browse files
authored
Save encoded URI for ACX DevTools (#1890)
1 parent 8384a11 commit 969f41f

File tree

7 files changed

+16
-137
lines changed

7 files changed

+16
-137
lines changed

dwds/debug_extension_mv3/web/cross_extension_communication.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ library cross_extension_communication;
88
import 'package:js/js.dart';
99

1010
import 'chrome_api.dart';
11-
import 'data_types.dart';
1211
import 'debug_session.dart';
1312
import 'logger.dart';
1413
import 'storage.dart';
@@ -85,7 +84,7 @@ void _respondWithChromeResult(Object? chromeResult, Function sendResponse) {
8584
}
8685

8786
void _respondWithEncodedUri(int tabId, Function sendResponse) async {
88-
final encodedUri = await fetchStorageObject<EncodedUri>(
87+
final encodedUri = await fetchStorageObject<String>(
8988
type: StorageObject.encodedUri, tabId: tabId);
9089
sendResponse(encodedUri ?? '');
9190
}

dwds/debug_extension_mv3/web/data_serializers.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ part 'data_serializers.g.dart';
2121
DevToolsOpener,
2222
DevToolsUrl,
2323
DevToolsRequest,
24-
EncodedUri,
2524
ExtensionEvent,
2625
ExtensionRequest,
2726
ExtensionResponse,

dwds/debug_extension_mv3/web/data_serializers.g.dart

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/debug_extension_mv3/web/data_types.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ abstract class DevToolsOpener
3535
bool get newWindow;
3636
}
3737

38-
// TODO(elliette): Standardize on uri or url here and across DWDS, instead of a
39-
// combination of both.
40-
abstract class EncodedUri implements Built<EncodedUri, EncodedUriBuilder> {
41-
static Serializer<EncodedUri> get serializer => _$encodedUriSerializer;
42-
43-
factory EncodedUri([Function(EncodedUriBuilder) updates]) = _$EncodedUri;
44-
45-
EncodedUri._();
46-
47-
String get uri;
48-
}
49-
5038
abstract class DevToolsUrl implements Built<DevToolsUrl, DevToolsUrlBuilder> {
5139
static Serializer<DevToolsUrl> get serializer => _$devToolsUrlSerializer;
5240

dwds/debug_extension_mv3/web/data_types.g.dart

Lines changed: 0 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/debug_extension_mv3/web/debug_session.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ void _routeDwdsEvent(String eventData, SocketClient client, int tabId) {
247247
if (message.method == 'dwds.devtoolsUri') {
248248
_openDevTools(message.params, dartAppTabId: tabId);
249249
}
250+
if (message.method == 'dwds.encodedUri') {
251+
setStorageObject(
252+
type: StorageObject.encodedUri,
253+
value: message.params,
254+
tabId: tabId,
255+
);
256+
}
250257
}
251258
}
252259

dwds/debug_extension_mv3/web/storage.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ Future<bool> setStorageObject<T>({
4444
void Function()? callback,
4545
}) {
4646
final storageKey = _createStorageKey(type, tabId);
47-
final json = jsonEncode(serializers.serialize(value));
47+
final json =
48+
value is String ? value : jsonEncode(serializers.serialize(value));
4849
final storageObj = <String, String>{storageKey: json};
4950
final completer = Completer<bool>();
5051
final storageArea = _getStorageArea(type.persistance);
@@ -73,9 +74,13 @@ Future<T?> fetchStorageObject<T>({required StorageObject type, int? tabId}) {
7374
debugWarn('Does not exist.', prefix: storageKey);
7475
completer.complete(null);
7576
} else {
76-
final value = serializers.deserialize(jsonDecode(json)) as T;
7777
debugLog('Fetched: $json', prefix: storageKey);
78-
completer.complete(value);
78+
if (T == String) {
79+
completer.complete(json as T);
80+
} else {
81+
final value = serializers.deserialize(jsonDecode(json)) as T;
82+
completer.complete(value);
83+
}
7984
}
8085
}));
8186
return completer.future;

0 commit comments

Comments
 (0)