From 66af1dd3e5aa80b257ba711600d112752ecaf655 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 17 Feb 2012 00:19:48 -0800 Subject: Adding Chrome webRequest intercept Need to add logic to resolve file's actual URL dynamically. --- js/controllers/document-controller.js | 25 +++++++++++++++++++++++++ js/document/html-document.js | 6 ++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index b1a22c1b..9785d824 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -56,12 +56,37 @@ DocumentController = exports.DocumentController = Montage.create(Component, { this.eventManager.addEventListener("executeSave", this, false); this.eventManager.addEventListener("recordStyleChanged", this, false); + + + } }, + + + handleWebRequest: { + value: function (request) { + if (request.url.indexOf('js/document/templates/montage-html') !== -1) { + + console.log(request); + + //TODO: Figure out why active document is not available here + + /* +if (request.url.indexOf('calculator.css') !== -1) { + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+'/calculator/components/calculator.reel/calculator.css'}; + } +*/ + } + } + }, + handleAppLoaded: { value: function() { // + + chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: [""]}, ["blocking"]); + } }, diff --git a/js/document/html-document.js b/js/document/html-document.js index a5483f40..16595d14 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -355,13 +355,15 @@ exports.HTMLDocument = Montage.create(TextDocument, { }, + + + //////////////////////////////////////////////////////////////////// // handleEvent: { value: function(event){ - //console.log('end'); - //console.log('file content start'); + //TODO: Clean up, using for prototyping save this._templateDocument = {}; this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");; -- cgit v1.2.3