DevTools: Extract JS module declarations from compile_frontend.py into js_modules

R=aandrey, eustas, vsevik
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/blink/trunk@164216 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/Source/devtools/scripts/compile_frontend.py b/third_party/WebKit/Source/devtools/scripts/compile_frontend.py
index 7aebc6e..62ada41 100755
--- a/third_party/WebKit/Source/devtools/scripts/compile_frontend.py
+++ b/third_party/WebKit/Source/devtools/scripts/compile_frontend.py
@@ -35,6 +35,10 @@
 import subprocess
 import sys
 import tempfile
+try:
+    import json
+except ImportError:
+    import simplejson as json
 
 scripts_path = os.path.dirname(os.path.abspath(__file__))
 devtools_path = os.path.dirname(scripts_path)
@@ -49,365 +53,14 @@
 generate_protocol_externs.generate_protocol_externs(protocol_externs_path, devtools_path + "/protocol.json")
 
 jsmodule_name_prefix = "jsmodule_"
-modules = [
-    {
-        "name": "common",
-        "dependencies": [],
-        "sources": [
-            "Color.js",
-            "DOMExtension.js",
-            "Object.js",
-            "ParsedURL.js",
-            "Progress.js",
-            "Settings.js",
-            "TextRange.js",
-            "UIString.js",
-            "UserMetrics.js",
-            "utilities.js",
-            "Geometry.js",
-        ]
-    },
-    {
-        "name": "sdk",
-        "dependencies": ["common"],
-        "sources": [
-            "ApplicationCacheModel.js",
-            "CompilerScriptMapping.js",
-            "ConsoleModel.js",
-            "ContentProvider.js",
-            "ContentProviderBasedProjectDelegate.js",
-            "ContentProviders.js",
-            "CookieParser.js",
-            "CSSFormatter.js",
-            "CSSMetadata.js",
-            "CSSStyleModel.js",
-            "CSSStyleSheetMapping.js",
-            "BreakpointManager.js",
-            "Database.js",
-            "DOMAgent.js",
-            "DOMStorage.js",
-            "DebuggerModel.js",
-            "DebuggerScriptMapping.js",
-            "FileManager.js",
-            "FileSystemMapping.js",
-            "FileSystemModel.js",
-            "FileSystemProjectDelegate.js",
-            "FileUtils.js",
-            "HAREntry.js",
-            "IndexedDBModel.js",
-            "InspectorBackend.js",
-            "IsolatedFileSystemManager.js",
-            "IsolatedFileSystem.js",
-            "JavaScriptFormatter.js",
-            "Linkifier.js",
-            "NetworkLog.js",
-            "NetworkUISourceCodeProvider.js",
-            "OverridesSupport.js",
-            "PresentationConsoleMessageHelper.js",
-            "RuntimeModel.js",
-            "SASSSourceMapping.js",
-            "Script.js",
-            "ScriptFormatter.js",
-            "ScriptFormatterWorker.js",
-            "ScriptSnippetModel.js",
-            "SimpleWorkspaceProvider.js",
-            "SnippetStorage.js",
-            "SourceMapping.js",
-            "StylesSourceMapping.js",
-            "TempFile.js",
-            "TimelineManager.js",
-            "RemoteObject.js",
-            "Resource.js",
-            "DefaultScriptMapping.js",
-            "ResourceScriptMapping.js",
-            "LiveEditSupport.js",
-            "ResourceTreeModel.js",
-            "ResourceType.js",
-            "ResourceUtils.js",
-            "SourceMap.js",
-            "TracingAgent.js",
-            "NetworkManager.js",
-            "NetworkRequest.js",
-            "UISourceCode.js",
-            "Workspace.js",
-            "WorkspaceController.js",
-        ]
-    },
-    {
-        "name": "ui",
-        "dependencies": ["common"],
-        "sources": [
-            "Checkbox.js",
-            "ContextMenu.js",
-            "CompletionDictionary.js",
-            "DOMSyntaxHighlighter.js",
-            "DataGrid.js",
-            "Dialog.js",
-            "DockController.js",
-            "Drawer.js",
-            "EmptyView.js",
-            "FilterBar.js",
-            "GoToLineDialog.js",
-            "HelpScreen.js",
-            "InspectorView.js",
-            "KeyboardShortcut.js",
-            "OverviewGrid.js",
-            "Panel.js",
-            "Placard.js",
-            "Popover.js",
-            "ProgressIndicator.js",
-            "PropertiesSection.js",
-            "SearchableView.js",
-            "Section.js",
-            "SidebarPane.js",
-            "SidebarTreeElement.js",
-            "ShortcutsScreen.js",
-            "ShowMoreDataGridNode.js",
-            "SidebarOverlay.js",
-            "SoftContextMenu.js",
-            "Spectrum.js",
-            "SplitView.js",
-            "SidebarView.js",
-            "StatusBarButton.js",
-            "SuggestBox.js",
-            "TabbedPane.js",
-            "TextEditor.js",
-            "TextPrompt.js",
-            "TextUtils.js",
-            "TimelineGrid.js",
-            "UIUtils.js",
-            "View.js",
-            "ViewportControl.js",
-            "treeoutline.js",
-        ]
-    },
-    {
-        "name": "components",
-        "dependencies": ["sdk", "ui"],
-        "sources": [
-            "AdvancedSearchController.js",
-            "HandlerRegistry.js",
-            "ConsoleMessage.js",
-            "CookiesTable.js",
-            "DOMBreakpointsSidebarPane.js",
-            "DOMPresentationUtils.js",
-            "ElementsTreeOutline.js",
-            "FontView.js",
-            "ImageView.js",
-            "NativeBreakpointsSidebarPane.js",
-            "InspectElementModeController.js",
-            "ObjectPopoverHelper.js",
-            "ObjectPropertiesSection.js",
-            "ScreencastView.js",
-            "SourceFrame.js",
-            "ResourceView.js",
-        ]
-    },
-    {
-        "name": "elements",
-        "dependencies": ["components"],
-        "sources": [
-            "CSSNamedFlowCollectionsView.js",
-            "CSSNamedFlowView.js",
-            "ElementsPanel.js",
-            "ElementsPanelDescriptor.js",
-            "EventListenersSidebarPane.js",
-            "MetricsSidebarPane.js",
-            "OverridesView.js",
-            "PlatformFontsSidebarPane.js",
-            "PropertiesSidebarPane.js",
-            "StylesSidebarPane.js",
-            "RenderingOptionsView.js",
-        ]
-    },
-    {
-        "name": "network",
-        "dependencies": ["components"],
-        "sources": [
-            "NetworkItemView.js",
-            "RequestCookiesView.js",
-            "RequestHeadersView.js",
-            "RequestHTMLView.js",
-            "RequestJSONView.js",
-            "RequestPreviewView.js",
-            "RequestResponseView.js",
-            "RequestTimingView.js",
-            "RequestView.js",
-            "ResourceWebSocketFrameView.js",
-            "NetworkPanel.js",
-            "NetworkPanelDescriptor.js",
-        ]
-    },
-    {
-        "name": "resources",
-        "dependencies": ["components"],
-        "sources": [
-            "ApplicationCacheItemsView.js",
-            "CookieItemsView.js",
-            "DatabaseQueryView.js",
-            "DatabaseTableView.js",
-            "DirectoryContentView.js",
-            "DOMStorageItemsView.js",
-            "FileContentView.js",
-            "FileSystemView.js",
-            "IndexedDBViews.js",
-            "ResourcesPanel.js",
-        ]
-    },
-    {
-        "name": "workers",
-        "dependencies": ["components"],
-        "sources": [
-            "WorkerManager.js",
-        ]
-    },
-    {
-        "name": "scripts",
-        "dependencies": ["components", "workers"],
-        "sources": [
-            "BreakpointsSidebarPane.js",
-            "CSSSourceFrame.js",
-            "CallStackSidebarPane.js",
-            "FilePathScoreFunction.js",
-            "FilteredItemSelectionDialog.js",
-            "JavaScriptSourceFrame.js",
-            "NavigatorOverlayController.js",
-            "NavigatorView.js",
-            "RevisionHistoryView.js",
-            "ScopeChainSidebarPane.js",
-            "SourcesNavigator.js",
-            "SourcesPanel.js",
-            "SourcesPanelDescriptor.js",
-            "SourcesSearchScope.js",
-            "StyleSheetOutlineDialog.js",
-            "TabbedEditorContainer.js",
-            "UISourceCodeFrame.js",
-            "WatchExpressionsSidebarPane.js",
-            "WorkersSidebarPane.js",
-        ]
-    },
-    {
-        "name": "console",
-        "dependencies": ["components"],
-        "sources": [
-            "ConsoleView.js",
-            "ConsolePanel.js",
-        ]
-    },
-    {
-        "name": "timeline",
-        "dependencies": ["components"],
-        "sources": [
-            "DOMCountersGraph.js",
-            "MemoryStatistics.js",
-            "PieChart.js",
-            "TimelineEventOverview.js",
-            "TimelineFrameOverview.js",
-            "TimelineMemoryOverview.js",
-            "TimelineModel.js",
-            "TimelineOverviewPane.js",
-            "TimelinePanel.js",
-            "TimelinePanelDescriptor.js",
-            "TimelinePresentationModel.js",
-            "TimelineFrameController.js"
-        ]
-    },
-    {
-        "name": "audits",
-        "dependencies": ["components"],
-        "sources": [
-            "AuditCategories.js",
-            "AuditController.js",
-            "AuditFormatters.js",
-            "AuditLauncherView.js",
-            "AuditResultView.js",
-            "AuditRules.js",
-            "AuditsPanel.js",
-        ]
-    },
-    {
-        "name": "codemirror",
-        "dependencies": ["components"],
-        "sources": [
-            "CodeMirrorTextEditor.js",
-            "CodeMirrorUtils.js",
-        ]
-    },
-    {
-        "name": "layers",
-        "dependencies": ["components"],
-        "sources": [
-            "LayerTreeModel.js",
-            "LayersPanel.js",
-            "LayersPanelDescriptor.js",
-            "LayerTree.js",
-            "Layers3DView.js",
-            "LayerDetailsView.js",
-            "PaintProfilerView.js",
-        ]
-    },
-    {
-        "name": "extensions",
-        "dependencies": ["components"],
-        "sources": [
-            "ExtensionAPI.js",
-            "ExtensionAuditCategory.js",
-            "ExtensionPanel.js",
-            "ExtensionRegistryStub.js",
-            "ExtensionServer.js",
-            "ExtensionView.js",
-        ]
-    },
-    {
-        "name": "settings",
-        "dependencies": ["components", "extensions"],
-        "sources": [
-            "SettingsScreen.js",
-            "EditFileSystemDialog.js",
-        ]
-    },
-    {
-        "name": "tests",
-        "dependencies": ["components"],
-        "sources": [
-            "TestController.js",
-        ]
-    },
-    {
-        "name": "profiler",
-        "dependencies": ["components", "workers"],
-        "sources": [
-            "AllocationProfile.js",
-            "BottomUpProfileDataGridTree.js",
-            "CPUProfileView.js",
-            "FlameChart.js",
-            "HeapSnapshot.js",
-            "HeapSnapshotDataGrids.js",
-            "HeapSnapshotGridNodes.js",
-            "HeapSnapshotLoader.js",
-            "HeapSnapshotProxy.js",
-            "HeapSnapshotView.js",
-            "HeapSnapshotWorker.js",
-            "HeapSnapshotWorkerDispatcher.js",
-            "JSHeapSnapshot.js",
-            "ProfileDataGridTree.js",
-            "ProfilesPanel.js",
-            "ProfilesPanelDescriptor.js",
-            "ProfileLauncherView.js",
-            "TopDownProfileDataGridTree.js",
-            "CanvasProfileView.js",
-            "CanvasReplayStateView.js",
-        ]
-    },
-    {
-        "name": "host_stub",
-        "dependencies": ["components", "profiler", "timeline"],
-        "sources": [
-            "InspectorFrontendAPI.js",
-            "InspectorFrontendHostStub.js",
-        ]
-    }
-]
+js_modules_name = "frontend_modules.json"
+
+try:
+    with open(os.path.join(scripts_path, js_modules_name), "rt") as js_modules_file:
+        modules = json.loads(js_modules_file.read())
+except:
+    print "ERROR: Failed to read %s" % js_modules_name
+    raise
 
 # `importScript` function must not be used in any files
 # except module headers. Refer to devtools.gyp file for
