Skip to content

Commit

Permalink
Add chrome://nfc-debug for debugging NFC on Chrome OS.
Browse files Browse the repository at this point in the history
Wrote a simple WebUI page that demonstrates the functionality of the NFC API
defined in device/nfc. This is primarily meant for testing and demo purposes.

BUG=336687

Review URL: https://codereview.chromium.org/131103007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247118 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
armansito@chromium.org committed Jan 25, 2014
1 parent 1f58a75 commit f4660c6
Show file tree
Hide file tree
Showing 13 changed files with 1,468 additions and 1 deletion.
88 changes: 88 additions & 0 deletions chrome/app/generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -15476,6 +15476,94 @@ Do you accept?
</message>
</if>

<!-- About NFC Debug UI display strings -->
<if expr="pp_ifdef('chromeos')">
<message name="IDS_NFC_DEBUG_TITLE" desc="Title of the debug page meant for developers to test NFC functionality">
NFC API Test Page
</message>
<message name="IDS_NFC_DEBUG_NOT_SUPPORTED" desc="Message shown if the NFC API is not supported on platform">
NFC is not supported on the current platform.
</message>
<message name="IDS_NFC_DEBUG_ADAPTER_HEADER" desc="Header of the 'NFC Adapter' box, that shows the state of the NFC adapter">
NFC Adapter
</message>
<message name="IDS_NFC_DEBUG_ADAPTER_POWER_ON" desc="Adapter power button text to turn the adapter on">
Power ON
</message>
<message name="IDS_NFC_DEBUG_ADAPTER_POWER_OFF" desc="Adapter power button text to turn the adapter off">
Power OFF
</message>
<message name="IDS_NFC_DEBUG_ADAPTER_START_POLL" desc="Adapter poll button text to start polling">
Start Poll
</message>
<message name="IDS_NFC_DEBUG_ADAPTER_STOP_POLL" desc="Adapter poll button text to stop polling">
Stop Poll
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_HEADER" desc="Header of the 'NFC NDEF message form' box used send a message to tag/peer">
Push/Write NDEF Message
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_TYPE_TEXT" desc="NDEF message form dropdown menu item for message type 'Text'">
Text
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_TYPE_URI" desc="NDEF message form dropdown menu item for message type 'URI'">
URI
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_TYPE_SMART_POSTER" desc="NDEF message form dropdown menu text for message type 'SmartPoster'">
SmartPoster
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_TEXT" desc="Label for required input field 'Text'">
Text (required):
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_ENCODING" desc="Label for required input field 'Encoding'">
Encoding (required):
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_LANGUAGE_CODE" desc="Label for required input field 'Language Code'">
Language Code (required):
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_URI" desc="Label for required input field 'URI'">
URI (required):
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_MIME_TYPE" desc="Label for input field 'MIME Type'">
MIME Type:
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_TARGET_SIZE" desc="Label for input field 'Target Size'">
Target Size:
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_TITLE_TEXT" desc="Label for required input field 'Title Text'">
Title Text (required):
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_TITLE_ENCODING" desc="Label for required input field 'Title Encoding'">
Title Encoding (required):
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_FIELD_TITLE_LANGUAGE_CODE" desc="Label for required input field 'Title Language Code'">
Title Language Code (required):
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_WRITE_BUTTON" desc="NDEF message form button text for writing message to an NFC tag">
Write to Tag
</message>
<message name="IDS_NFC_DEBUG_NDEF_FORM_PUSH_BUTTON" desc="NDEF message form button text for pushing a message to an NFC peer device">
Push to Peer
</message>
<message name="IDS_NFC_DEBUG_NFC_PEER_HEADER" desc="Header of the 'NFC Peer' box">
NDEF Peer
</message>
<message name="IDS_NFC_DEBUG_NFC_TAG_HEADER" desc="Header of the 'NFC Tag' box">
NDEF Tag
</message>
<message name="IDS_NFC_DEBUG_RECORDS_HEADER" desc="Header of the 'Records' section in the tag and peer boxes">
Records
</message>
<message name="IDS_NFC_DEBUG_ERROR_FAILED_TO_SET_POWER" desc="Error message shown when adapter power could not be set.">
Failed to set adapter power.
</message>
<message name="IDS_NFC_DEBUG_ERROR_FAILED_TO_SET_POLLING" desc="Error message shown when polling state could not be set.">
Failed to start/stop polling.
</message>
<message name="IDS_NFC_DEBUG_ERROR_FAILED_TO_SUBMIT_PREFIX" desc="Error message shown when an NDEF form could not be submitted.">
Failed to submit NDEF:
</message>
</if>

