Commit fa2b888a authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[fix] Refactoring the popup UI

parent 7cd58a409369
......@@ -32,7 +32,9 @@ import {
observeContent,
getAcceptRdf,
ORIGIN_KIND_DIRECT,
ORIGIN_KIND_LINKED_HTML
ORIGIN_KIND_LINKED_HTML,
ORIGIN_KIND_NEGOTIATED,
ORIGIN_KIND_REDIRECTED
} from "../common/data";
import { Message, activateNegotiated } from "../common/messages";
/// <reference path="./fallback.d.ts"/>
......@@ -134,6 +136,17 @@ function onSendingHeaders(
return {};
let observation = allObservations[details.tabId];
if (observation == null || observation == undefined) return {};
if (
observation.origin == null ||
observation.origin.kind != ORIGIN_KIND_REDIRECTED
)
observation.origin = {
kind: ORIGIN_KIND_DIRECT,
url: details.url
};
if (observation.origin.kind == ORIGIN_KIND_REDIRECTED) {
observation.origin.kind = ORIGIN_KIND_NEGOTIATED;
}
if (observation.preemptable) {
// this tab has been preempted
let headers = details.requestHeaders;
......@@ -163,11 +176,23 @@ function onHeadersReceived(
details.frameId != 0 || // not the main top-level frame
details.method != "GET" || // not a GET method
details.statusCode < 200 || // not an OK
details.statusCode >= 300 || // redirect or failure no handled
details.statusCode >= 400 || // redirect or failure no handled
details.type != "main_frame" // not the top-level document
)
return {};
if (details.statusCode >= 300) {
let observation = allObservations[details.tabId];
if (details.statusCode == 303 && observation) {
// mark as negotiated
observation.origin = {
kind: ORIGIN_KIND_REDIRECTED,
url: details.url
};
}
return {};
}
let index = details.url.indexOf("?protocol=ldviews&uri=");
if (index >= 0) {
// preempts the protocol ldviews
......@@ -198,7 +223,7 @@ function onHeadersReceived(
url: details.url
});
let observation = resolveObservationsForTab(allObservations, details.tabId);
observation.origin = obs.origin;
if (observation.origin == null) observation.origin = obs.origin;
observation.url = obs.url;
observation.primaryTopic = obs.primaryTopic;
observation.sources = obs.sources;
......
......@@ -349,6 +349,10 @@ export const ORIGIN_KIND_LINKED_HTML: string = "htmlLink";
* The document or source has been obtained through negotiation
*/
export const ORIGIN_KIND_NEGOTIATED: string = "negotiated";
/**
* The document or source has been obtained through a redirection
*/
export const ORIGIN_KIND_REDIRECTED: string = "redirected";
/**
* The document or source is the direct response from the server
*/
......@@ -642,7 +646,7 @@ export function observeContent(
observable.url,
MIME[observable.contentType],
observable.content,
{ kind: ORIGIN_KIND_DIRECT, url: observable.url }
origin
)
: new DocumentSourceLinked(
new Link(observable.url, [
......
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