| 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;
|
|
|