<!-- About power UI display strings -->
<if expr="pp_ifdef('chromeos')">
<message name="IDS_ABOUT_POWER_TITLE" desc="Title of the page">
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/browser_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@
<include name="IDR_MOBILE_SETUP_PORTAL_PAGE_HTML" file="resources\chromeos\mobile_setup_portal.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_NETWORK_MENU_CSS" file="resources\chromeos\network_menu.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_NETWORK_MENU_JS" file="resources\chromeos\network_menu.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_NFC_DEBUG_HTML" file="resources\chromeos\nfc_debug.html" type="BINDATA" />
<include name="IDR_NFC_DEBUG_CSS" file="resources\chromeos\nfc_debug.css" type="BINDATA" />
<include name="IDR_NFC_DEBUG_JS" file="resources\chromeos\nfc_debug.js" type="BINDATA" />
<include name="IDR_NOTIFICATION_ICON_LINK_HTML" file="resources\chromeos\notification_icon_link.html" type="BINDATA" />
<include name="IDR_ECHO_MANIFEST" file="resources\chromeos\echo\manifest.json" type="BINDATA" />
<include name="IDR_OFFLINE_APP_LOAD_HTML" file="resources\chromeos\offline_app_load.html" flattenhtml="true" type="BINDATA" />
Expand Down
85 changes: 85 additions & 0 deletions chrome/browser/resources/chromeos/nfc_debug.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

body {
margin: 0
}

p {
white-space: pre-wrap;
}

label {
display: block;
}

h1 {
margin: 1%;
}

div.entity-div {
-webkit-box-shadow: 0 0 20px 2px #aaa;
box-shadow: 0 0 20px 2px #aaa;
display: inline-block;
margin: 10px 5px;
overflow: hidden;
padding: 10px;
vertical-align: top;
}

#nfc-adapter-info {
width: 165px;
}

#ndef-record-form {
width: 300px;
}

#nfc-tag-info,
#nfc-peer-info {
width: 270px;
word-wrap: break-word;
}

#ndef-record-form input {
width: 99%;
}

.parameters-table td {
padding: 0 10px 10px 0;
}

.transition-in {
-webkit-transition: opacity 250ms ease-in-out;
opacity: 1;
transition: opacity 250ms ease-in-out;
}

.transition-out {
-webkit-transition: opacity 250ms ease-in-out;
opacity: 0.25;
transition: opacity 250ms ease-in-out;
}

hr {
background: #888;
border: 0;
border-bottom: 1px dashed #ccc;
}

div.record-key-value-div {
margin-bottom: 10px;
}

span.record-key-span,
div.record-key-div {
font-style: italic;
font-weight: bold;
margin-right: 10px;
}

