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

Side by Side Diff: Source/devtools/front_end/main/Main.js

Issue 1105643002: Devtools: Introduce WI.ExtensibleToolbar (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 WebInspector.Main.prototype = { 43 WebInspector.Main.prototype = {
44 /** 44 /**
45 * @override 45 * @override
46 * @return {!Promise.<undefined>} 46 * @return {!Promise.<undefined>}
47 */ 47 */
48 showConsole: function() 48 showConsole: function()
49 { 49 {
50 return WebInspector.Revealer.revealPromise(WebInspector.console); 50 return WebInspector.Revealer.revealPromise(WebInspector.console);
51 }, 51 },
52 52
53 _createGlobalToolbarItems: function()
54 {
55 var extensions = self.runtime.extensions(WebInspector.ToolbarItem.Provid er);
56 var promises = [];
57 for (var i = 0; i < extensions.length; ++i)
58 promises.push(resolveItem(extensions[i]));
59 Promise.all(promises).then(appendItemsInOrder);
60
61 /**
62 * @param {!Runtime.Extension} extension
63 * @return {!Promise.<?WebInspector.ToolbarItem>}
64 */
65 function resolveItem(extension)
66 {
67 var descriptor = extension.descriptor();
68 if (!descriptor.className)
69 return Promise.resolve(new WebInspector.ToolbarButton(WebInspect or.UIString(descriptor["title"]), descriptor["elementClass"])).then(attachHandle r);
70 return extension.instancePromise().then(fetchItemFromProvider).then( attachHandler);
71
72 /**
73 * @param {!Object} provider
74 */
75 function fetchItemFromProvider(provider)
76 {
77 return /** @type {!WebInspector.ToolbarItem.Provider} */ (provid er).item();
78 }
79
80 /**
81 * @param {?WebInspector.ToolbarItem} item
82 * @return {?WebInspector.ToolbarItem} item
83 */
84 function attachHandler(item)
85 {
86 if (extension.descriptor()["actionId"] && item)
87 item.addEventListener("click", handler);
88 return item;
89 }
90
91 function handler()
92 {
93 WebInspector.actionRegistry.execute(extension.descriptor()["acti onId"]);
94 }
95 }
96
97 /**
98 * @param {!Array.<?WebInspector.ToolbarItem>} items
99 */
100 function appendItemsInOrder(items)
101 {
102 for (var i = 0; i < items.length; ++i) {
103 var item = items[i];
104 if (!item)
105 continue;
106 if (extensions[i].descriptor()["location"] === "toolbar-left")
107 WebInspector.inspectorView.appendToLeftToolbar(item);
108 else if (extensions[i].descriptor()["location"] === "toolbar-rig ht")
109 WebInspector.inspectorView.appendToRightToolbar(item);
110 }
111 }
112 },
113
114 _loaded: function() 53 _loaded: function()
115 { 54 {
116 console.timeStamp("Main._loaded"); 55 console.timeStamp("Main._loaded");
117 56
118 if (InspectorFrontendHost.isUnderTest()) 57 if (InspectorFrontendHost.isUnderTest())
119 self.runtime.useTestBase(); 58 self.runtime.useTestBase();
120 InspectorFrontendHost.getPreferences(this._createSettings.bind(this)); 59 InspectorFrontendHost.getPreferences(this._createSettings.bind(this));
121 }, 60 },
122 61
123 /** 62 /**
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 _showAppUI: function(appProvider) 248 _showAppUI: function(appProvider)
310 { 249 {
311 var app = /** @type {!WebInspector.AppProvider} */ (appProvider).createA pp(); 250 var app = /** @type {!WebInspector.AppProvider} */ (appProvider).createA pp();
312 // It is important to kick controller lifetime after apps are instantiat ed. 251 // It is important to kick controller lifetime after apps are instantiat ed.
313 WebInspector.dockController.initialize(); 252 WebInspector.dockController.initialize();
314 console.timeStamp("Main._presentUI"); 253 console.timeStamp("Main._presentUI");
315 app.presentUI(document); 254 app.presentUI(document);
316 255
317 if (!Runtime.queryParam("isSharedWorker")) 256 if (!Runtime.queryParam("isSharedWorker"))
318 WebInspector.inspectElementModeController = new WebInspector.Inspect ElementModeController(); 257 WebInspector.inspectElementModeController = new WebInspector.Inspect ElementModeController();
319 this._createGlobalToolbarItems(); 258 WebInspector.inspectorView.createToolbars();
320
321 InspectorFrontendHost.loadCompleted(); 259 InspectorFrontendHost.loadCompleted();
322 260
323 var extensions = self.runtime.extensions(WebInspector.QueryParamHandler) ; 261 var extensions = self.runtime.extensions(WebInspector.QueryParamHandler) ;
324 for (var extension of extensions) { 262 for (var extension of extensions) {
325 var value = Runtime.queryParam(extension.descriptor()["name"]); 263 var value = Runtime.queryParam(extension.descriptor()["name"]);
326 if (value !== null) 264 if (value !== null)
327 extension.instancePromise().then(handleQueryParam.bind(null, val ue)); 265 extension.instancePromise().then(handleQueryParam.bind(null, val ue));
328 } 266 }
329 // Give UI cycles to repaint, then proceed with creating connection. 267 // Give UI cycles to repaint, then proceed with creating connection.
330 setTimeout(this._createConnection.bind(this), 0); 268 setTimeout(this._createConnection.bind(this), 0);
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 p.classList.add("help-section"); 835 p.classList.add("help-section");
898 p.textContent = WebInspector.UIString("Inspected worker has terminated. Once it restarts we will attach to it automatically."); 836 p.textContent = WebInspector.UIString("Inspected worker has terminated. Once it restarts we will attach to it automatically.");
899 } 837 }
900 838
901 WebInspector.WorkerTerminatedScreen.prototype = { 839 WebInspector.WorkerTerminatedScreen.prototype = {
902 840
903 __proto__: WebInspector.HelpScreen.prototype 841 __proto__: WebInspector.HelpScreen.prototype
904 } 842 }
905 843
906 new WebInspector.Main(); 844 new WebInspector.Main();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698