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

Unified Diff: chrome/browser/extensions/api/debugger/debugger_api.cc

Issue 352523003: Have the Debugger extension api check that it has access to the tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add PermissionsData::UrlIsRestricted() Created 6 years, 6 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/extensions/api/debugger/debugger_api.cc
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc
index ebbc10207223aa9f07f5fed2ca7ee92480921f65..3fbaa6af5343dc26dbb871f45b4e740f80a358cc 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -47,8 +47,12 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/extension_system.h"
+#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
+#include "extensions/common/manifest_constants.h"
+#include "extensions/common/permissions/permissions_data.h"
+#include "extensions/common/switches.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -503,6 +507,7 @@ void DebuggerFunction::FormatErrorMessage(const std::string& format) {
}
bool DebuggerFunction::InitAgentHost() {
+ const Extension* extension = GetExtension();
if (debuggee_.tab_id) {
WebContents* web_contents = NULL;
bool result = ExtensionTabUtil::GetTabById(*debuggee_.tab_id,
@@ -513,12 +518,9 @@ bool DebuggerFunction::InitAgentHost() {
&web_contents,
NULL);
if (result && web_contents) {
- if (content::HasWebUIScheme(web_contents->GetURL())) {
- error_ = ErrorUtils::FormatErrorMessage(
- keys::kAttachToWebUIError,
- web_contents->GetURL().scheme());
+ GURL url = web_contents->GetVisibleURL();
not at google - send to devlin 2014/06/25 20:42:16 yeah this really should be GetLastCommittedURL. co
Devlin 2014/06/25 23:30:00 Done.
+ if (PermissionsData::UrlIsRestricted(url, url, extension, &error_))
return false;
- }
agent_host_ = DevToolsAgentHost::GetOrCreateFor(web_contents);
}
} else if (debuggee_.extension_id) {
@@ -527,6 +529,12 @@ bool DebuggerFunction::InitAgentHost() {
->process_manager()
->GetBackgroundHostForExtension(*debuggee_.extension_id);
if (extension_host) {
+ if (PermissionsData::UrlIsRestricted(extension_host->GetURL(),
+ extension_host->GetURL(),
+ extension,
+ &error_)) {
+ return false;
+ }
agent_host_ = DevToolsAgentHost::GetOrCreateFor(
extension_host->render_view_host());
}
@@ -588,25 +596,26 @@ bool DebuggerAttachFunction::RunAsync() {
return false;
}
+ const Extension* extension = GetExtension();
infobars::InfoBar* infobar = NULL;
if (!CommandLine::ForCurrentProcess()->
- HasSwitch(switches::kSilentDebuggerExtensionAPI)) {
+ HasSwitch(::switches::kSilentDebuggerExtensionAPI)) {
// Do not attach to the target if for any reason the infobar cannot be shown
// for this WebContents instance.
infobar = ExtensionDevToolsInfoBarDelegate::Create(
- agent_host_->GetRenderViewHost(), GetExtension()->name());
+ agent_host_->GetRenderViewHost(), extension->name());
if (!infobar) {
error_ = ErrorUtils::FormatErrorMessage(
keys::kSilentDebuggingRequired,
- switches::kSilentDebuggerExtensionAPI);
+ ::switches::kSilentDebuggerExtensionAPI);
return false;
}
}
new ExtensionDevToolsClientHost(GetProfile(),
agent_host_.get(),
- GetExtension()->id(),
- GetExtension()->name(),
+ extension->id(),
+ extension->name(),
debuggee_,
infobar);
SendResponse(true);

Powered by Google App Engine
This is Rietveld 408576698