diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 0b92b90bb4..ba68917741 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -1174,7 +1174,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-dark-console' => array( - 'uri' => '/res/ae7f15ce/rsrc/js/application/core/behavior-dark-console.js', + 'uri' => '/res/89aeb6c0/rsrc/js/application/core/behavior-dark-console.js', 'type' => 'js', 'requires' => array( @@ -3488,7 +3488,7 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/bc0774e5/core.pkg.js', 'type' => 'js', ), - '3e0098ea' => + 'dca4a03d' => array( 'name' => 'darkconsole.pkg.js', 'symbols' => @@ -3496,7 +3496,7 @@ celerity_register_resource_map(array( 0 => 'javelin-behavior-dark-console', 1 => 'javelin-behavior-error-log', ), - 'uri' => '/res/pkg/3e0098ea/darkconsole.pkg.js', + 'uri' => '/res/pkg/dca4a03d/darkconsole.pkg.js', 'type' => 'js', ), '8aaacd1b' => @@ -3666,7 +3666,7 @@ celerity_register_resource_map(array( 'javelin-behavior-aphront-drag-and-drop-textarea' => '95d0d865', 'javelin-behavior-aphront-form-disable-on-submit' => 'bc0774e5', 'javelin-behavior-audit-preview' => 'f96657b8', - 'javelin-behavior-dark-console' => '3e0098ea', + 'javelin-behavior-dark-console' => 'dca4a03d', 'javelin-behavior-device' => 'bc0774e5', 'javelin-behavior-differential-accept-with-errors' => '95d0d865', 'javelin-behavior-differential-add-reviewers-and-ccs' => '95d0d865', @@ -3682,7 +3682,7 @@ celerity_register_resource_map(array( 'javelin-behavior-differential-user-select' => '95d0d865', 'javelin-behavior-diffusion-commit-graph' => 'f96657b8', 'javelin-behavior-diffusion-pull-lastmodified' => 'f96657b8', - 'javelin-behavior-error-log' => '3e0098ea', + 'javelin-behavior-error-log' => 'dca4a03d', 'javelin-behavior-global-drag-and-drop' => 'bc0774e5', 'javelin-behavior-konami' => 'bc0774e5', 'javelin-behavior-lightbox-attachments' => 'bc0774e5', diff --git a/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php b/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php index 3452e675d0..2eadc39068 100644 --- a/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php +++ b/src/aphront/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php @@ -13,11 +13,23 @@ final class DarkConsoleXHProfPluginAPI { return extension_loaded('xhprof'); } + public static function getProfilerHeader() { + return 'X-Phabricator-Profiler'; + } + public static function isProfilerRequested() { if (!empty($_REQUEST['__profile__'])) { return $_REQUEST['__profile__']; } + $header = self::getProfilerHeader(); + $header = strtoupper($header); + $header = str_replace('-', '_', $header); + $header = 'HTTP_'.$header; + if (!empty($_SERVER[$header])) { + return $_SERVER[$header]; + } + static $profilerRequested = null; if (!isset($profilerRequested)) { diff --git a/src/infrastructure/celerity/CelerityStaticResourceResponse.php b/src/infrastructure/celerity/CelerityStaticResourceResponse.php index 6891fa4fff..7fbfd809ca 100644 --- a/src/infrastructure/celerity/CelerityStaticResourceResponse.php +++ b/src/infrastructure/celerity/CelerityStaticResourceResponse.php @@ -147,6 +147,7 @@ final class CelerityStaticResourceResponse { $higher_priority_names = array( 'refresh-csrf', 'aphront-basic-tokenizer', + 'dark-console', ); $higher_priority_behaviors = array_select_keys( diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php index d692411ca2..b0ec7a1642 100644 --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -161,12 +161,19 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { if ($console) { require_celerity_resource('aphront-dark-console-css'); + + $headers = array(); + if (DarkConsoleXHProfPluginAPI::isProfilerRequested()) { + $headers[DarkConsoleXHProfPluginAPI::getProfilerHeader()] = 'page'; + } + Javelin::initBehavior( 'dark-console', array( 'uri' => $request ? (string)$request->getRequestURI() : '?', 'selected' => $user ? $user->getConsoleTab() : null, 'visible' => $user ? (int)$user->getConsoleVisible() : true, + 'headers' => $headers, )); // Change this to initBehavior when there is some behavior to initialize diff --git a/webroot/rsrc/js/application/core/behavior-dark-console.js b/webroot/rsrc/js/application/core/behavior-dark-console.js index 50a3471997..75515bd0e6 100644 --- a/webroot/rsrc/js/application/core/behavior-dark-console.js +++ b/webroot/rsrc/js/application/core/behavior-dark-console.js @@ -14,7 +14,6 @@ JX.behavior('dark-console', function(config, statics) { config.key = config.key || root.getAttribute('data-console-key'); add_request(config); - // Do first-time setup. function setup_console() { statics.root = JX.$('darkconsole'); @@ -42,6 +41,16 @@ JX.behavior('dark-console', function(config, statics) { install_shortcut(); + if (config.headers) { + // If the main page had profiling enabled, also enable it for any Ajax + // requests. + JX.Request.listen('open', function(r) { + for (var k in config.headers) { + r.getTransport().setRequestHeader(k, config.headers[k]); + } + }); + } + return statics.root; }