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

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

Issue 2628863003: Fix remote trace recording via chrome://inspect?tracing (Closed)
Patch Set: drive by: stronger check for front-end URL Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 466150c4b10fe305219d7737d620bef1092324a3..2c6c72214bb491ca2fbf25f7ba29c2fab6388f59 100644
--- a/chrome/browser/devtools/devtools_ui_bindings.cc
+++ b/chrome/browser/devtools/devtools_ui_bindings.cc
@@ -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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698