diff --git a/third_party/WebKit/Source/devtools/scripts/frontend_modules.json b/third_party/WebKit/Source/devtools/scripts/frontend_modules.json
new file mode 100755
index 0000000..0245486
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/scripts/frontend_modules.json
@@ -0,0 +1,359 @@
+[
+    {
+        "name": "common",
+        "dependencies": [],
+        "sources": [
+            "Color.js",
+            "DOMExtension.js",
+            "Object.js",
+            "ParsedURL.js",
+            "Progress.js",
+            "Settings.js",
+            "TextRange.js",
+            "UIString.js",
+            "UserMetrics.js",
+            "utilities.js",
+            "Geometry.js"
+        ]
+    },
+    {
+        "name": "sdk",
+        "dependencies": ["common"],
+        "sources": [
+            "ApplicationCacheModel.js",
+            "CompilerScriptMapping.js",
+            "ConsoleModel.js",
+            "ContentProvider.js",
+            "ContentProviderBasedProjectDelegate.js",
+            "ContentProviders.js",
+            "CookieParser.js",
+            "CSSFormatter.js",
+            "CSSMetadata.js",
+            "CSSStyleModel.js",
+            "CSSStyleSheetMapping.js",
+            "BreakpointManager.js",
+            "Database.js",
+            "DOMAgent.js",
+            "DOMStorage.js",
+            "DebuggerModel.js",
+            "DebuggerScriptMapping.js",
+            "FileManager.js",
+            "FileSystemMapping.js",
+            "FileSystemModel.js",
+            "FileSystemProjectDelegate.js",
+            "FileUtils.js",
+            "HAREntry.js",
+            "IndexedDBModel.js",
+            "InspectorBackend.js",
+            "IsolatedFileSystemManager.js",
+            "IsolatedFileSystem.js",
+            "JavaScriptFormatter.js",
+            "Linkifier.js",
+            "NetworkLog.js",
+            "NetworkUISourceCodeProvider.js",
+            "OverridesSupport.js",
+            "PresentationConsoleMessageHelper.js",
+            "RuntimeModel.js",
+            "SASSSourceMapping.js",
+            "Script.js",
+            "ScriptFormatter.js",
+            "ScriptFormatterWorker.js",
+            "ScriptSnippetModel.js",
+            "SimpleWorkspaceProvider.js",
+            "SnippetStorage.js",
+            "SourceMapping.js",
+            "StylesSourceMapping.js",
+            "TempFile.js",
+            "TimelineManager.js",
+            "RemoteObject.js",
+            "Resource.js",
+            "DefaultScriptMapping.js",
+            "ResourceScriptMapping.js",
+            "LiveEditSupport.js",
+            "ResourceTreeModel.js",
+            "ResourceType.js",
+            "ResourceUtils.js",
+            "SourceMap.js",
+            "TracingAgent.js",
+            "NetworkManager.js",
+            "NetworkRequest.js",
+            "UISourceCode.js",
+            "Workspace.js",
+            "WorkspaceController.js"
+        ]
+    },
+    {
+        "name": "ui",
+        "dependencies": ["common"],
+        "sources": [
+            "Checkbox.js",
+            "ContextMenu.js",
+            "CompletionDictionary.js",
+            "DOMSyntaxHighlighter.js",
+            "DataGrid.js",
+            "Dialog.js",
+            "DockController.js",
+            "Drawer.js",
+            "EmptyView.js",
+            "FilterBar.js",
+            "GoToLineDialog.js",
+            "HelpScreen.js",
+            "InspectorView.js",
+            "KeyboardShortcut.js",
+            "OverviewGrid.js",
+            "Panel.js",
+            "Placard.js",
+            "Popover.js",
+            "ProgressIndicator.js",
+            "PropertiesSection.js",
+            "SearchableView.js",
+            "Section.js",
+            "SidebarPane.js",
+            "SidebarTreeElement.js",
+            "ShortcutsScreen.js",
+            "ShowMoreDataGridNode.js",
+            "SidebarOverlay.js",
+            "SoftContextMenu.js",
+            "Spectrum.js",
+            "SplitView.js",
+            "SidebarView.js",
+            "StatusBarButton.js",
+            "SuggestBox.js",
+            "TabbedPane.js",
+            "TextEditor.js",
+            "TextPrompt.js",
+            "TextUtils.js",
+            "TimelineGrid.js",
+            "UIUtils.js",
+            "View.js",
+            "ViewportControl.js",
+            "treeoutline.js"
+        ]
+    },
+    {
+        "name": "components",
+        "dependencies": ["sdk", "ui"],
+        "sources": [
+            "AdvancedSearchController.js",
+            "HandlerRegistry.js",
+            "ConsoleMessage.js",
+            "CookiesTable.js",
+            "DOMBreakpointsSidebarPane.js",
+            "DOMPresentationUtils.js",
+            "ElementsTreeOutline.js",
+            "FontView.js",
+            "ImageView.js",
+            "NativeBreakpointsSidebarPane.js",
+            "InspectElementModeController.js",
+            "ObjectPopoverHelper.js",
+            "ObjectPropertiesSection.js",
+            "ScreencastView.js",
+            "SourceFrame.js",
+            "ResourceView.js"
+        ]
+    },
+    {
+        "name": "elements",
+        "dependencies": ["components"],
+        "sources": [
+            "CSSNamedFlowCollectionsView.js",
+            "CSSNamedFlowView.js",
+            "ElementsPanel.js",
+            "ElementsPanelDescriptor.js",
+            "EventListenersSidebarPane.js",
+            "MetricsSidebarPane.js",
+            "OverridesView.js",
+            "PlatformFontsSidebarPane.js",
+            "PropertiesSidebarPane.js",
+            "StylesSidebarPane.js",
+            "RenderingOptionsView.js"
+        ]
+    },
+    {
+        "name": "network",
+        "dependencies": ["components"],
+        "sources": [
+            "NetworkItemView.js",
+            "RequestCookiesView.js",
+            "RequestHeadersView.js",
+            "RequestHTMLView.js",
+            "RequestJSONView.js",
+            "RequestPreviewView.js",
+            "RequestResponseView.js",
+            "RequestTimingView.js",
+            "RequestView.js",
+            "ResourceWebSocketFrameView.js",
+            "NetworkPanel.js",
+            "NetworkPanelDescriptor.js"
+        ]
+    },
+    {
+        "name": "resources",
+        "dependencies": ["components"],
+        "sources": [
+            "ApplicationCacheItemsView.js",
+            "CookieItemsView.js",
+            "DatabaseQueryView.js",
+            "DatabaseTableView.js",
+            "DirectoryContentView.js",
+            "DOMStorageItemsView.js",
+            "FileContentView.js",
+            "FileSystemView.js",
+            "IndexedDBViews.js",
+            "ResourcesPanel.js"
+        ]
+    },
+    {
+        "name": "workers",
+        "dependencies": ["components"],
+        "sources": [
+            "WorkerManager.js"
+        ]
+    },
+    {
+        "name": "scripts",
+        "dependencies": ["components", "workers"],
+        "sources": [
+            "BreakpointsSidebarPane.js",
+            "CSSSourceFrame.js",
+            "CallStackSidebarPane.js",
+            "FilePathScoreFunction.js",
+            "FilteredItemSelectionDialog.js",
+            "JavaScriptSourceFrame.js",
+            "NavigatorOverlayController.js",
+            "NavigatorView.js",
+            "RevisionHistoryView.js",
+            "ScopeChainSidebarPane.js",
+            "SourcesNavigator.js",
+            "SourcesPanel.js",
+            "SourcesPanelDescriptor.js",
+            "SourcesSearchScope.js",
+            "StyleSheetOutlineDialog.js",
+            "TabbedEditorContainer.js",
+            "UISourceCodeFrame.js",
+            "WatchExpressionsSidebarPane.js",
+            "WorkersSidebarPane.js"
+        ]
+    },
+    {
+        "name": "console",
+        "dependencies": ["components"],
+        "sources": [
+            "ConsoleView.js",
+            "ConsolePanel.js"
+        ]
+    },
+    {
+        "name": "timeline",
+        "dependencies": ["components"],
+        "sources": [
+            "DOMCountersGraph.js",
+            "MemoryStatistics.js",
+            "PieChart.js",
+            "TimelineEventOverview.js",
+            "TimelineFrameOverview.js",
+            "TimelineMemoryOverview.js",
+            "TimelineModel.js",
+            "TimelineOverviewPane.js",
+            "TimelinePanel.js",
+            "TimelinePanelDescriptor.js",
+            "TimelinePresentationModel.js",
+            "TimelineFrameController.js"
+        ]
+    },
+    {
+        "name": "audits",
+        "dependencies": ["components"],
+        "sources": [
+            "AuditCategories.js",
+            "AuditController.js",
+            "AuditFormatters.js",
+            "AuditLauncherView.js",
+            "AuditResultView.js",
+            "AuditRules.js",
+            "AuditsPanel.js"
+        ]
+    },
+    {
+        "name": "codemirror",
+        "dependencies": ["components"],
+        "sources": [
+            "CodeMirrorTextEditor.js",
+            "CodeMirrorUtils.js"
+        ]
+    },
+    {
+        "name": "layers",
+        "dependencies": ["components"],
+        "sources": [
+            "LayerTreeModel.js",
+            "LayersPanel.js",
+            "LayersPanelDescriptor.js",
+            "LayerTree.js",
+            "Layers3DView.js",
+            "LayerDetailsView.js",
+            "PaintProfilerView.js"
+        ]
+    },
+    {
+        "name": "extensions",
+        "dependencies": ["components"],
+        "sources": [
+            "ExtensionAPI.js",
+            "ExtensionAuditCategory.js",
+            "ExtensionPanel.js",
+            "ExtensionRegistryStub.js",
+            "ExtensionServer.js",
+            "ExtensionView.js"
+        ]
+    },
+    {
+        "name": "settings",
+        "dependencies": ["components", "extensions"],
+        "sources": [
+            "SettingsScreen.js",
+            "EditFileSystemDialog.js"
+        ]
+    },
+    {
+        "name": "tests",
+        "dependencies": ["components"],
+        "sources": [
+            "TestController.js"
+        ]
+    },
+    {
+        "name": "profiler",
+        "dependencies": ["components", "workers"],
+        "sources": [
+            "AllocationProfile.js",
+            "BottomUpProfileDataGridTree.js",
+            "CPUProfileView.js",
+            "FlameChart.js",
+            "HeapSnapshot.js",
+            "HeapSnapshotDataGrids.js",
+            "HeapSnapshotGridNodes.js",
+            "HeapSnapshotLoader.js",
+            "HeapSnapshotProxy.js",
+            "HeapSnapshotView.js",
+            "HeapSnapshotWorker.js",
+            "HeapSnapshotWorkerDispatcher.js",
+            "JSHeapSnapshot.js",
+            "ProfileDataGridTree.js",
+            "ProfilesPanel.js",
+            "ProfilesPanelDescriptor.js",
+            "ProfileLauncherView.js",
+            "TopDownProfileDataGridTree.js",
+            "CanvasProfileView.js",
+            "CanvasReplayStateView.js"
+        ]
+    },
+    {
+        "name": "host_stub",
+        "dependencies": ["components", "profiler", "timeline"],
+        "sources": [
+            "InspectorFrontendAPI.js",
+            "InspectorFrontendHostStub.js"
+        ]
+    }
+]