Skip to content

Commit

Permalink
Display a warning when running Connector on non-Chrome OS system (#35)
Browse files Browse the repository at this point in the history
This commit adds a warning message displayed in the Connector app's window when it's executed on a non-Chrome OS platform. The reason for this is that, on one side, we want to discourage people from running it on the desktop platforms (because it can only bring very limited benefit on them); while on the other side, we want to allow the Connector app to be used by third-party client app developers for testing purposes.

Fixes #27.
  • Loading branch information
emaxx-google authored Aug 25, 2016
1 parent 1e13822 commit d587acb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
4 changes: 4 additions & 0 deletions smart_card_connector_app/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"message": "Smart Card Connector",
"description": "The header displayed in the main window"
},
"nonChromeOsWarning": {
"message": "Warning: The app is intended to be run on Chrome OS only!",
"description": "The text that is displayed as a warning when the app is executed on non-Chrome OS systems"
},
"windowClose": {
"message": "Close",
"description": "Accessibility text for close button"
Expand Down
26 changes: 21 additions & 5 deletions smart_card_connector_app/src/window-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ goog.require('GoogleSmartCard.I18n');
goog.require('GoogleSmartCard.Logging');
goog.require('GoogleSmartCard.PopupWindow.Client');
goog.require('goog.dom');
goog.require('goog.dom.classlist');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('goog.log.Logger');
Expand All @@ -45,10 +46,6 @@ var logger = GSC.Logging.getScopedLogger('ConnectorApp.MainWindow');

logger.info('The main window is created');

function closeWindowClickListener() {
chrome.app.window.current().close();
}

goog.events.listen(
goog.dom.getElement('close-window'),
goog.events.EventType.CLICK,
Expand All @@ -59,8 +56,27 @@ GSC.ConnectorApp.Window.AppsDisplaying.initialize();
GSC.ConnectorApp.Window.DevicesDisplaying.initialize();
GSC.ConnectorApp.Window.LogsExporting.initialize();

GSC.I18n.adjustElementsTranslation();

GSC.PopupWindow.Client.showWindow();

GSC.I18n.adjustElementsTranslation();
displayNonChromeOsWarningIfNeeded();

function closeWindowClickListener() {
chrome.app.window.current().close();
}

function displayNonChromeOsWarningIfNeeded() {
chrome.runtime.getPlatformInfo(function(platformInfo) {
/** @type {string} */
var os = platformInfo['os'];
if (os != 'cros') {
logger.info('Displaying the warning regarding non-Chrome OS system ' +
'(the current OS is "' + os + '")');
goog.dom.classlist.remove(
goog.dom.getElement('non-chrome-os-warning'), 'hidden');
}
});
}

}); // goog.scope
11 changes: 11 additions & 0 deletions smart_card_connector_app/src/window.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
-webkit-user-select: text;
}

.hidden {
display: none;
}

html,
body,
button {
Expand Down Expand Up @@ -58,6 +62,13 @@ body {
-webkit-user-select: none;
}

#non-chrome-os-warning {
color: red;
font-size: 15px;
font-weight: 600;
margin-top: 15px;
}

.list-header {
color: #4285f4;
font-size: 12px;
Expand Down
2 changes: 2 additions & 0 deletions smart_card_connector_app/src/window.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<h1 id="header" data-i18n="mainWindowHeader"></h1>
</div>

<div id="non-chrome-os-warning" class="hidden" data-i18n="nonChromeOsWarning"></div>

<button id="close-window" data-i18n-aria-label="windowClose">×</button>

<h2 id="readers-list-header" class="list-header" data-i18n="readersListHeader"></h2>
Expand Down

0 comments on commit d587acb

Please sign in to comment.