Commit f946918f authored by Peter Beverloo's avatar Peter Beverloo Committed by Commit Bot

Add a phrase to display the Android Secret on chrome://gcm-internals

There are good reasons for displaying the Android Secret on this page,
but we need to make sure that users don't include it by accident when
making a screenshot for other reasons.

Following this CL, they can type "secret" to display the Android Secret
that's associated with the already included Android ID.

Bug: 833949
Change-Id: I20131dbf0f113738cd1f9acd2ece0763db032921
Reviewed-on: https://chromium-review.googlesource.com/1034803
Commit-Queue: Peter Beverloo <peter@chromium.org>
Reviewed-by: default avatarAnita Woodruff <awdf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555861}
parent 3317f6f5
...@@ -9,34 +9,30 @@ namespace gcm { ...@@ -9,34 +9,30 @@ namespace gcm {
GCMClient::ChromeBuildInfo::ChromeBuildInfo() GCMClient::ChromeBuildInfo::ChromeBuildInfo()
: platform(PLATFORM_UNSPECIFIED), channel(CHANNEL_UNKNOWN) {} : platform(PLATFORM_UNSPECIFIED), channel(CHANNEL_UNKNOWN) {}
GCMClient::ChromeBuildInfo::~ChromeBuildInfo() { GCMClient::ChromeBuildInfo::~ChromeBuildInfo() = default;
}
GCMClient::SendErrorDetails::SendErrorDetails() : result(UNKNOWN_ERROR) {} GCMClient::SendErrorDetails::SendErrorDetails() : result(UNKNOWN_ERROR) {}
GCMClient::SendErrorDetails::SendErrorDetails(const SendErrorDetails& other) = GCMClient::SendErrorDetails::SendErrorDetails(const SendErrorDetails& other) =
default; default;
GCMClient::SendErrorDetails::~SendErrorDetails() {} GCMClient::SendErrorDetails::~SendErrorDetails() = default;
GCMClient::GCMStatistics::GCMStatistics() GCMClient::GCMStatistics::GCMStatistics()
: is_recording(false), : is_recording(false),
gcm_client_created(false), gcm_client_created(false),
connection_client_created(false), connection_client_created(false),
android_id(0), android_id(0u),
android_secret(0u),
send_queue_size(0), send_queue_size(0),
resend_queue_size(0) { resend_queue_size(0) {}
}
GCMClient::GCMStatistics::GCMStatistics(const GCMStatistics& other) = default; GCMClient::GCMStatistics::GCMStatistics(const GCMStatistics& other) = default;
GCMClient::GCMStatistics::~GCMStatistics() { GCMClient::GCMStatistics::~GCMStatistics() = default;
}
GCMClient::GCMClient() { GCMClient::GCMClient() = default;
}
GCMClient::~GCMClient() { GCMClient::~GCMClient() = default;
}
} // namespace gcm } // namespace gcm
...@@ -129,6 +129,7 @@ class GCMClient { ...@@ -129,6 +129,7 @@ class GCMClient {
base::Time last_checkin; base::Time last_checkin;
base::Time next_checkin; base::Time next_checkin;
uint64_t android_id; uint64_t android_id;
uint64_t android_secret;
std::vector<std::string> registered_app_ids; std::vector<std::string> registered_app_ids;
int send_queue_size; int send_queue_size;
int resend_queue_size; int resend_queue_size;
......
...@@ -1292,6 +1292,9 @@ GCMClient::GCMStatistics GCMClientImpl::GetStatistics() const { ...@@ -1292,6 +1292,9 @@ GCMClient::GCMStatistics GCMClientImpl::GetStatistics() const {
} }
if (device_checkin_info_.android_id > 0) if (device_checkin_info_.android_id > 0)
stats.android_id = device_checkin_info_.android_id; stats.android_id = device_checkin_info_.android_id;
if (device_checkin_info_.secret > 0)
stats.android_secret = device_checkin_info_.secret;
recorder_.CollectActivities(&stats.recorded_activities); recorder_.CollectActivities(&stats.recorded_activities);
for (RegistrationInfoMap::const_iterator it = registrations_.begin(); for (RegistrationInfoMap::const_iterator it = registrations_.begin();
......
...@@ -17,6 +17,7 @@ const char kSetGcmInternalsRecording[] = "setGcmInternalsRecording"; ...@@ -17,6 +17,7 @@ const char kSetGcmInternalsRecording[] = "setGcmInternalsRecording";
// GCM internal info. // GCM internal info.
const char kAndroidId[] = "androidId"; const char kAndroidId[] = "androidId";
const char kAndroidSecret[] = "androidSecret";
const char kCheckinInfo[] = "checkinInfo"; const char kCheckinInfo[] = "checkinInfo";
const char kConnectionClientCreated[] = "connectionClientCreated"; const char kConnectionClientCreated[] = "connectionClientCreated";
const char kConnectionInfo[] = "connectionInfo"; const char kConnectionInfo[] = "connectionInfo";
......
...@@ -21,6 +21,7 @@ extern const char kSetGcmInternalsRecording[]; ...@@ -21,6 +21,7 @@ extern const char kSetGcmInternalsRecording[];
// GCM internal info. // GCM internal info.
// Must match the constants used in the resource files. // Must match the constants used in the resource files.
extern const char kAndroidId[]; extern const char kAndroidId[];
extern const char kAndroidSecret[];
extern const char kCheckinInfo[]; extern const char kCheckinInfo[];
extern const char kConnectionClientCreated[]; extern const char kConnectionClientCreated[];
extern const char kConnectionInfo[]; extern const char kConnectionInfo[];
......
...@@ -133,6 +133,10 @@ void SetGCMInternalsInfo(const gcm::GCMClient::GCMStatistics* stats, ...@@ -133,6 +133,10 @@ void SetGCMInternalsInfo(const gcm::GCMClient::GCMStatistics* stats,
device_info->SetString( device_info->SetString(
kAndroidId, base::StringPrintf("0x%" PRIx64, stats->android_id)); kAndroidId, base::StringPrintf("0x%" PRIx64, stats->android_id));
} }
if (stats->android_secret > 0) {
device_info->SetString(kAndroidSecret,
base::NumberToString(stats->android_secret));
}
device_info->SetInteger(kSendQueueSize, stats->send_queue_size); device_info->SetInteger(kSendQueueSize, stats->send_queue_size);
device_info->SetInteger(kResendQueueSize, stats->resend_queue_size); device_info->SetInteger(kResendQueueSize, stats->resend_queue_size);
results->Set(kDeviceInfo, std::move(device_info)); results->Set(kDeviceInfo, std::move(device_info));
......
...@@ -32,7 +32,7 @@ th { ...@@ -32,7 +32,7 @@ th {
padding: 0px 4px; padding: 0px 4px;
} }
#device-info tr :first-child { #device-info tr > :first-child {
font-weight: bold; font-weight: bold;
padding-right: 10px; padding-right: 10px;
text-align: end; text-align: end;
...@@ -41,3 +41,7 @@ th { ...@@ -41,3 +41,7 @@ th {
.log-table { .log-table {
padding: 4px; padding: 4px;
} }
#android-secret-container.invisible {
display: none;
}
...@@ -37,7 +37,11 @@ ...@@ -37,7 +37,11 @@
<td> <td>
Android Id Android Id
</td> </td>
<td id="android-id"> <td>
<span id="android-id"></span>
<span id="android-secret-container" class="invisible">
(<b>secret</b>: <span id="android-secret"></span>)
</span>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -6,6 +6,7 @@ cr.define('gcmInternals', function() { ...@@ -6,6 +6,7 @@ cr.define('gcmInternals', function() {
'use strict'; 'use strict';
var isRecording = false; var isRecording = false;
var keyPressState = 0;
/** /**
* If the info dictionary has property prop, then set the text content of * If the info dictionary has property prop, then set the text content of
...@@ -32,6 +33,7 @@ cr.define('gcmInternals', function() { ...@@ -32,6 +33,7 @@ cr.define('gcmInternals', function() {
*/ */
function displayDeviceInfo(info) { function displayDeviceInfo(info) {
setIfExists(info, 'androidId', 'android-id'); setIfExists(info, 'androidId', 'android-id');
setIfExists(info, 'androidSecret', 'android-secret');
setIfExists(info, 'profileServiceCreated', 'profile-service-created'); setIfExists(info, 'profileServiceCreated', 'profile-service-created');
setIfExists(info, 'gcmEnabled', 'gcm-enabled'); setIfExists(info, 'gcmEnabled', 'gcm-enabled');
setIfExists(info, 'gcmClientCreated', 'gcm-client-created'); setIfExists(info, 'gcmClientCreated', 'gcm-client-created');
...@@ -112,6 +114,28 @@ cr.define('gcmInternals', function() { ...@@ -112,6 +114,28 @@ cr.define('gcmInternals', function() {
chrome.send('setGcmInternalsRecording', [true]); chrome.send('setGcmInternalsRecording', [true]);
} }
/**
* Allows displaying the Android Secret by typing a secret phrase.
*
* There are good reasons for displaying the Android Secret associated with
* the local connection info, but we also need to be careful to make sure that
* users don't share this value by accident. Therefore we require a secret
* phrase to be typed into the page for making it visible.
*
* @param {!Event} event The keypress event handler.
*/
function handleKeyPress(event) {
var PHRASE = 'secret';
if (PHRASE.charCodeAt(keyPressState) === event.keyCode) {
if (++keyPressState < PHRASE.length)
return;
$('android-secret-container').classList.remove('invisible');
}
keyPressState = 0;
}
/** /**
* Refresh the log html table by clearing it first. If data is not empty, then * Refresh the log html table by clearing it first. If data is not empty, then
* it will be used to populate the table. * it will be used to populate the table.
...@@ -154,8 +178,10 @@ cr.define('gcmInternals', function() { ...@@ -154,8 +178,10 @@ cr.define('gcmInternals', function() {
// Return an object with all of the exports. // Return an object with all of the exports.
return { return {
initialize: initialize, initialize: initialize,
handleKeyPress: handleKeyPress,
setGcmInternalsInfo: setGcmInternalsInfo, setGcmInternalsInfo: setGcmInternalsInfo,
}; };
}); });
document.addEventListener('DOMContentLoaded', gcmInternals.initialize); document.addEventListener('DOMContentLoaded', gcmInternals.initialize);
document.addEventListener('keypress', gcmInternals.handleKeyPress);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment