From 68f2f9eee86b0afd0236b10a5c1a762defe11b2d Mon Sep 17 00:00:00 2001 From: "aa@chromium.org" Date: Thu, 22 Mar 2012 03:25:25 +0000 Subject: Add a helpful console message in case web-inaccessible request. BUG=112620 Review URL: http://codereview.chromium.org/9805004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128157 0039d316-1c4b-4281-b951-d872f2087c98 --- .../extensions/extension_resource_request_policy.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'chrome/renderer/extensions/extension_resource_request_policy.cc') diff --git a/chrome/renderer/extensions/extension_resource_request_policy.cc b/chrome/renderer/extensions/extension_resource_request_policy.cc index 6e7e6c8..4bee495 100644 --- a/chrome/renderer/extensions/extension_resource_request_policy.cc +++ b/chrome/renderer/extensions/extension_resource_request_policy.cc @@ -6,18 +6,21 @@ #include "base/command_line.h" #include "base/logging.h" +#include "base/stringprintf.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_set.h" #include "googleurl/src/gurl.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" // static bool ExtensionResourceRequestPolicy::CanRequestResource( const GURL& resource_url, - const WebKit::WebFrame* frame, + WebKit::WebFrame* frame, const ExtensionSet* loaded_extensions) { CHECK(resource_url.SchemeIs(chrome::kExtensionScheme)); @@ -59,8 +62,14 @@ bool ExtensionResourceRequestPolicy::CanRequestResource( !(page_url.SchemeIs(chrome::kChromeDevToolsScheme) && !extension->devtools_url().is_empty()) && !extension->IsResourceWebAccessible(resource_url.path())) { - LOG(ERROR) << "Denying load of " << resource_url.spec() << " which " - << "is not a web accessible resource."; + std::string message = base::StringPrintf( + "Denying load of %s. Resources must be listed in the " + "web_accessible_resources manifest key in order to be loaded by web " + "pages.", + resource_url.spec().c_str()); + frame->addMessageToConsole( + WebKit::WebConsoleMessage(WebKit::WebConsoleMessage::LevelError, + WebKit::WebString::fromUTF8(message))); return false; } -- cgit v1.1