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

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

Issue 2300403003: DevTools: patch browser's Chrome version into Chrome user agents for emulation (Closed)
Patch Set: common > sdk, address comments Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/network/NetworkConfigView.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 /** @type {!WebInspector.NetworkManager.Conditions} */ 692 /** @type {!WebInspector.NetworkManager.Conditions} */
693 this._networkConditions = WebInspector.NetworkManager.NoThrottlingConditions ; 693 this._networkConditions = WebInspector.NetworkManager.NoThrottlingConditions ;
694 } 694 }
695 695
696 /** @enum {symbol} */ 696 /** @enum {symbol} */
697 WebInspector.MultitargetNetworkManager.Events = { 697 WebInspector.MultitargetNetworkManager.Events = {
698 ConditionsChanged: Symbol("ConditionsChanged"), 698 ConditionsChanged: Symbol("ConditionsChanged"),
699 UserAgentChanged: Symbol("UserAgentChanged") 699 UserAgentChanged: Symbol("UserAgentChanged")
700 } 700 }
701 701
702 /**
703 * @param {string} uaString
704 * @return {string}
705 */
706 WebInspector.MultitargetNetworkManager.patchUserAgentWithChromeVersion = functio n(uaString)
707 {
708 // Patches Chrome/CriOS version from user agent ("1.2.3.4" when user agent i s: "Chrome/1.2.3.4").
709 var chromeRegex = new RegExp("((?:^|\\W)Chrome/)(\\S+)");
pfeldman 2016/09/19 23:42:47 So you want Opera here as well? Or array of "Chrom
710 var criosRegex = new RegExp("((?:^|\\W)CriOS/)(\\S+)");
711 var chromeMatch = navigator.userAgent.match(chromeRegex);
712 if (chromeMatch && chromeMatch.length > 2)
713 return uaString.replace(chromeRegex, "$1" + chromeMatch[2]).replace(crio sRegex, "$1" + chromeMatch[2]);
714 return uaString;
715 }
716
702 WebInspector.MultitargetNetworkManager.prototype = { 717 WebInspector.MultitargetNetworkManager.prototype = {
703 /** 718 /**
704 * @override 719 * @override
705 * @param {!WebInspector.Target} target 720 * @param {!WebInspector.Target} target
706 */ 721 */
707 targetAdded: function(target) 722 targetAdded: function(target)
708 { 723 {
709 var networkAgent = target.networkAgent(); 724 var networkAgent = target.networkAgent();
710 if (this._extraHeaders) 725 if (this._extraHeaders)
711 networkAgent.setExtraHTTPHeaders(this._extraHeaders); 726 networkAgent.setExtraHTTPHeaders(this._extraHeaders);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 WebInspector.ResourceLoader.load(url, headers, callback); 928 WebInspector.ResourceLoader.load(url, headers, callback);
914 }, 929 },
915 930
916 __proto__: WebInspector.Object.prototype 931 __proto__: WebInspector.Object.prototype
917 } 932 }
918 933
919 /** 934 /**
920 * @type {!WebInspector.MultitargetNetworkManager} 935 * @type {!WebInspector.MultitargetNetworkManager}
921 */ 936 */
922 WebInspector.multitargetNetworkManager; 937 WebInspector.multitargetNetworkManager;
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/network/NetworkConfigView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698