Commit 3a06f264 authored by caseq's avatar caseq Committed by Commit bot

Fix remote trace recording via chrome://inspect?tracing

This was regressed in two different places, first by
https://codereview.chromium.org/2515903002
and then by
https://codereview.chromium.org/2607833002

BUG=680170

Review-Url: https://codereview.chromium.org/2628863003
Cr-Commit-Position: refs/heads/master@{#443121}
parent 1916748e
......@@ -472,6 +472,12 @@ GURL DevToolsUIBindings::SanitizeFrontendURL(const GURL& url) {
}
bool DevToolsUIBindings::IsValidFrontendURL(const GURL& url) {
if (url.SchemeIs(content::kChromeUIScheme) &&
url.host() == content::kChromeUITracingHost &&
!url.has_query() && !url.has_ref()) {
return true;
}
return SanitizeFrontendURL(url).spec() == url.spec();
}
......@@ -582,7 +588,7 @@ DevToolsUIBindings::~DevToolsUIBindings() {
// content::DevToolsFrontendHost::Delegate implementation ---------------------
void DevToolsUIBindings::HandleMessageFromDevToolsFrontend(
const std::string& message) {
if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
if (!frontend_host_)
return;
std::string method;
base::ListValue empty_params;
......@@ -612,7 +618,7 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontend(
void DevToolsUIBindings::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host, const std::string& message) {
DCHECK(agent_host == agent_host_.get());
if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
if (!frontend_host_)
return;
if (message.length() < kMaxMessageChunkSize) {
......@@ -728,7 +734,7 @@ void DevToolsUIBindings::AppendToFile(const std::string& url,
}
void DevToolsUIBindings::RequestFileSystems() {
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
std::vector<DevToolsFileHelper::FileSystem> file_systems =
file_helper_->GetFileSystems();
base::ListValue file_systems_value;
......@@ -739,7 +745,7 @@ void DevToolsUIBindings::RequestFileSystems() {
}
void DevToolsUIBindings::AddFileSystem(const std::string& file_system_path) {
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
file_helper_->AddFileSystem(
file_system_path,
base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar,
......@@ -747,13 +753,13 @@ void DevToolsUIBindings::AddFileSystem(const std::string& file_system_path) {
}
void DevToolsUIBindings::RemoveFileSystem(const std::string& file_system_path) {
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
file_helper_->RemoveFileSystem(file_system_path);
}
void DevToolsUIBindings::UpgradeDraggedFileSystemPermissions(
const std::string& file_system_url) {
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
file_helper_->UpgradeDraggedFileSystemPermissions(
file_system_url,
base::Bind(&DevToolsUIBindings::ShowDevToolsConfirmInfoBar,
......@@ -763,7 +769,7 @@ void DevToolsUIBindings::UpgradeDraggedFileSystemPermissions(
void DevToolsUIBindings::IndexPath(int index_request_id,
const std::string& file_system_path) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
if (!file_helper_->IsFileSystemAdded(file_system_path)) {
IndexingDone(index_request_id, file_system_path);
return;
......@@ -801,7 +807,7 @@ void DevToolsUIBindings::SearchInPath(int search_request_id,
const std::string& file_system_path,
const std::string& query) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
CHECK(web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme));
CHECK(IsValidFrontendURL(web_contents_->GetURL()) && frontend_host_);
if (!file_helper_->IsFileSystemAdded(file_system_path)) {
SearchCompleted(search_request_id,
file_system_path,
......@@ -1287,8 +1293,6 @@ void DevToolsUIBindings::CallClientFunction(const std::string& function_name,
const base::Value* arg1,
const base::Value* arg2,
const base::Value* arg3) {
if (!web_contents_->GetURL().SchemeIs(content::kChromeDevToolsScheme))
return;
// If we're not exposing bindings, we shouldn't call functions either.
if (!frontend_host_)
return;
......
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