feat(instrumentation): do not enable by default

test-unit-sauce
Brian Ford 10 years ago
parent f1c54f3f24
commit 1cfef9bd07

@ -1,20 +1,26 @@
var html = document.getElementsByTagName('html')[0]; if (document.cookie.indexOf('__ngDebug=true') != -1) {
bootstrapHint();
}
var eventProxyElement = document.createElement('div'); function bootstrapHint () {
eventProxyElement.id = '__ngBatarangElement'; var html = document.getElementsByTagName('html')[0];
eventProxyElement.style.display = 'none';
html.appendChild(eventProxyElement);
// inject into the application context from the content script context var eventProxyElement = document.createElement('div');
eventProxyElement.id = '__ngBatarangElement';
eventProxyElement.style.display = 'none';
html.appendChild(eventProxyElement);
var script = window.document.createElement('script'); // inject into the application context from the content script context
script.src = chrome.extension.getURL('dist/hint.js');
eventProxyElement.addEventListener('batarangDataEvent', function () { var script = window.document.createElement('script');
var eventData = eventProxyElement.innerText; script.src = chrome.extension.getURL('dist/hint.js');
chrome.extension.sendMessage(eventData);
});
html.setAttribute('ng-hint', ''); eventProxyElement.addEventListener('batarangDataEvent', function () {
var eventData = eventProxyElement.innerText;
chrome.extension.sendMessage(eventData);
});
html.appendChild(script); html.setAttribute('ng-hint', '');
html.appendChild(script);
}

@ -21,6 +21,14 @@ function inspectedAppService($rootScope) {
return invokeAngularHintMethod('assign', scopeId, path, value); return invokeAngularHintMethod('assign', scopeId, path, value);
}; };
this.enableInstrumentation = function (setting) {
setting = !!setting;
chrome.devtools.inspectedWindow.eval(
"window.document.cookie = '__ngDebug=" + setting + ";';" +
"window.document.location.reload();"
);
};
/* /*
* sets window.$scope to the scope of the given id * sets window.$scope to the scope of the given id
*/ */

@ -8,6 +8,16 @@
sidebar" sidebar"
style="width: 200px;"> style="width: 200px;">
<ol class="sidebar-tree" tabindex="0"> <ol class="sidebar-tree" tabindex="0">
<li class="sidebar-tree-item
profile-launcher-view-tree-item">
<img class="icon">
<div class="status"></div>
<div class="titles no-subtitle">
<span class="title ng-binding">Enable <input type="checkbox" ng-model="enabled"></span>
<span class="subtitle"></span>
</div>
</li>
<li ng-repeat="pane in panes" <li ng-repeat="pane in panes"
ng-click="select(pane)" ng-click="select(pane)"
class="sidebar-tree-item class="sidebar-tree-item

@ -1,6 +1,6 @@
angular.module('batarang.tabs', []). angular.module('batarang.tabs', []).
directive('batTabs', function ($compile, $templateCache, $http) { directive('batTabs', function ($compile, $templateCache, $http, inspectedApp) {
return { return {
restrict: 'E', restrict: 'E',
transclude: true, transclude: true,
@ -14,6 +14,12 @@ directive('batTabs', function ($compile, $templateCache, $http) {
this.addPane = function(pane) { this.addPane = function(pane) {
panes.push(pane); panes.push(pane);
}; };
$scope.$watch('enabled', function (newVal) {
if (newVal === !!newVal) {
inspectedApp.enableInstrumentation(newVal);
}
});
}, },
link: function (scope, element, attr) { link: function (scope, element, attr) {