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 ++++-- manifest.json | 4 +++- 3 files changed, 32 insertions(+), 3 deletions(-) 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");; diff --git a/manifest.json b/manifest.json index 12a5d8b7..2754c71e 100644 --- a/manifest.json +++ b/manifest.json @@ -12,7 +12,9 @@ }, "permissions": [ "unlimitedStorage", - "notifications" + "notifications", + "webRequestBlocking", + "webRequest" ], "requirements": { "3D": { -- cgit v1.2.3