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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/workspace/IsolatedFileSystem.js

Issue 1369063002: DevTools: merge excluded folder manager into isolated file system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 22 matching lines...) Expand all
33 * @param {!WebInspector.IsolatedFileSystemManager} manager 33 * @param {!WebInspector.IsolatedFileSystemManager} manager
34 * @param {string} path 34 * @param {string} path
35 * @param {string} name 35 * @param {string} name
36 * @param {string} rootURL 36 * @param {string} rootURL
37 */ 37 */
38 WebInspector.IsolatedFileSystem = function(manager, path, name, rootURL) 38 WebInspector.IsolatedFileSystem = function(manager, path, name, rootURL)
39 { 39 {
40 this._manager = manager; 40 this._manager = manager;
41 this._path = path; 41 this._path = path;
42 this._domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL ); 42 this._domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL );
43 this._excludedFoldersSetting = WebInspector.settings.createLocalSetting("wor kspaceExcludedFolders", {});
44 this._excludedFolders = this._excludedFoldersSetting.get()[path] || [];
43 } 45 }
44 46
45 /** 47 /**
46 * @param {!FileError} error 48 * @param {!FileError} error
47 * @return {string} 49 * @return {string}
48 */ 50 */
49 WebInspector.IsolatedFileSystem.errorMessage = function(error) 51 WebInspector.IsolatedFileSystem.errorMessage = function(error)
50 { 52 {
51 return WebInspector.UIString("File system error: %s", error.message); 53 return WebInspector.UIString("File system error: %s", error.message);
52 } 54 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 96
95 /** 97 /**
96 * @param {!Array.<!FileEntry>} entries 98 * @param {!Array.<!FileEntry>} entries
97 * @this {WebInspector.IsolatedFileSystem} 99 * @this {WebInspector.IsolatedFileSystem}
98 */ 100 */
99 function innerCallback(entries) 101 function innerCallback(entries)
100 { 102 {
101 for (var i = 0; i < entries.length; ++i) { 103 for (var i = 0; i < entries.length; ++i) {
102 var entry = entries[i]; 104 var entry = entries[i];
103 if (!entry.isDirectory) { 105 if (!entry.isDirectory) {
104 if (this._manager.excludedFolderManager().isFileExcluded(thi s._path, entry.fullPath)) 106 if (this._isFileExcluded(entry.fullPath))
105 continue; 107 continue;
106 fileCallback(entry.fullPath.substr(1)); 108 fileCallback(entry.fullPath.substr(1));
107 } 109 }
108 else { 110 else {
109 if (this._manager.excludedFolderManager().isFileExcluded(thi s._path, entry.fullPath + "/")) 111 if (this._isFileExcluded(entry.fullPath + "/"))
110 continue; 112 continue;
111 ++pendingRequests; 113 ++pendingRequests;
112 this._requestEntries(entry.fullPath, innerCallback.bind(this )); 114 this._requestEntries(entry.fullPath, innerCallback.bind(this ));
113 } 115 }
114 } 116 }
115 if (finishedCallback && (--pendingRequests === 0)) 117 if (finishedCallback && (--pendingRequests === 0))
116 finishedCallback(); 118 finishedCallback();
117 } 119 }
118 }, 120 },
119 121
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 { 481 {
480 this._readDirectory(dirEntry, callback); 482 this._readDirectory(dirEntry, callback);
481 } 483 }
482 484
483 function errorHandler(error) 485 function errorHandler(error)
484 { 486 {
485 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro r); 487 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro r);
486 console.error(errorMessage + " when requesting entry '" + path + "'" ); 488 console.error(errorMessage + " when requesting entry '" + path + "'" );
487 callback([]); 489 callback([]);
488 } 490 }
491 },
492
493 _saveExcludedFolders: function()
494 {
495 var settingValue = this._excludedFoldersSetting.get();
496 settingValue[this._path] = this._excludedFolders;
497 this._excludedFoldersSetting.set(settingValue);
498 },
499
500 /**
501 * @param {string} path
502 */
503 addExcludedFolder: function(path)
504 {
505 this._excludedFolders.push(path);
506 this._saveExcludedFolders();
507 this._manager.dispatchEventToListeners(WebInspector.IsolatedFileSystemMa nager.Events.ExcludedFolderAdded, path);
508 },
509
510 /**
511 * @param {string} path
512 */
513 removeExcludedFolder: function(path)
514 {
515 this._excludedFolders.remove(path);
516 this._saveExcludedFolders();
517 this._manager.dispatchEventToListeners(WebInspector.IsolatedFileSystemMa nager.Events.ExcludedFolderRemoved, path);
518 },
519
520 fileSystemRemoved: function()
521 {
522 var settingValue = this._excludedFoldersSetting.get();
523 delete settingValue[this._path];
524 this._excludedFoldersSetting.set(settingValue);
525 },
526
527 /**
528 * @param {string} folderPath
529 * @return {boolean}
530 */
531 _isFileExcluded: function(folderPath)
532 {
533 for (var i = 0; i < this._excludedFolders.length; ++i) {
534 if (this._excludedFolders[i] === folderPath)
535 return true;
536 }
537 var regex = this._manager.workspaceFolderExcludePatternSetting().asRegEx p();
538 return !!(regex && regex.test(folderPath));
539 },
540
541 /**
542 * @return {!Array<string>}
543 */
544 excludedFolders: function()
545 {
546 return this._excludedFolders.slice();
489 } 547 }
490 } 548 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698