Commit 479878c1 authored by yoshiki's avatar yoshiki Committed by Commit bot

Files.app: Split background.js

This patch splits the background.js into the 3 files (background_base.js, app_window_wrapper.js, background.js), extracting the common classes.

This patch itself doesn't change any functionality, but the extracted files will be used in the separated audio player app in near future.

BUG=375039
TEST=browser_test passes

Review URL: https://codereview.chromium.org/562103002

Cr-Commit-Position: refs/heads/master@{#294998}
parent 0a24cfc9
// 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;
};
......@@ -41,20 +41,6 @@
"webview"
],
"file_browser_handlers": [
{
"id": "play",
"default_title": "__MSG_PLAY_MEDIA__",
"default_icon": "common/images/file_types/200/audio.png",
"file_filters": [
"filesystem:*.amr",
"filesystem:*.flac",
"filesystem:*.m4a",
"filesystem:*.mp3",
"filesystem:*.oga",
"filesystem:*.ogg",
"filesystem:*.wav"
]
},
{
"id": "mount-archive",
"default_title": "__MSG_MOUNT_ARCHIVE__",
......@@ -156,6 +142,8 @@
// enough that anything is passed to web_accessible_resources. If there is
// at least any file, then all files are allowed. http://crbug.com/179127.
"web_accessible_resources": [
"background/js/app_window_wrapper.js",
"background/js/background_base.js",
"background/js/test_util.js",
"background/js/volume_manager.js",
"common/js/async_util.js",
......@@ -187,6 +175,8 @@
"common/js/progress_center_common.js",
"common/js/util.js",
"common/js/volume_manager_common.js",
"background/js/app_window_wrapper.js",
"background/js/background_base.js",
"background/js/device_handler.js",
"background/js/drive_sync_handler.js",
"background/js/file_operation_handler.js",
......
......@@ -17,19 +17,23 @@
<include name="IDR_FILE_MANAGER_MAIN_JS" file="file_manager/foreground/js/main_scripts.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_FILE_MANAGER_BKGND_JS" file="file_manager/background/js/background.js" type="BINDATA" />
<!-- Scripts working in background page. -->
<!-- Commone Scripts. -->
<include name="IDR_FILE_MANAGER_ERROR_UTIL_JS" file="file_manager/common/js/error_util.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_ASYNC_UTIL_JS" file="file_manager/common/js/async_util.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_PROGRESS_CENTER_COMMON_JS" file="file_manager/common/js/progress_center_common.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_UTIL_JS" file="file_manager/common/js/util.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_VOLUME_MANAGER_COMMON_JS" file="file_manager/common/js/volume_manager_common.js" flattenhtml="false" type="BINDATA" />
<!-- Scripts working in background page. -->
<include name="IDR_FILE_MANAGER_DEVICE_APP_WINDOW_WRAPPER_JS" file="file_manager/background/js/app_window_wrapper.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_DEVICE_BACKGROUND_BASE_JS" file="file_manager/background/js/background_base.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_DEVICE_HANDLER_JS" file="file_manager/background/js/device_handler.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_DRIVE_SYNC_HANDLER_JS" file="file_manager/background/js/drive_sync_handler.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_FILE_OPERATION_HANDLER_JS" file="file_manager/background/js/file_operation_handler.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_FILE_OPERATION_MANAGER_JS" file="file_manager/background/js/file_operation_manager.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_PROGRESS_CENTER_COMMON_JS" file="file_manager/common/js/progress_center_common.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_PROGRESS_CENTER_JS" file="file_manager/background/js/progress_center.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_TEST_UTIL_JS" file="file_manager/background/js/test_util.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_UTIL_JS" file="file_manager/common/js/util.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_VOLUME_MANAGER_JS" file="file_manager/background/js/volume_manager.js" flattenhtml="false" type="BINDATA" />
<include name="IDR_FILE_MANAGER_VOLUME_MANAGER_COMMON_JS" file="file_manager/common/js/volume_manager_common.js" flattenhtml="false" type="BINDATA" />
<!-- Scripts referred by the gallery app. -->
<include name="IDR_FILE_MANAGER_FILE_TYPE_JS" file="file_manager/foreground/js/file_type.js" flattenhtml="false" type="BINDATA" />
......
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