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

Unified Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 967513002: DevTools: do not use debug target when loading URLs for the front-end (chrome side). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@t5
Patch Set: using acks Created 5 years, 10 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/browser/devtools/devtools_ui_bindings.cc
diff --git a/chrome/browser/devtools/devtools_ui_bindings.cc b/chrome/browser/devtools/devtools_ui_bindings.cc
index 1f28ed8c42a5d37c0a605011928d8a25634a898d..e7ebc5a610c8c72b8f815084ad438bd9cbb51944 100644
--- a/chrome/browser/devtools/devtools_ui_bindings.cc
+++ b/chrome/browser/devtools/devtools_ui_bindings.cc
@@ -47,6 +47,8 @@
#include "content/public/common/url_constants.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/permissions/permissions_data.h"
+#include "net/http/http_response_headers.h"
+#include "net/url_request/url_fetcher.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
@@ -466,10 +468,11 @@ void DevToolsUIBindings::AgentHostClosed(
delegate_->InspectedContentsClosing();
}
-void DevToolsUIBindings::SendMessageAck(int request_id) {
+void DevToolsUIBindings::SendMessageAck(int request_id,
+ const base::Value* arg) {
base::FundamentalValue id_value(request_id);
CallClientFunction("DevToolsAPI.embedderMessageAck",
- &id_value, nullptr, nullptr);
+ &id_value, arg, nullptr);
}
// DevToolsEmbedderMessageDispatcher::Delegate implementation -----------------
@@ -492,7 +495,7 @@ void DevToolsUIBindings::SetInspectedPageBounds(int request_id,
void DevToolsUIBindings::SetIsDocked(int request_id, bool dock_requested) {
delegate_->SetIsDocked(dock_requested);
- SendMessageAck(request_id);
+ SendMessageAck(request_id, nullptr);
}
void DevToolsUIBindings::InspectElementCompleted(int request_id) {
@@ -509,6 +512,25 @@ void DevToolsUIBindings::InspectedURLChanged(int request_id,
web_contents()->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE);
}
+void DevToolsUIBindings::LoadNetworkResource(int request_id,
+ const std::string& url,
+ const std::string& headers) {
+ GURL gurl(url);
+ if (!gurl.is_valid()) {
+ base::DictionaryValue response;
+ response.SetInteger("statusCode", 404);
+ SendMessageAck(request_id, &response);
+ return;
+ }
+
+ net::URLFetcher* fetcher =
+ net::URLFetcher::Create(gurl, net::URLFetcher::GET, this);
dgozman 2015/02/27 12:22:04 You should delete all pending fetchers in destruct
pfeldman 2015/02/27 12:54:47 Ouch. Done.
+ pending_requests_[fetcher] = request_id;
+ fetcher->SetRequestContext(profile_->GetRequestContext());
+ fetcher->SetExtraRequestHeaders(headers);
+ fetcher->Start();
+}
+
void DevToolsUIBindings::OpenInNewTab(int request_id, const std::string& url) {
delegate_->OpenInNewTab(url);
}
@@ -704,6 +726,33 @@ void DevToolsUIBindings::RecordActionUMA(int request_id,
UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary);
}
+void DevToolsUIBindings::OnURLFetchComplete(const net::URLFetcher* source) {
+ DCHECK(source);
+ PendingRequestsMap::iterator it = pending_requests_.find(source);
+ DCHECK(it != pending_requests_.end());
+
+ std::string body;
+ source->GetResponseAsString(&body);
+
+ base::FundamentalValue request_id(it->second);
+
+ base::DictionaryValue response;
+ base::DictionaryValue* headers = new base::DictionaryValue();
+ net::HttpResponseHeaders* rh = source->GetResponseHeaders();
+ response.SetInteger("statusCode", rh ? rh->response_code() : 200);
+ response.Set("headers", headers);
+ response.SetString("body", body);
+
+ void* iterator = NULL;
+ std::string name;
+ std::string value;
+ while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value))
+ headers->SetString(name, value);
+
+ SendMessageAck(it->second, &response);
+ pending_requests_.erase(it);
+}
+
void DevToolsUIBindings::DeviceCountChanged(int count) {
base::FundamentalValue value(count);
CallClientFunction("DevToolsAPI.deviceCountUpdated", &value, NULL,

Powered by Google App Engine
This is Rietveld 408576698