.record-value-div > * {
margin: 10px;
}
130 changes: 130 additions & 0 deletions chrome/browser/resources/chromeos/nfc_debug.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<!DOCTYPE html>
<html i18n-values="dir:textdirection;">
<head>
<meta charset="utf-8">
<title i18n-content="titleText"></title>
<link rel="stylesheet" type="text/css" href="nfc_debug.css">
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="strings.js"></script>
<script src="nfc_debug.js"></script>
</head>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<h1 i18n-content="titleText"></h1>
<p id="nfc-not-supported" i18n-content="notSupportedText"></p>
<div id="wrapper">
<div id="nfc-adapter-info" class="entity-div">
<h3 i18n-content="adapterHeaderText"></h3>
<div id="adapter-parameters"></div>
<div id="adapter-toggles">
<button id="power-toggle"></button>
<button id="poll-toggle"></button>
</div>
</div>
<div id="ndef-record-form" class="entity-div">
<h3 i18n-content="ndefFormHeaderText"></h3>
<select id="record-type-menu">
<option i18n-content="ndefFormTypeTextText" value="text"></option>
<option i18n-content="ndefFormTypeUriText" value="uri"></option>
<option i18n-content="ndefFormTypeSmartPosterText" value="smart-poster">
</option>
</select>
<div id="text-form" class="record-form">
<div>
<label for="text-form-text" class="required"
i18n-content="ndefFormFieldTextText">
</label>
<input type="text" id="text-form-text">
</div>
<div>
<label for="text-form-encoding" class="required"
i18n-content="ndefFormFieldEncodingText">
</label>
<input type="text" id="text-form-encoding">
</div>
<div>
<label for="text-form-language-code" class="required"
i18n-content="ndefFormFieldLanguageCodeText">
</label>
<input type="text" id="text-form-language-code">
</div>
</div>
<div id="uri-form" class="record-form">
<div>
<label for="uri-form-uri" class="required"
i18n-content="ndefFormFieldUriText"></label>
<input type="text" id="uri-form-uri">
</div>
<div>
<label for="uri-form-mime-type"
i18n-content="ndefFormFieldMimeTypeText"></label>
<input type="text" id="uri-form-mime-type">
</div>
<div>
<label for="uri-form-target-size"
i18n-content="ndefFormFieldTargetSizeText"></label>
<input type="text" id="uri-form-target-size">
</div>
</div>
<div id="smart-poster-form" class="record-form">
<div>
<label for="smart-poster-form-uri"
i18n-content="ndefFormFieldUriText"></label>
<input type="text" id="smart-poster-form-uri">
</div>
<div>
<label for="smart-poster-form-mime-type"
i18n-content="ndefFormFieldMimeTypeText"></label>
<input type="text" id="smart-poster-form-mime-type">
</div>
<div>
<label for="smart-poster-form-target-size"
i18n-content="ndefFormFieldTargetSizeText"></label>
<input type="text" id="smart-poster-form-target-size">
</div>
<div>
<label for="smart-poster-form-title-text"
i18n-content="ndefFormFieldTitleTextText">
</label>
<input type="text" id="smart-poster-form-title-text">
</div>
<div>
<label for="smart-poster-form-title-encoding"
i18n-content="ndefFormFieldTitleEncodingText">
</label>
<input type="text" id="smart-poster-form-title-encoding">
</div>
<div>
<label for="smart-poster-form-title-language-code"
i18n-content="ndefFormFieldTitleLanguageCodeText">
</label>
<input type="text" id="smart-poster-form-title-language-code">
</div>
</div>
<button id="record-form-submit-button"></button>
</div>
<div id="nfc-peer-info" class="entity-div">
<h3 i18n-content="nfcPeerHeaderText"></h3>
<div id="peer-parameters"></div>
<div id="peer-records-entry" class="records-entry">
<h3 i18n-content="recordsHeaderText"></h3>
<hr/>
<div id="peer-records-container"></div>
<hr/>
</div>
</div>
<div id="nfc-tag-info" class="entity-div">
<h3 i18n-content="nfcTagHeaderText"></h3>
<div id="tag-parameters"></div>
<div id="tag-records-entry" class="records-entry">
<h3 i18n-content="recordsHeaderText"></h3>
<hr/>
<div id="tag-records-container"></div>
<hr/>
</div>
</div>
</div>
<script src="chrome://resources/js/i18n_template2.js"></script>
</body>
</html>
Loading

0 comments on commit f4660c6

Please sign in to comment.