Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3372)

Unified Diff: chrome/common/extensions/docs/examples/api/debugger/live-headers/headers.html

Issue 9289057: Changing manifest to v2 extension samples (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding zip files after rebasing with master Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/api/debugger/live-headers/headers.html
diff --git a/chrome/common/extensions/docs/examples/api/debugger/live-headers/headers.html b/chrome/common/extensions/docs/examples/api/debugger/live-headers/headers.html
index 6261c3e0af94d1e29779d37af8acdea8bc242031..3c042e97946988f89d620bc53baa391d58f029c7 100644
--- a/chrome/common/extensions/docs/examples/api/debugger/live-headers/headers.html
+++ b/chrome/common/extensions/docs/examples/api/debugger/live-headers/headers.html
@@ -1,5 +1,5 @@
<!--
-Copyright (c) 2011 The Chromium Authors. All rights reserved.
+Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
@@ -23,83 +23,7 @@ body {
</style>
-<script>
-
-var tabId = parseInt(window.location.search.substring(1));
-
-window.addEventListener("load", function() {
- chrome.debugger.sendCommand({tabId:tabId}, "Network.enable");
- chrome.debugger.onEvent.addListener(onEvent);
-});
-
-window.addEventListener("unload", function() {
- chrome.debugger.detach({tabId:tabId});
-});
-
-var requests = {};
-
-function onEvent(debuggeeId, message, params) {
- if (tabId != debuggeeId.tabId)
- return;
-
- if (message == "Network.requestWillBeSent") {
- var requestDiv = requests[params.requestId];
- if (!requestDiv) {
- var requestDiv = document.createElement("div");
- requestDiv.className = "request";
- requests[params.requestId] = requestDiv;
- var urlLine = document.createElement("div");
- urlLine.textContent = params.request.url;
- requestDiv.appendChild(urlLine);
- }
-
- if (params.redirectResponse)
- appendResponse(params.requestId, params.redirectResponse);
-
- var requestLine = document.createElement("div");
- requestLine.textContent = "\n" + params.request.method + " " +
- parseURL(params.request.url).path + " HTTP/1.1";
- requestDiv.appendChild(requestLine);
- document.getElementById("container").appendChild(requestDiv);
- } else if (message == "Network.responseReceived") {
- appendResponse(params.requestId, params.response);
- }
-}
-
-function appendResponse(requestId, response) {
- var requestDiv = requests[requestId];
- requestDiv.appendChild(formatHeaders(response.requestHeaders));
-
- var statusLine = document.createElement("div");
- statusLine.textContent = "\nHTTP/1.1 " + response.status + " " +
- response.statusText;
- requestDiv.appendChild(statusLine);
- requestDiv.appendChild(formatHeaders(response.headers));
-}
-
-function formatHeaders(headers) {
- var text = "";
- for (name in headers)
- text += name + ": " + headers[name] + "\n";
- var div = document.createElement("div");
- div.textContent = text;
- return div;
-}
-
-function parseURL(url) {
- var result = {};
- var match = url.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
- if (!match)
- return result;
- result.scheme = match[1].toLowerCase();
- result.host = match[2];
- result.port = match[3];
- result.path = match[4] || "/";
- result.fragment = match[5];
- return result;
-}
-
-</script>
+<script src="headers.js"></script>
</head>
<body>

Powered by Google App Engine
This is Rietveld 408576698