| 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 26a57c8c6904511e5854e3383e8bd9320a89e01d..9de2d6a0f550cfbb8f7f319ec8d6012c88951dbe 100644
|
| --- a/chrome/browser/resources/chromeos/arc_support/background.js
|
| +++ b/chrome/browser/resources/chromeos/arc_support/background.js
|
| @@ -41,19 +41,6 @@ var termsView = null;
|
| var port = null;
|
|
|
| /**
|
| - * Indicates that window was closed internally and it is not required to send
|
| - * closure notification.
|
| - * @type {boolean}
|
| - */
|
| -var windowClosedInternally = false;
|
| -
|
| -/**
|
| - * Timer for terms reload.
|
| - * @type {Object}
|
| - */
|
| -var termsReloadTimeout = null;
|
| -
|
| -/**
|
| * Stores current device id.
|
| * @type {string}
|
| */
|
| @@ -91,16 +78,6 @@ var INNER_HEIGHT = 688;
|
|
|
|
|
| /**
|
| - * Closes current window in response to request from native code. This does not
|
| - * issue 'cancelAuthCode' message to native code.
|
| - */
|
| -function closeWindowInternally() {
|
| - windowClosedInternally = true;
|
| - appWindow.close();
|
| - appWindow = null;
|
| -}
|
| -
|
| -/**
|
| * Sends a native message to ArcSupportHost.
|
| * @param {string} code The action code in message.
|
| * @param {Object=} opt_Props Extra properties for the message.
|
| @@ -301,8 +278,10 @@ function onNativeMessage(message) {
|
| setBackupRestoreMode(message.enabled, message.managed);
|
| } else if (message.action == 'setLocationServiceMode') {
|
| setLocationServiceMode(message.enabled, message.managed);
|
| - } else if (message.action == 'closeUI') {
|
| - closeWindowInternally();
|
| + } else if (message.action == 'closeWindow') {
|
| + if (appWindow) {
|
| + appWindow.close();
|
| + }
|
| } else if (message.action == 'showPage') {
|
| showPageWithStatus(message.page, message.status);
|
| } else if (message.action == 'setWindowBounds') {
|
| @@ -320,8 +299,8 @@ function connectPort() {
|
| }
|
|
|
| /**
|
| - * Shows requested page and hide others. Show appWindow if it was hidden before
|
| - * for non 'none' pages. For 'none' page this closes host window.
|
| + * Shows requested page and hide others. Show appWindow if it was hidden before.
|
| + * 'none' hides all views.
|
| * @param {string} pageDivId id of divider of the page to show.
|
| */
|
| function showPage(pageDivId) {
|
| @@ -329,11 +308,6 @@ function showPage(pageDivId) {
|
| return;
|
| }
|
|
|
| - if (pageDivId == 'none') {
|
| - closeWindowInternally();
|
| - return;
|
| - }
|
| -
|
| var doc = appWindow.contentWindow.document;
|
| var pages = doc.getElementsByClassName('section');
|
| var sendFeedbackElement = doc.getElementById('button-send-feedback');
|
| @@ -577,9 +551,7 @@ chrome.app.runtime.onLaunched.addListener(function() {
|
|
|
| var onCancel = function() {
|
| if (appWindow) {
|
| - windowClosedInternally = false;
|
| appWindow.close();
|
| - appWindow = null;
|
| }
|
| };
|
|
|
| @@ -607,24 +579,23 @@ chrome.app.runtime.onLaunched.addListener(function() {
|
| var onWindowCreated = function(createdWindow) {
|
| appWindow = createdWindow;
|
| appWindow.contentWindow.onload = onAppContentLoad;
|
| - createdWindow.onClosed.addListener(onWindowClosed);
|
| + appWindow.onClosed.addListener(onWindowClosed);
|
|
|
| setWindowBounds();
|
| };
|
|
|
| var onWindowClosed = function() {
|
| - if (termsReloadTimeout) {
|
| - clearTimeout(termsReloadTimeout);
|
| - termsReloadTimeout = null;
|
| - }
|
| + appWindow = null;
|
|
|
| - if (windowClosedInternally) {
|
| - return;
|
| - }
|
| - sendNativeMessage('cancelAuthCode');
|
| - };
|
| + // Notify to Chrome.
|
| + sendNativeMessage('onWindowClosed');
|
|
|
| - windowClosedInternally = false;
|
| + // On window closed, then dispose the extension. So, close the port
|
| + // otherwise the background page would be kept alive so that the extension
|
| + // would not be unloaded.
|
| + port.disconnect();
|
| + port = null;
|
| + };
|
|
|
| var options = {
|
| 'id': 'play_store_wnd',
|
|
|