Chromium Code Reviews| Index: chrome/browser/resources/chromeos/arc_support/background.js |
| diff --git a/chrome/browser/resources/chromeos/arc_support/background.js b/chrome/browser/resources/chromeos/arc_support/background.js |
| index 9de2d6a0f550cfbb8f7f319ec8d6012c88951dbe..57a5e55cd330d6a1151125673b4e074429fbd541 100644 |
| --- a/chrome/browser/resources/chromeos/arc_support/background.js |
| +++ b/chrome/browser/resources/chromeos/arc_support/background.js |
| @@ -79,11 +79,11 @@ var INNER_HEIGHT = 688; |
| /** |
| * Sends a native message to ArcSupportHost. |
| - * @param {string} code The action code in message. |
| - * @param {Object=} opt_Props Extra properties for the message. |
| + * @param {string} event The event type in message. |
| + * @param {Object=} opt_props Extra properties for the message. |
| */ |
| -function sendNativeMessage(code, opt_Props) { |
| - var message = Object.assign({'action': code}, opt_Props); |
| +function sendNativeMessage(event, opt_props) { |
| + var message = Object.assign({'event': event}, opt_props); |
| port.postMessage(message); |
| } |
| @@ -469,7 +469,7 @@ chrome.app.runtime.onLaunched.addListener(function() { |
| if (results && results.length == 1 && typeof results[0] == 'string' && |
| results[0].substring(0, authCodePrefix.length) == authCodePrefix) { |
| var authCode = results[0].substring(authCodePrefix.length); |
| - sendNativeMessage('setAuthCode', {code: authCode}); |
| + sendNativeMessage('onAuthSucceeded', {'code': authCode}); |
|
Luis Héctor Chávez
2016/10/03 20:40:16
Google's JavaScript style guide indicate that obje
hidehiko
2016/10/04 04:48:19
Updated as you suggested.
|
| } else { |
| setErrorMessage(appWindow.contentWindow.loadTimeData.getString( |
| 'authorizationFailed')); |
| @@ -529,24 +529,18 @@ chrome.app.runtime.onLaunched.addListener(function() { |
| var onAgree = function() { |
| termsAccepted = true; |
| + var data = {}; |
| var enableMetrics = doc.getElementById('enable-metrics'); |
| if (!enableMetrics.hidden) { |
| - sendNativeMessage('enableMetrics', { |
| - 'enabled': enableMetrics.checked |
| - }); |
| + data['isMetricsEnabled'] = enableMetrics.checked; |
|
Luis Héctor Chávez
2016/10/03 20:40:16
I'm not _entirely_ sure that this particular rule
hidehiko
2016/10/04 04:48:19
Done.
|
| } |
| - |
| var enableBackupRestore = doc.getElementById('enable-backup-restore'); |
| - sendNativeMessage('setBackupRestore', { |
| - 'enabled': enableBackupRestore.checked |
| - }); |
| + data['isBackupRestoreEnabled'] = enableBackupRestore.checked; |
| var enableLocationService = doc.getElementById('enable-location-service'); |
| - sendNativeMessage('setLocationService', { |
| - 'enabled': enableLocationService.checked |
| - }); |
| + data['isLocationServiceEnabled'] = enableLocationService.checked; |
| - sendNativeMessage('startLso'); |
| + sendNativeMessage('onAgreed', data); |
| }; |
| var onCancel = function() { |
| @@ -557,14 +551,16 @@ chrome.app.runtime.onLaunched.addListener(function() { |
| var onRetry = function() { |
| if (termsAccepted) { |
| - sendNativeMessage('startLso'); |
| + // Reuse the onAgree() in case that the user has already accepted |
| + // the ToS. |
| + onAgree(); |
| } else { |
| loadInitialTerms(); |
| } |
| }; |
| var onSendFeedback = function() { |
| - sendNativeMessage('sendFeedback'); |
| + sendNativeMessage('onSendFeedbackClicked'); |
| }; |
| doc.getElementById('button-agree').addEventListener('click', onAgree); |