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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/host/InspectorFrontendHost.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 /** 30 /**
31 * @implements {InspectorFrontendHostAPI} 31 * @implements {InspectorFrontendHostAPI}
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.InspectorFrontendHostStub = class { 34 Host.InspectorFrontendHostStub = class {
35 /** 35 /**
36 * @suppressGlobalPropertiesCheck 36 * @suppressGlobalPropertiesCheck
37 */ 37 */
38 constructor() { 38 constructor() {
39 /** 39 /**
40 * @param {!Event} event 40 * @param {!Event} event
41 */ 41 */
42 function stopEventPropagation(event) { 42 function stopEventPropagation(event) {
43 // Let browser handle Ctrl+/Ctrl- shortcuts in hosted mode. 43 // Let browser handle Ctrl+/Ctrl- shortcuts in hosted mode.
44 var zoomModifier = WebInspector.isMac() ? event.metaKey : event.ctrlKey; 44 var zoomModifier = Host.isMac() ? event.metaKey : event.ctrlKey;
45 if (zoomModifier && (event.keyCode === 187 || event.keyCode === 189)) 45 if (zoomModifier && (event.keyCode === 187 || event.keyCode === 189))
46 event.stopPropagation(); 46 event.stopPropagation();
47 } 47 }
48 document.addEventListener('keydown', stopEventPropagation, true); 48 document.addEventListener('keydown', stopEventPropagation, true);
49 } 49 }
50 50
51 /** 51 /**
52 * @override 52 * @override
53 * @return {string} 53 * @return {string}
54 */ 54 */
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 */ 128 */
129 setInjectedScriptForOrigin(origin, script) { 129 setInjectedScriptForOrigin(origin, script) {
130 } 130 }
131 131
132 /** 132 /**
133 * @override 133 * @override
134 * @param {string} url 134 * @param {string} url
135 * @suppressGlobalPropertiesCheck 135 * @suppressGlobalPropertiesCheck
136 */ 136 */
137 inspectedURLChanged(url) { 137 inspectedURLChanged(url) {
138 document.title = WebInspector.UIString('Developer Tools - %s', url); 138 document.title = Common.UIString('Developer Tools - %s', url);
139 } 139 }
140 140
141 /** 141 /**
142 * @override 142 * @override
143 * @param {string} text 143 * @param {string} text
144 */ 144 */
145 copyText(text) { 145 copyText(text) {
146 WebInspector.console.error('Clipboard is not enabled in hosted mode. Please inspect using chrome://inspect'); 146 Common.console.error('Clipboard is not enabled in hosted mode. Please inspec t using chrome://inspect');
147 } 147 }
148 148
149 /** 149 /**
150 * @override 150 * @override
151 * @param {string} url 151 * @param {string} url
152 */ 152 */
153 openInNewTab(url) { 153 openInNewTab(url) {
154 window.open(url, '_blank'); 154 window.open(url, '_blank');
155 } 155 }
156 156
157 /** 157 /**
158 * @override 158 * @override
159 * @param {string} url 159 * @param {string} url
160 * @param {string} content 160 * @param {string} content
161 * @param {boolean} forceSaveAs 161 * @param {boolean} forceSaveAs
162 */ 162 */
163 save(url, content, forceSaveAs) { 163 save(url, content, forceSaveAs) {
164 WebInspector.console.error('Saving files is not enabled in hosted mode. Plea se inspect using chrome://inspect'); 164 Common.console.error('Saving files is not enabled in hosted mode. Please ins pect using chrome://inspect');
165 this.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.Cancele dSaveURL, url); 165 this.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.Cancele dSaveURL, url);
166 } 166 }
167 167
168 /** 168 /**
169 * @override 169 * @override
170 * @param {string} url 170 * @param {string} url
171 * @param {string} content 171 * @param {string} content
172 */ 172 */
173 append(url, content) { 173 append(url, content) {
174 WebInspector.console.error('Saving files is not enabled in hosted mode. Plea se inspect using chrome://inspect'); 174 Common.console.error('Saving files is not enabled in hosted mode. Please ins pect using chrome://inspect');
175 } 175 }
176 176
177 /** 177 /**
178 * @override 178 * @override
179 * @param {string} message 179 * @param {string} message
180 */ 180 */
181 sendMessageToBackend(message) { 181 sendMessageToBackend(message) {
182 } 182 }
183 183
184 /** 184 /**
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 /** 224 /**
225 * @override 225 * @override
226 * @param {string} url 226 * @param {string} url
227 * @param {string} headers 227 * @param {string} headers
228 * @param {number} streamId 228 * @param {number} streamId
229 * @param {function(!InspectorFrontendHostAPI.LoadNetworkResourceResult)} call back 229 * @param {function(!InspectorFrontendHostAPI.LoadNetworkResourceResult)} call back
230 */ 230 */
231 loadNetworkResource(url, headers, streamId, callback) { 231 loadNetworkResource(url, headers, streamId, callback) {
232 Runtime.loadResourcePromise(url) 232 Runtime.loadResourcePromise(url)
233 .then(function(text) { 233 .then(function(text) {
234 WebInspector.ResourceLoader.streamWrite(streamId, text); 234 Host.ResourceLoader.streamWrite(streamId, text);
235 callback({statusCode: 200}); 235 callback({statusCode: 200});
236 }) 236 })
237 .catch(function() { 237 .catch(function() {
238 callback({statusCode: 404}); 238 callback({statusCode: 404});
239 }); 239 });
240 } 240 }
241 241
242 /** 242 /**
243 * @override 243 * @override
244 * @param {function(!Object<string, string>)} callback 244 * @param {function(!Object<string, string>)} callback
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 console.error(e + ' ' + e.stack); 463 console.error(e + ' ' + e.stack);
464 } 464 }
465 } 465 }
466 } 466 }
467 467
468 /** 468 /**
469 * @param {number} id 469 * @param {number} id
470 * @param {string} chunk 470 * @param {string} chunk
471 */ 471 */
472 streamWrite(id, chunk) { 472 streamWrite(id, chunk) {
473 WebInspector.ResourceLoader.streamWrite(id, chunk); 473 Host.ResourceLoader.streamWrite(id, chunk);
474 } 474 }
475 }; 475 };
476 476
477 /** 477 /**
478 * @type {!InspectorFrontendHostAPI} 478 * @type {!InspectorFrontendHostAPI}
479 */ 479 */
480 var InspectorFrontendHost = window.InspectorFrontendHost || null; 480 var InspectorFrontendHost = window.InspectorFrontendHost || null;
481 window.InspectorFrontendHost = InspectorFrontendHost; 481 window.InspectorFrontendHost = InspectorFrontendHost;
482 (function() { 482 (function() {
483 483
484 function initializeInspectorFrontendHost() { 484 function initializeInspectorFrontendHost() {
485 if (!InspectorFrontendHost) { 485 if (!InspectorFrontendHost) {
486 // Instantiate stub for web-hosted mode if necessary. 486 // Instantiate stub for web-hosted mode if necessary.
487 window.InspectorFrontendHost = InspectorFrontendHost = new WebInspector.In spectorFrontendHostStub(); 487 window.InspectorFrontendHost = InspectorFrontendHost = new Host.InspectorF rontendHostStub();
488 } else { 488 } else {
489 // Otherwise add stubs for missing methods that are declared in the interf ace. 489 // Otherwise add stubs for missing methods that are declared in the interf ace.
490 var proto = WebInspector.InspectorFrontendHostStub.prototype; 490 var proto = Host.InspectorFrontendHostStub.prototype;
491 for (var name in proto) { 491 for (var name in proto) {
492 var value = proto[name]; 492 var value = proto[name];
493 if (typeof value !== 'function' || InspectorFrontendHost[name]) 493 if (typeof value !== 'function' || InspectorFrontendHost[name])
494 continue; 494 continue;
495 495
496 InspectorFrontendHost[name] = stub.bind(null, name); 496 InspectorFrontendHost[name] = stub.bind(null, name);
497 } 497 }
498 } 498 }
499 499
500 /** 500 /**
501 * @param {string} name 501 * @param {string} name
502 * @return {?} 502 * @return {?}
503 */ 503 */
504 function stub(name) { 504 function stub(name) {
505 console.error('Incompatible embedder: method InspectorFrontendHost.' + nam e + ' is missing. Using stub instead.'); 505 console.error('Incompatible embedder: method InspectorFrontendHost.' + nam e + ' is missing. Using stub instead.');
506 var args = Array.prototype.slice.call(arguments, 1); 506 var args = Array.prototype.slice.call(arguments, 1);
507 return proto[name].apply(InspectorFrontendHost, args); 507 return proto[name].apply(InspectorFrontendHost, args);
508 } 508 }
509 509
510 // Attach the events object. 510 // Attach the events object.
511 InspectorFrontendHost.events = new WebInspector.Object(); 511 InspectorFrontendHost.events = new Common.Object();
512 } 512 }
513 513
514 // FIXME: This file is included into both apps, since the devtools_app needs t he InspectorFrontendHostAPI only, 514 // FIXME: This file is included into both apps, since the devtools_app needs t he InspectorFrontendHostAPI only,
515 // so the host instance should not initialized there. 515 // so the host instance should not initialized there.
516 initializeInspectorFrontendHost(); 516 initializeInspectorFrontendHost();
517 window.InspectorFrontendAPI = new InspectorFrontendAPIImpl(); 517 window.InspectorFrontendAPI = new InspectorFrontendAPIImpl();
518 WebInspector.setLocalizationPlatform(InspectorFrontendHost.platform()); 518 Common.setLocalizationPlatform(InspectorFrontendHost.platform());
519 })(); 519 })();
520 520
521 /** 521 /**
522 * @type {!WebInspector.EventTarget} 522 * @type {!Common.EventTarget}
523 */ 523 */
524 InspectorFrontendHost.events; 524 InspectorFrontendHost.events;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698