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

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

Issue 439843002: Merge 280354 "Have the Debugger extension api check that it has ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 4 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 | chrome/browser/extensions/api/debugger/debugger_api_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/debugger/debugger_api.cc
===================================================================
--- chrome/browser/extensions/api/debugger/debugger_api.cc (revision 287393)
+++ chrome/browser/extensions/api/debugger/debugger_api.cc (working copy)
@@ -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 @@
}
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,10 @@
&web_contents,
NULL);
if (result && web_contents) {
- if (content::HasWebUIScheme(web_contents->GetURL())) {
- error_ = ErrorUtils::FormatErrorMessage(
- keys::kAttachToWebUIError,
- web_contents->GetURL().scheme());
+ // TODO(rdevlin.cronin) This should definitely be GetLastCommittedURL().
+ GURL url = web_contents->GetVisibleURL();
+ if (PermissionsData::IsRestrictedUrl(url, url, extension, &error_))
return false;
- }
agent_host_ = DevToolsAgentHost::GetOrCreateFor(web_contents);
}
} else if (debuggee_.extension_id) {
@@ -527,6 +530,12 @@
->process_manager()
->GetBackgroundHostForExtension(*debuggee_.extension_id);
if (extension_host) {
+ if (PermissionsData::IsRestrictedUrl(extension_host->GetURL(),
+ extension_host->GetURL(),
+ extension,
+ &error_)) {
+ return false;
+ }
agent_host_ = DevToolsAgentHost::GetOrCreateFor(
extension_host->render_view_host());
}
@@ -588,25 +597,26 @@
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);
« no previous file with comments | « no previous file | chrome/browser/extensions/api/debugger/debugger_api_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698