Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: ui/file_manager/file_manager/background/js/background_base.js

Issue 562103002: Files.app: Split background.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+};
« no previous file with comments | « ui/file_manager/file_manager/background/js/background.js ('k') | ui/file_manager/file_manager/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698