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

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: Move close button out of toolbar 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 _showAppUI: function(appProvider) 245 _showAppUI: function(appProvider)
307 { 246 {
308 var app = /** @type {!WebInspector.AppProvider} */ (appProvider).createA pp(); 247 var app = /** @type {!WebInspector.AppProvider} */ (appProvider).createA pp();
309 // It is important to kick controller lifetime after apps are instantiat ed. 248 // It is important to kick controller lifetime after apps are instantiat ed.
310 WebInspector.dockController.initialize(); 249 WebInspector.dockController.initialize();
311 console.timeStamp("Main._presentUI"); 250 console.timeStamp("Main._presentUI");
312 app.presentUI(document); 251 app.presentUI(document);
313 252
314 if (!Runtime.queryParam("isSharedWorker")) 253 if (!Runtime.queryParam("isSharedWorker"))
315 WebInspector.inspectElementModeController = new WebInspector.Inspect ElementModeController(); 254 WebInspector.inspectElementModeController = new WebInspector.Inspect ElementModeController();
316 this._createGlobalToolbarItems(); 255 WebInspector.inspectorView.createToolbars();
317
318 InspectorFrontendHost.loadCompleted(); 256 InspectorFrontendHost.loadCompleted();
319 257
320 var extensions = self.runtime.extensions(WebInspector.QueryParamHandler) ; 258 var extensions = self.runtime.extensions(WebInspector.QueryParamHandler) ;
321 for (var extension of extensions) { 259 for (var extension of extensions) {
322 var value = Runtime.queryParam(extension.descriptor()["name"]); 260 var value = Runtime.queryParam(extension.descriptor()["name"]);
323 if (value !== null) 261 if (value !== null)
324 extension.instancePromise().then(handleQueryParam.bind(null, val ue)); 262 extension.instancePromise().then(handleQueryParam.bind(null, val ue));
325 } 263 }
326 // Give UI cycles to repaint, then proceed with creating connection. 264 // Give UI cycles to repaint, then proceed with creating connection.
327 setTimeout(this._createConnection.bind(this), 0); 265 setTimeout(this._createConnection.bind(this), 0);
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 p.classList.add("help-section"); 824 p.classList.add("help-section");
887 p.textContent = WebInspector.UIString("Inspected worker has terminated. Once it restarts we will attach to it automatically."); 825 p.textContent = WebInspector.UIString("Inspected worker has terminated. Once it restarts we will attach to it automatically.");
888 } 826 }
889 827
890 WebInspector.WorkerTerminatedScreen.prototype = { 828 WebInspector.WorkerTerminatedScreen.prototype = {
891 829
892 __proto__: WebInspector.HelpScreen.prototype 830 __proto__: WebInspector.HelpScreen.prototype
893 } 831 }
894 832
895 new WebInspector.Main(); 833 new WebInspector.Main();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698