| Index: ui/file_manager/file_manager/background/js/background_base.js
|
| diff --git a/ui/file_manager/file_manager/background/js/background_base.js b/ui/file_manager/file_manager/background/js/background_base.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..588b34900e8966b3c55e82eed058137517be9a8a
|
| --- /dev/null
|
| +++ b/ui/file_manager/file_manager/background/js/background_base.js
|
| @@ -0,0 +1,47 @@
|
| +// 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.
|
| +
|
| +'use strict';
|
| +
|
| +/**
|
| + * Root class of the background page.
|
| + * @constructor
|
| + */
|
| +function BackgroundBase() {
|
| + /**
|
| + * Map of all currently open app windows. The key is an app ID.
|
| + * @type {Object.<string, AppWindow>}
|
| + */
|
| + this.appWindows = {};
|
| +}
|
| +
|
| +/**
|
| + * Checks the current condition of background page.
|
| + * @return {boolean} True if the background page can be closed. False if not.
|
| + */
|
| +BackgroundBase.prototype.canClose = function() {
|
| + return true;
|
| +};
|
| +
|
| +/**
|
| + * Checks the current condition of background page and closes it if possible.
|
| + */
|
| +BackgroundBase.prototype.tryClose = function() {
|
| + if (this.canClose())
|
| + window.close();
|
| +};
|
| +
|
| +/**
|
| + * Gets similar windows, it means with the same initial url.
|
| + * @param {string} url URL that the obtained windows have.
|
| + * @return {Array.<AppWindow>} List of similar windows.
|
| + */
|
| +BackgroundBase.prototype.getSimilarWindows = function(url) {
|
| + var result = [];
|
| + for (var appID in this.appWindows) {
|
| + if (this.appWindows[appID].contentWindow.appInitialURL === url)
|
| + result.push(this.appWindows[appID]);
|
| + }
|
| + return result;
|
| +};
|
|
|