Commit 5ae21c60 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[fix] Fixing Chrome compatibility

parent 5d3104c70a94
......@@ -34,7 +34,8 @@ import {
ORIGIN_KIND_DIRECT,
ORIGIN_KIND_LINKED_HTML,
ORIGIN_KIND_REDIRECTED,
DocumentStatus
DocumentStatus,
DocumentObservations
} from "../common/data";
import { Message, activateTab } from "../common/messages";
/// <reference path="./fallback.d.ts"/>
......@@ -50,6 +51,10 @@ import {
* The data about the tabs
*/
let allObservations: ObservedResourceRegistry = {};
/**
* The observations for an opening tab
*/
let openingObservations: DocumentObservations = null;
/**
* The reference view registry
*/
......@@ -137,7 +142,11 @@ function onSendingHeaders(
)
return {};
let observation = allObservations[details.tabId];
if (observation == null || observation == undefined) return {};
if (observation == null || observation == undefined) {
if (openingObservations == null) return {};
// this is tab opening from the extension
observation = openingObservations;
}
// do not request RDF for off and asleep tabs
if (
observation.status == DocumentStatus.off ||
......@@ -395,8 +404,8 @@ chrome.pageAction.onClicked.addListener((tab: chrome.tabs.Tab) => {
let isNegotiated =
observation.negotiated != null && observation.negotiated != undefined;
let callback = (openedTab: chrome.tabs.Tab) => {
allObservations[openedTab.id] = JSON.parse(JSON.stringify(observation));
allObservations[openedTab.id].status = DocumentStatus.active;
allObservations[openedTab.id] = openingObservations;
openingObservations = null;
onObservedTabUpdated(openedTab.id);
activateTab(openedTab.id, observation);
};
......@@ -405,6 +414,8 @@ chrome.pageAction.onClicked.addListener((tab: chrome.tabs.Tab) => {
: chrome.extension.getURL(
"ldbrowser/index.html?target=" + encodeURIComponent(observation.url)
);
openingObservations = JSON.parse(JSON.stringify(observation));
openingObservations.status = DocumentStatus.active;
let promise: any = chrome.tabs.create(
{
windowId: tab.windowId,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment