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

Side by Side Diff: Source/devtools/front_end/sdk/NetworkManager.js

Issue 1295903005: [DevTools] Implementation of resource requests blocked by specific urls. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 */ 623 */
624 _createNetworkRequest: function(requestId, frameId, loaderId, url, documentU RL, initiator) 624 _createNetworkRequest: function(requestId, frameId, loaderId, url, documentU RL, initiator)
625 { 625 {
626 return new WebInspector.NetworkRequest(this._manager._target, requestId, url, documentURL, frameId, loaderId, initiator); 626 return new WebInspector.NetworkRequest(this._manager._target, requestId, url, documentURL, frameId, loaderId, initiator);
627 } 627 }
628 } 628 }
629 629
630 630
631 /** 631 /**
632 * @constructor 632 * @constructor
633 * @extends {WebInspector.Object}
633 * @implements {WebInspector.TargetManager.Observer} 634 * @implements {WebInspector.TargetManager.Observer}
634 */ 635 */
635 WebInspector.MultitargetNetworkManager = function() 636 WebInspector.MultitargetNetworkManager = function()
636 { 637 {
638 WebInspector.Object.call(this);
637 WebInspector.targetManager.observeTargets(this); 639 WebInspector.targetManager.observeTargets(this);
640
641 /** @type {!Set<string>} */
642 this._blockedURLs = new Set();
643 }
644
645 WebInspector.MultitargetNetworkManager.EventTypes = {
646 BlockedURLsChanged: "BlockedURLsChanged"
638 } 647 }
639 648
640 WebInspector.MultitargetNetworkManager.prototype = { 649 WebInspector.MultitargetNetworkManager.prototype = {
641 /** 650 /**
642 * @override 651 * @override
643 * @param {!WebInspector.Target} target 652 * @param {!WebInspector.Target} target
644 */ 653 */
645 targetAdded: function(target) 654 targetAdded: function(target)
646 { 655 {
647 var networkAgent = target.networkAgent(); 656 var networkAgent = target.networkAgent();
648 if (this._extraHeaders) 657 if (this._extraHeaders)
649 networkAgent.setExtraHTTPHeaders(this._extraHeaders); 658 networkAgent.setExtraHTTPHeaders(this._extraHeaders);
650 if (typeof this._userAgent !== "undefined") 659 if (typeof this._userAgent !== "undefined")
651 networkAgent.setUserAgentOverride(this._userAgent); 660 networkAgent.setUserAgentOverride(this._userAgent);
661 for (var url of this._blockedURLs)
662 networkAgent.addBlockedURL(url);
652 }, 663 },
653 664
654 /** 665 /**
655 * @override 666 * @override
656 * @param {!WebInspector.Target} target 667 * @param {!WebInspector.Target} target
657 */ 668 */
658 targetRemoved: function(target) 669 targetRemoved: function(target)
659 { 670 {
660 }, 671 },
661 672
662 /** 673 /**
663 * @param {!NetworkAgent.Headers} headers 674 * @param {!NetworkAgent.Headers} headers
664 */ 675 */
665 setExtraHTTPHeaders: function(headers) 676 setExtraHTTPHeaders: function(headers)
666 { 677 {
667 this._extraHeaders = headers; 678 this._extraHeaders = headers;
668 for (var target of WebInspector.targetManager.targets()) 679 for (var target of WebInspector.targetManager.targets())
669 target.networkAgent().setExtraHTTPHeaders(this._extraHeaders); 680 target.networkAgent().setExtraHTTPHeaders(this._extraHeaders);
670 }, 681 },
671 682
672 /** 683 /**
673 * @param {string} userAgent 684 * @param {string} userAgent
674 */ 685 */
675 setUserAgentOverride: function(userAgent) 686 setUserAgentOverride: function(userAgent)
676 { 687 {
677 WebInspector.ResourceLoader.targetUserAgent = userAgent; 688 WebInspector.ResourceLoader.targetUserAgent = userAgent;
678 this._userAgent = userAgent; 689 this._userAgent = userAgent;
679 for (var target of WebInspector.targetManager.targets()) 690 for (var target of WebInspector.targetManager.targets())
680 target.networkAgent().setUserAgentOverride(this._userAgent); 691 target.networkAgent().setUserAgentOverride(this._userAgent);
681 } 692 },
693
694 /**
695 * @param {string} url
696 */
697 toggleURLBlocked: function(url)
698 {
699 if (this._blockedURLs.has(url)) {
700 this._blockedURLs.delete(url);
701 for (var target of WebInspector.targetManager.targets())
702 target.networkAgent().removeBlockedURL(url);
703 } else {
704 this._blockedURLs.add(url);
705 for (var target of WebInspector.targetManager.targets())
706 target.networkAgent().addBlockedURL(url);
707 }
708 this.dispatchEventToListeners(WebInspector.MultitargetNetworkManager.Eve ntTypes.BlockedURLsChanged);
709 },
710
711 /**
712 * @return {!Set<string>}
713 */
714 blockedURLs: function()
715 {
716 return this._blockedURLs;
717 },
718
719 __proto__: WebInspector.Object.prototype
682 } 720 }
683 721
684 /** 722 /**
685 * @type {!WebInspector.MultitargetNetworkManager} 723 * @type {!WebInspector.MultitargetNetworkManager}
686 */ 724 */
687 WebInspector.multitargetNetworkManager; 725 WebInspector.multitargetNetworkManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698