@@ -20,25 +20,25 @@ import 'messaging.dart';
2020import 'storage.dart' ;
2121import 'utils.dart' ;
2222
23- bool connecting = false ;
24- String backgroundColor = darkColor ;
25- bool isDartApp = true ;
23+ bool _connecting = false ;
24+ String _backgroundColor = _darkColor ;
25+ bool _isDartApp = true ;
2626
27- const bugLinkId = 'bugLink' ;
28- const darkColor = '202125' ;
29- const darkThemeClass = 'dark-theme' ;
30- const hiddenClass = 'hidden' ;
31- const iframeContainerId = 'iframeContainer' ;
32- const landingPageId = 'landingPage' ;
33- const launchDebugConnectionButtonId = 'launchDebugConnectionButton' ;
34- const lightColor = 'ffffff' ;
35- const lightThemeClass = 'light-theme' ;
36- const loadingSpinnerId = 'loadingSpinner' ;
37- const panelAttribute = 'data-panel' ;
38- const panelBodyId = 'panelBody' ;
39- const showClass = 'show' ;
40- const warningBannerId = 'warningBanner' ;
41- const warningMsgId = 'warningMsg' ;
27+ const _bugLinkId = 'bugLink' ;
28+ const _darkColor = '202125' ;
29+ const _darkThemeClass = 'dark-theme' ;
30+ const _hiddenClass = 'hidden' ;
31+ const _iframeContainerId = 'iframeContainer' ;
32+ const _landingPageId = 'landingPage' ;
33+ const _launchDebugConnectionButtonId = 'launchDebugConnectionButton' ;
34+ const _lightColor = 'ffffff' ;
35+ const _lightThemeClass = 'light-theme' ;
36+ const _loadingSpinnerId = 'loadingSpinner' ;
37+ const _panelAttribute = 'data-panel' ;
38+ const _panelBodyId = 'panelBody' ;
39+ const _showClass = 'show' ;
40+ const _warningBannerId = 'warningBanner' ;
41+ const _warningMsgId = 'warningMsg' ;
4242
4343int get _tabId => chrome.devtools.inspectedWindow.tabId;
4444
@@ -52,7 +52,7 @@ void _registerListeners() {
5252 chrome.storage.onChanged.addListener (allowInterop (_handleStorageChanges));
5353 chrome.runtime.onMessage.addListener (allowInterop (_handleRuntimeMessages));
5454 final launchDebugConnectionButton =
55- document.getElementById (launchDebugConnectionButtonId ) as ButtonElement ;
55+ document.getElementById (_launchDebugConnectionButtonId ) as ButtonElement ;
5656 launchDebugConnectionButton.addEventListener ('click' , _launchDebugConnection);
5757
5858 _maybeInjectDevToolsIframe ();
@@ -89,7 +89,7 @@ void _handleRuntimeMessages(
8989 if (connectFailure.tabId != _tabId) {
9090 return ;
9191 }
92- connecting = false ;
92+ _connecting = false ;
9393 _handleConnectFailure (
9494 ConnectFailureReason .fromString (connectFailure.reason ?? 'unknown' ),
9595 );
@@ -112,12 +112,12 @@ void _handleStorageChanges(Object storageObj, String storageArea) {
112112}
113113
114114void _handleDebugInfoChanges (DebugInfo ? debugInfo) async {
115- if (debugInfo == null && isDartApp ) {
116- isDartApp = false ;
115+ if (debugInfo == null && _isDartApp ) {
116+ _isDartApp = false ;
117117 _showWarningBanner ('Dart app is no longer open.' );
118118 }
119- if (debugInfo != null && ! isDartApp ) {
120- isDartApp = true ;
119+ if (debugInfo != null && ! _isDartApp ) {
120+ _isDartApp = true ;
121121 _hideWarningBanner ();
122122 }
123123}
@@ -135,7 +135,7 @@ void _maybeUpdateFileABugLink() async {
135135 );
136136 final isInternal = debugInfo? .isInternalBuild ?? false ;
137137 if (isInternal) {
138- final bugLink = document.getElementById (bugLinkId );
138+ final bugLink = document.getElementById (_bugLinkId );
139139 if (bugLink == null ) return ;
140140 bugLink.setAttribute (
141141 'href' , 'http://b/issues/new?component=775375&template=1369639' );
@@ -144,12 +144,12 @@ void _maybeUpdateFileABugLink() async {
144144
145145void _setColorThemeToMatchChromeDevTools () async {
146146 final chromeTheme = chrome.devtools.panels.themeName;
147- final panelBody = document.getElementById (panelBodyId );
147+ final panelBody = document.getElementById (_panelBodyId );
148148 if (chromeTheme == 'dark' ) {
149- backgroundColor = darkColor ;
149+ _backgroundColor = _darkColor ;
150150 _updateColorThemeForElement (panelBody, isDarkTheme: true );
151151 } else {
152- backgroundColor = lightColor ;
152+ _backgroundColor = _lightColor ;
153153 _updateColorThemeForElement (panelBody, isDarkTheme: false );
154154 }
155155}
@@ -159,18 +159,18 @@ void _updateColorThemeForElement(
159159 required bool isDarkTheme,
160160}) {
161161 if (element == null ) return ;
162- final classToRemove = isDarkTheme ? lightThemeClass : darkThemeClass ;
162+ final classToRemove = isDarkTheme ? _lightThemeClass : _darkThemeClass ;
163163 if (element.classes.contains (classToRemove)) {
164164 element.classes.remove (classToRemove);
165- final classToAdd = isDarkTheme ? darkThemeClass : lightThemeClass ;
165+ final classToAdd = isDarkTheme ? _darkThemeClass : _lightThemeClass ;
166166 element.classes.add (classToAdd);
167167 }
168168}
169169
170170void _handleDebugConnectionLost (String ? reason) {
171171 final detachReason = DetachReason .fromString (reason ?? 'unknown' );
172172 _removeDevToolsIframe ();
173- _updateElementVisibility (landingPageId , visible: true );
173+ _updateElementVisibility (_landingPageId , visible: true );
174174 if (detachReason != DetachReason .canceledByUser) {
175175 _showWarningBanner ('Lost connection.' );
176176 }
@@ -190,26 +190,26 @@ void _handleConnectFailure(ConnectFailureReason reason) {
190190 default :
191191 _showWarningBanner ('Failed to connect, please try again.' );
192192 }
193- _updateElementVisibility (launchDebugConnectionButtonId , visible: true );
194- _updateElementVisibility (loadingSpinnerId , visible: false );
193+ _updateElementVisibility (_launchDebugConnectionButtonId , visible: true );
194+ _updateElementVisibility (_loadingSpinnerId , visible: false );
195195}
196196
197197void _showWarningBanner (String message) {
198- final warningMsg = document.getElementById (warningMsgId );
198+ final warningMsg = document.getElementById (_warningMsgId );
199199 warningMsg? .setInnerHtml (message);
200200 print (warningMsg);
201- final warningBanner = document.getElementById (warningBannerId );
202- warningBanner? .classes.add (showClass );
201+ final warningBanner = document.getElementById (_warningBannerId );
202+ warningBanner? .classes.add (_showClass );
203203}
204204
205205void _hideWarningBanner () {
206- final warningBanner = document.getElementById (warningBannerId );
207- warningBanner? .classes.remove (showClass );
206+ final warningBanner = document.getElementById (_warningBannerId );
207+ warningBanner? .classes.remove (_showClass );
208208}
209209
210210void _launchDebugConnection (Event _) async {
211- _updateElementVisibility (launchDebugConnectionButtonId , visible: false );
212- _updateElementVisibility (loadingSpinnerId , visible: true );
211+ _updateElementVisibility (_launchDebugConnectionButtonId , visible: false );
212+ _updateElementVisibility (_loadingSpinnerId , visible: true );
213213 final json = jsonEncode (serializers.serialize (DebugStateChange ((b) => b
214214 ..tabId = _tabId
215215 ..newState = DebugStateChange .startDebugging)));
@@ -222,9 +222,9 @@ void _launchDebugConnection(Event _) async {
222222}
223223
224224void _maybeHandleConnectionTimeout () async {
225- connecting = true ;
225+ _connecting = true ;
226226 await Future .delayed (Duration (seconds: 10 ));
227- if (connecting == true ) {
227+ if (_connecting == true ) {
228228 _handleConnectFailure (ConnectFailureReason .timeout);
229229 }
230230}
@@ -238,31 +238,31 @@ void _maybeInjectDevToolsIframe() async {
238238}
239239
240240void _injectDevToolsIframe (String devToolsUri) {
241- connecting = false ;
242- final iframeContainer = document.getElementById (iframeContainerId );
241+ _connecting = false ;
242+ final iframeContainer = document.getElementById (_iframeContainerId );
243243 if (iframeContainer == null ) return ;
244- final panelBody = document.getElementById (panelBodyId );
245- final panelType = panelBody? .getAttribute (panelAttribute ) ?? 'debugger' ;
244+ final panelBody = document.getElementById (_panelBodyId );
245+ final panelType = panelBody? .getAttribute (_panelAttribute ) ?? 'debugger' ;
246246 final iframe = document.createElement ('iframe' );
247247 final iframeSrc = addQueryParameters (
248248 devToolsUri,
249249 queryParameters: {
250250 'ide' : 'ChromeDevTools' ,
251251 'embed' : 'true' ,
252252 'page' : panelType,
253- 'backgroundColor ' : backgroundColor ,
253+ '_backgroundColor ' : _backgroundColor ,
254254 },
255255 );
256256 iframe.setAttribute ('src' , iframeSrc);
257257 _hideWarningBanner ();
258- _updateElementVisibility (landingPageId , visible: false );
259- _updateElementVisibility (loadingSpinnerId , visible: false );
260- _updateElementVisibility (launchDebugConnectionButtonId , visible: true );
258+ _updateElementVisibility (_landingPageId , visible: false );
259+ _updateElementVisibility (_loadingSpinnerId , visible: false );
260+ _updateElementVisibility (_launchDebugConnectionButtonId , visible: true );
261261 iframeContainer.append (iframe);
262262}
263263
264264void _removeDevToolsIframe () {
265- final iframeContainer = document.getElementById (iframeContainerId );
265+ final iframeContainer = document.getElementById (_iframeContainerId );
266266 final iframe = iframeContainer? .firstChild;
267267 if (iframe == null ) return ;
268268 iframe.remove ();
@@ -272,8 +272,8 @@ void _updateElementVisibility(String elementId, {required bool visible}) {
272272 final element = document.getElementById (elementId);
273273 if (element == null ) return ;
274274 if (visible) {
275- element.classes.remove (hiddenClass );
275+ element.classes.remove (_hiddenClass );
276276 } else {
277- element.classes.add (hiddenClass );
277+ element.classes.add (_hiddenClass );
278278 }
279279}
0 commit comments