OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.Object} |
34 */ | 34 */ |
35 WebInspector.IsolatedFileSystemManager = function() | 35 WebInspector.IsolatedFileSystemManager = function() |
36 { | 36 { |
37 /** @type {!Object.<string, !WebInspector.IsolatedFileSystem>} */ | 37 /** @type {!Object.<string, !WebInspector.IsolatedFileSystem>} */ |
38 this._fileSystems = {}; | 38 this._fileSystems = {}; |
39 this._excludedFolderManager = new WebInspector.ExcludedFolderManager(); | |
40 | 39 |
41 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemsLoaded, this._onFileSystemsLoaded, this); | 40 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemsLoaded, this._onFileSystemsLoaded, this); |
42 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemRemoved, this._onFileSystemRemoved, this); | 41 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemRemoved, this._onFileSystemRemoved, this); |
43 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemAdded, this._onFileSystemAdded, this); | 42 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemAdded, this._onFileSystemAdded, this); |
| 43 |
| 44 this._initExcludePatterSetting(); |
44 } | 45 } |
45 | 46 |
46 /** @typedef {!{fileSystemName: string, rootURL: string, fileSystemPath: string}
} */ | 47 /** @typedef {!{fileSystemName: string, rootURL: string, fileSystemPath: string}
} */ |
47 WebInspector.IsolatedFileSystemManager.FileSystem; | 48 WebInspector.IsolatedFileSystemManager.FileSystem; |
48 | 49 |
49 WebInspector.IsolatedFileSystemManager.Events = { | 50 WebInspector.IsolatedFileSystemManager.Events = { |
50 FileSystemAdded: "FileSystemAdded", | 51 FileSystemAdded: "FileSystemAdded", |
51 FileSystemRemoved: "FileSystemRemoved" | 52 FileSystemRemoved: "FileSystemRemoved", |
| 53 ExcludedFolderAdded: "ExcludedFolderAdded", |
| 54 ExcludedFolderRemoved: "ExcludedFolderRemoved" |
52 } | 55 } |
53 | 56 |
54 WebInspector.IsolatedFileSystemManager.prototype = { | 57 WebInspector.IsolatedFileSystemManager.prototype = { |
55 /** | 58 /** |
56 * @return {!WebInspector.ExcludedFolderManager} | |
57 */ | |
58 excludedFolderManager: function() | |
59 { | |
60 return this._excludedFolderManager; | |
61 }, | |
62 | |
63 /** | |
64 * @param {function()} callback | 59 * @param {function()} callback |
65 */ | 60 */ |
66 initialize: function(callback) | 61 initialize: function(callback) |
67 { | 62 { |
68 console.assert(!this._loaded); | |
69 this._initializeCallback = callback; | 63 this._initializeCallback = callback; |
70 InspectorFrontendHost.requestFileSystems(); | 64 InspectorFrontendHost.requestFileSystems(); |
71 }, | 65 }, |
72 | 66 |
73 addFileSystem: function() | 67 addFileSystem: function() |
74 { | 68 { |
75 InspectorFrontendHost.addFileSystem(); | 69 InspectorFrontendHost.addFileSystem(); |
76 }, | 70 }, |
77 | 71 |
78 /** | 72 /** |
79 * @param {string} fileSystemPath | 73 * @param {string} fileSystemPath |
80 */ | 74 */ |
81 removeFileSystem: function(fileSystemPath) | 75 removeFileSystem: function(fileSystemPath) |
82 { | 76 { |
83 InspectorFrontendHost.removeFileSystem(fileSystemPath); | 77 InspectorFrontendHost.removeFileSystem(fileSystemPath); |
84 }, | 78 }, |
85 | 79 |
86 /** | 80 /** |
87 * @param {!WebInspector.Event} event | 81 * @param {!WebInspector.Event} event |
88 */ | 82 */ |
89 _onFileSystemsLoaded: function(event) | 83 _onFileSystemsLoaded: function(event) |
90 { | 84 { |
91 var fileSystems = /** @type {!Array.<!WebInspector.IsolatedFileSystemMan
ager.FileSystem>} */ (event.data); | 85 var fileSystems = /** @type {!Array.<!WebInspector.IsolatedFileSystemMan
ager.FileSystem>} */ (event.data); |
92 var addedFileSystemPaths = {}; | 86 var addedFileSystemPaths = {}; |
93 for (var i = 0; i < fileSystems.length; ++i) { | 87 for (var i = 0; i < fileSystems.length; ++i) { |
94 this._innerAddFileSystem(fileSystems[i]); | 88 this._innerAddFileSystem(fileSystems[i]); |
95 addedFileSystemPaths[fileSystems[i].fileSystemPath] = true; | 89 addedFileSystemPaths[fileSystems[i].fileSystemPath] = true; |
96 } | 90 } |
97 | 91 |
98 this._loaded = true; | |
99 | |
100 this._initializeCallback(); | 92 this._initializeCallback(); |
101 delete this._initializeCallback; | 93 delete this._initializeCallback; |
102 }, | 94 }, |
103 | 95 |
104 /** | 96 /** |
105 * @param {!WebInspector.IsolatedFileSystemManager.FileSystem} fileSystem | 97 * @param {!WebInspector.IsolatedFileSystemManager.FileSystem} fileSystem |
106 */ | 98 */ |
107 _innerAddFileSystem: function(fileSystem) | 99 _innerAddFileSystem: function(fileSystem) |
108 { | 100 { |
109 var fileSystemPath = fileSystem.fileSystemPath; | 101 var fileSystemPath = fileSystem.fileSystemPath; |
(...skipping 21 matching lines...) Expand all Loading... |
131 _onFileSystemRemoved: function(event) | 123 _onFileSystemRemoved: function(event) |
132 { | 124 { |
133 this._fileSystemRemoved(/** @type {string} */ (event.data)); | 125 this._fileSystemRemoved(/** @type {string} */ (event.data)); |
134 }, | 126 }, |
135 | 127 |
136 /** | 128 /** |
137 * @param {string} fileSystemPath | 129 * @param {string} fileSystemPath |
138 */ | 130 */ |
139 _fileSystemRemoved: function(fileSystemPath) | 131 _fileSystemRemoved: function(fileSystemPath) |
140 { | 132 { |
141 this._excludedFolderManager.removeFileSystem(fileSystemPath); | |
142 var isolatedFileSystem = this._fileSystems[fileSystemPath]; | 133 var isolatedFileSystem = this._fileSystems[fileSystemPath]; |
143 delete this._fileSystems[fileSystemPath]; | 134 delete this._fileSystems[fileSystemPath]; |
144 if (isolatedFileSystem) | 135 if (isolatedFileSystem) { |
| 136 isolatedFileSystem.fileSystemRemoved(); |
145 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager
.Events.FileSystemRemoved, isolatedFileSystem); | 137 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager
.Events.FileSystemRemoved, isolatedFileSystem); |
| 138 } |
146 }, | 139 }, |
147 | 140 |
148 /** | 141 /** |
149 * @return {!Array<string>} | 142 * @return {!Array<string>} |
150 */ | 143 */ |
151 fileSystemPaths: function() | 144 fileSystemPaths: function() |
152 { | 145 { |
153 return Object.keys(this._fileSystems); | 146 return Object.keys(this._fileSystems); |
154 }, | 147 }, |
155 | 148 |
| 149 /** |
| 150 * @param {string} fileSystemPath |
| 151 * @return {?WebInspector.IsolatedFileSystem} |
| 152 */ |
| 153 fileSystem: function(fileSystemPath) |
| 154 { |
| 155 return this._fileSystems[fileSystemPath]; |
| 156 }, |
| 157 |
| 158 _initExcludePatterSetting: function() |
| 159 { |
| 160 var defaultCommonExcludedFolders = [ |
| 161 "/\\.git/", |
| 162 "/\\.sass-cache/", |
| 163 "/\\.hg/", |
| 164 "/\\.idea/", |
| 165 "/\\.svn/", |
| 166 "/\\.cache/", |
| 167 "/\\.project/" |
| 168 ]; |
| 169 var defaultWinExcludedFolders = [ |
| 170 "/Thumbs.db$", |
| 171 "/ehthumbs.db$", |
| 172 "/Desktop.ini$", |
| 173 "/\\$RECYCLE.BIN/" |
| 174 ]; |
| 175 var defaultMacExcludedFolders = [ |
| 176 "/\\.DS_Store$", |
| 177 "/\\.Trashes$", |
| 178 "/\\.Spotlight-V100$", |
| 179 "/\\.AppleDouble$", |
| 180 "/\\.LSOverride$", |
| 181 "/Icon$", |
| 182 "/\\._.*$" |
| 183 ]; |
| 184 var defaultLinuxExcludedFolders = [ |
| 185 "/.*~$" |
| 186 ]; |
| 187 var defaultExcludedFolders = defaultCommonExcludedFolders; |
| 188 if (WebInspector.isWin()) |
| 189 defaultExcludedFolders = defaultExcludedFolders.concat(defaultWinExc
ludedFolders); |
| 190 else if (WebInspector.isMac()) |
| 191 defaultExcludedFolders = defaultExcludedFolders.concat(defaultMacExc
ludedFolders); |
| 192 else |
| 193 defaultExcludedFolders = defaultExcludedFolders.concat(defaultLinuxE
xcludedFolders); |
| 194 var defaultExcludedFoldersPattern = defaultExcludedFolders.join("|"); |
| 195 this._workspaceFolderExcludePatternSetting = WebInspector.settings.creat
eRegExpSetting("workspaceFolderExcludePattern", defaultExcludedFoldersPattern, W
ebInspector.isWin() ? "i" : ""); |
| 196 }, |
| 197 |
| 198 /** |
| 199 * @return {!WebInspector.Setting} |
| 200 */ |
| 201 workspaceFolderExcludePatternSetting: function() |
| 202 { |
| 203 return this._workspaceFolderExcludePatternSetting; |
| 204 }, |
| 205 |
156 __proto__: WebInspector.Object.prototype | 206 __proto__: WebInspector.Object.prototype |
157 } | 207 } |
158 | 208 |
159 /** | 209 /** |
160 * @type {!WebInspector.IsolatedFileSystemManager} | 210 * @type {!WebInspector.IsolatedFileSystemManager} |
161 */ | 211 */ |
162 WebInspector.isolatedFileSystemManager; | 212 WebInspector.isolatedFileSystemManager; |
OLD | NEW |