summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc1
-rw-r--r--chrome/browser/dom_ui/dom_ui.h1
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc6
-rw-r--r--chrome/browser/extensions/extension_dom_ui.h1
-rw-r--r--chrome/browser/extensions/extension_function.h6
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc2
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.h2
-rw-r--r--chrome/browser/extensions/extension_host.cc3
-rw-r--r--chrome/browser/extensions/extension_host.h1
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc123
-rw-r--r--chrome/browser/notifications/balloon_host.cc3
-rw-r--r--chrome/browser/notifications/balloon_host.h1
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc9
-rw-r--r--chrome/browser/renderer_host/render_view_host.h7
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h1
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc4
-rw-r--r--chrome/browser/tab_contents/tab_contents.h1
-rw-r--r--chrome/common/render_messages_internal.h6
-rw-r--r--chrome/renderer/dom_ui_bindings.cc10
-rw-r--r--chrome/renderer/extensions/extension_api_client_unittest.cc2
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.cc7
-rw-r--r--chrome/renderer/render_view.cc7
-rw-r--r--chrome/renderer/render_view.h4
23 files changed, 149 insertions, 59 deletions
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index 8f83db1..1d6b5b5 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -38,6 +38,7 @@ DOMUI::~DOMUI() {
void DOMUI::ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback) {
// Look up the callback for this message.
diff --git a/chrome/browser/dom_ui/dom_ui.h b/chrome/browser/dom_ui/dom_ui.h
index fe1af1c1..7fd2e55 100644
--- a/chrome/browser/dom_ui/dom_ui.h
+++ b/chrome/browser/dom_ui/dom_ui.h
@@ -42,6 +42,7 @@ class DOMUI {
// Called from TabContents.
virtual void ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback);
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index 7d8d15d..40f11f1 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -91,9 +91,13 @@ void ExtensionDOMUI::RenderViewReused(RenderViewHost* render_view_host) {
void ExtensionDOMUI::ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback) {
- extension_function_dispatcher_->HandleRequest(message, content, request_id,
+ extension_function_dispatcher_->HandleRequest(message,
+ content,
+ source_url,
+ request_id,
has_callback);
}
diff --git a/chrome/browser/extensions/extension_dom_ui.h b/chrome/browser/extensions/extension_dom_ui.h
index 7892b89..d14eb69 100644
--- a/chrome/browser/extensions/extension_dom_ui.h
+++ b/chrome/browser/extensions/extension_dom_ui.h
@@ -37,6 +37,7 @@ class ExtensionDOMUI
virtual void RenderViewReused(RenderViewHost* render_view_host);
virtual void ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback);
diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h
index 8e1ab8f..272d6c1 100644
--- a/chrome/browser/extensions/extension_function.h
+++ b/chrome/browser/extensions/extension_function.h
@@ -71,6 +71,9 @@ class ExtensionFunction : public base::RefCounted<ExtensionFunction> {
void set_request_id(int request_id) { request_id_ = request_id; }
int request_id() { return request_id_; }
+ void set_source_url(const GURL& source_url) { source_url_ = source_url; }
+ const GURL& source_url() { return source_url_; }
+
void set_has_callback(bool has_callback) { has_callback_ = has_callback; }
bool has_callback() { return has_callback_; }
@@ -126,6 +129,9 @@ class ExtensionFunction : public base::RefCounted<ExtensionFunction> {
// The name of this function.
std::string name_;
+ // The URL of the frame which is making this request
+ GURL source_url_;
+
// True if the js caller provides a callback function to receive the response
// of this call.
bool has_callback_;
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 78a2c032..8abc84c 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -372,12 +372,14 @@ Extension* ExtensionFunctionDispatcher::GetExtension() {
void ExtensionFunctionDispatcher::HandleRequest(const std::string& name,
const Value* args,
+ const GURL& source_url,
int request_id,
bool has_callback) {
scoped_refptr<ExtensionFunction> function(
FactoryRegistry::instance()->NewFunction(name));
function->set_dispatcher_peer(peer_);
function->SetArgs(args);
+ function->set_source_url(source_url);
function->set_request_id(request_id);
function->set_has_callback(has_callback);
ExtensionsService* service = profile()->GetExtensionsService();
diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h
index 86342cc..08e74bc1 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.h
+++ b/chrome/browser/extensions/extension_function_dispatcher.h
@@ -92,7 +92,7 @@ class ExtensionFunctionDispatcher {
// Handle a request to execute an extension function.
void HandleRequest(const std::string& name, const Value* args,
- int request_id, bool has_callback);
+ const GURL& source_url, int request_id, bool has_callback);
// Send a response to a function.
void SendResponse(ExtensionFunction* api, bool success);
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 1e04547..a9d2259 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -526,11 +526,12 @@ WebPreferences ExtensionHost::GetWebkitPrefs() {
void ExtensionHost::ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback) {
if (extension_function_dispatcher_.get()) {
extension_function_dispatcher_->HandleRequest(
- message, content, request_id, has_callback);
+ message, content, source_url, request_id, has_callback);
}
}
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index b7de670..4d6ca59 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -121,6 +121,7 @@ class ExtensionHost : public RenderViewHostDelegate,
virtual WebPreferences GetWebkitPrefs();
virtual void ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback);
virtual void RunJavaScriptMessage(const std::wstring& message,
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 934f2d6..28b50e9 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
+#include "base/histogram.h"
#include "base/base64.h"
#include "base/string_util.h"
#include "chrome/browser/browser.h"
@@ -48,6 +49,19 @@ static bool GetTabById(int tab_id, Profile* profile,
TabContents** contents,
int* tab_index, std::string* error_message);
+// Takes |url_string| and returns a GURL which is either valid and absolute
+// or invalid. If |url_string| is not directly interpretable as a valid (it is
+// likely a relative URL) an attempt is made to resolve it. |extension| is
+// provided so it can be resolved relative to its extension base
+// (chrome-extension://<id>/). |source_url| is provided so that we can test
+// whether |url_string| resolves differently relative to the source frame url.
+// Using the source frame url would be more correct, but because the api shipped
+// with urls resolved relative to their extension base, we must first measure
+// how much of an inpact making the change would have.
+static GURL ResolvePossiblyRelativeURL(std::string url_string,
+ Extension* extension,
+ const GURL& source_url);
+
// Return the type name for a browser window type.
static std::string GetWindowTypeText(Browser::Type type);
@@ -281,26 +295,22 @@ bool GetAllWindowsFunction::RunImpl() {
}
bool CreateWindowFunction::RunImpl() {
- scoped_ptr<GURL> url(new GURL());
+ GURL url;
// Look for optional url.
if (!args_->IsType(Value::TYPE_NULL)) {
EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY));
const DictionaryValue *args = args_as_dictionary();
- std::string url_input;
+ std::string url_string;
if (args->HasKey(keys::kUrlKey)) {
EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey,
- &url_input));
- url.reset(new GURL(url_input));
- if (!url->is_valid()) {
- // The path as passed in is not valid. Try converting to absolute path.
- *url = GetExtension()->GetResourceURL(url_input);
- if (!url->is_valid()) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(
- keys::kInvalidUrlError,
- url_input);
- return false;
- }
+ &url_string));
+ url = ResolvePossiblyRelativeURL(url_string, GetExtension(),
+ source_url());
+ if (!url.is_valid()) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(
+ keys::kInvalidUrlError, url_string);
+ return false;
}
}
}
@@ -374,7 +384,7 @@ bool CreateWindowFunction::RunImpl() {
Browser* new_window = new Browser(window_type, window_profile);
new_window->CreateBrowserWindow();
- new_window->AddTabWithURL(*(url.get()), GURL(), PageTransition::LINK, true,
+ new_window->AddTabWithURL(url, GURL(), PageTransition::LINK, true,
-1, false, NULL);
new_window->window()->SetBounds(bounds);
@@ -532,19 +542,15 @@ bool CreateTabFunction::RunImpl() {
// -favIconUrl
std::string url_string;
- scoped_ptr<GURL> url(new GURL());
+ GURL url;
if (args->HasKey(keys::kUrlKey)) {
EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey,
&url_string));
- url.reset(new GURL(url_string));
- if (!url->is_valid()) {
- // The path as passed in is not valid. Try converting to absolute path.
- *url = GetExtension()->GetResourceURL(url_string);
- if (!url->is_valid()) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
- url_string);
- return false;
- }
+ url = ResolvePossiblyRelativeURL(url_string, GetExtension(), source_url());
+ if (!url.is_valid()) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
+ url_string);
+ return false;
}
}
@@ -563,7 +569,7 @@ bool CreateTabFunction::RunImpl() {
// We can't load extension URLs into incognito windows. Special case to
// fall back to a normal window.
- if (url->SchemeIs(chrome::kExtensionScheme) &&
+ if (url.SchemeIs(chrome::kExtensionScheme) &&
browser->profile()->IsOffTheRecord()) {
browser = Browser::GetOrCreateTabbedBrowser(
browser->profile()->GetOriginalProfile());
@@ -580,7 +586,7 @@ bool CreateTabFunction::RunImpl() {
index = tab_strip->count();
}
- TabContents* contents = browser->AddTabWithURL(*(url.get()), GURL(),
+ TabContents* contents = browser->AddTabWithURL(url, GURL(),
PageTransition::LINK, selected, index, true, NULL);
index = tab_strip->GetIndexOfTabContents(contents);
@@ -632,25 +638,22 @@ bool UpdateTabFunction::RunImpl() {
// -favIconUrl
// Navigate the tab to a new location if the url different.
- std::string url;
+ std::string url_string;
if (update_props->HasKey(keys::kUrlKey)) {
EXTENSION_FUNCTION_VALIDATE(update_props->GetString(
- keys::kUrlKey, &url));
- GURL new_gurl(url);
-
- if (!new_gurl.is_valid()) {
- // The path as passed in is not valid. Try converting to absolute path.
- new_gurl = GetExtension()->GetResourceURL(url);
- if (!new_gurl.is_valid()) {
- error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
- url);
- return false;
- }
+ keys::kUrlKey, &url_string));
+ GURL url = ResolvePossiblyRelativeURL(url_string, GetExtension(),
+ source_url());
+
+ if (!url.is_valid()) {
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError,
+ url_string);
+ return false;
}
// JavaScript URLs can do the same kinds of things as cross-origin XHR, so
// we need to check host permissions before allowing them.
- if (new_gurl.SchemeIs(chrome::kJavaScriptScheme)) {
+ if (url.SchemeIs(chrome::kJavaScriptScheme)) {
if (!GetExtension()->CanExecuteScriptOnHost(contents->GetURL(), &error_))
return false;
@@ -665,12 +668,12 @@ bool UpdateTabFunction::RunImpl() {
return false;
}
- controller.LoadURL(new_gurl, GURL(), PageTransition::LINK);
+ controller.LoadURL(url, GURL(), PageTransition::LINK);
// The URL of a tab contents never actually changes to a JavaScript URL, so
// this check only makes sense in other cases.
- if (!new_gurl.SchemeIs(chrome::kJavaScriptScheme))
- DCHECK_EQ(new_gurl.spec(), contents->GetURL().spec());
+ if (!url.SchemeIs(chrome::kJavaScriptScheme))
+ DCHECK_EQ(url.spec(), contents->GetURL().spec());
}
bool selected = false;
@@ -1033,3 +1036,39 @@ static std::string GetWindowTypeText(Browser::Type type) {
DCHECK(type == Browser::TYPE_NORMAL);
return keys::kWindowTypeValueNormal;
}
+
+// These are histogram buckets passed to UMA in the following test of relative
+// URL use in the tabs & windows API.
+enum ExtensionAPIRelativeURLUse {
+ ABSOLUTE_URL,
+ RELATIVE_URL_RESOLUTIONS_DIFFER,
+ RELATIVE_URL_RESOLUTIONS_AGREE,
+ EXTENSION_API_RELATIVE_URL_USE_MAX_VALUE
+};
+
+static GURL ResolvePossiblyRelativeURL(std::string url_string,
+ Extension* extension,
+ const GURL& source_url) {
+ ExtensionAPIRelativeURLUse use_type = ABSOLUTE_URL;
+
+ GURL url = GURL(url_string);
+ if (!url.is_valid()) {
+ url = extension->GetResourceURL(url_string);
+ GURL resolved_url = source_url.Resolve(url_string);
+
+ // Note: It's possible that GetResourceURL() returned an invalid URL
+ // meaning that the url_string contained some kind of invalid characters.
+ // The first test for url.is_valid on the next line puts this case into
+ // the resolutions agree bucket -- in the sense that both resolutions would
+ // have resulted in an invald URL and thus an error being returned to the
+ // caller.
+ use_type = url.is_valid() && (url != resolved_url) ?
+ RELATIVE_URL_RESOLUTIONS_DIFFER : RELATIVE_URL_RESOLUTIONS_AGREE;
+ }
+
+ UMA_HISTOGRAM_ENUMERATION("Extensions.APIUse_RelativeURL", use_type,
+ EXTENSION_API_RELATIVE_URL_USE_MAX_VALUE);
+
+ return url;
+}
+
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 9e9ba28..19414a0 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -81,11 +81,12 @@ void BalloonHost::RendererGone(RenderViewHost* render_view_host) {
void BalloonHost::ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback) {
if (extension_function_dispatcher_.get()) {
extension_function_dispatcher_->HandleRequest(
- message, content, request_id, has_callback);
+ message, content, source_url, request_id, has_callback);
}
}
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index 42cd0e0..8cc397c 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -67,6 +67,7 @@ class BalloonHost : public RenderViewHostDelegate,
}
virtual void ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback);
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index ddc754f..9f70534 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1217,7 +1217,8 @@ void RenderViewHost::OnMsgDomOperationResponse(
}
void RenderViewHost::OnMsgDOMUISend(
- const std::string& message, const std::string& content) {
+ const GURL& source_url, const std::string& message,
+ const std::string& content) {
if (!ChildProcessSecurityPolicy::GetInstance()->
HasDOMUIBindings(process()->id())) {
NOTREACHED() << "Blocked unauthorized use of DOMUIBindings.";
@@ -1240,7 +1241,7 @@ void RenderViewHost::OnMsgDOMUISend(
}
}
- delegate_->ProcessDOMUIMessage(message, value.get(),
+ delegate_->ProcessDOMUIMessage(message, value.get(), source_url,
kRequestId, kHasCallback);
}
@@ -1740,6 +1741,7 @@ void RenderViewHost::OnRequestNotificationPermission(
void RenderViewHost::OnExtensionRequest(const std::string& name,
const ListValue& args_holder,
+ const GURL& source_url,
int request_id,
bool has_callback) {
if (!ChildProcessSecurityPolicy::GetInstance()->
@@ -1759,7 +1761,8 @@ void RenderViewHost::OnExtensionRequest(const std::string& name,
return;
}
- delegate_->ProcessDOMUIMessage(name, args, request_id, has_callback);
+ delegate_->ProcessDOMUIMessage(name, args, source_url, request_id,
+ has_callback);
}
void RenderViewHost::SendExtensionResponse(int request_id, bool success,
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 831c446..045acee 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -517,7 +517,8 @@ class RenderViewHost : public RenderWidgetHost {
void OnMsgDidContentsPreferredSizeChange(const gfx::Size& new_size);
void OnMsgDomOperationResponse(const std::string& json_string,
int automation_id);
- void OnMsgDOMUISend(const std::string& message,
+ void OnMsgDOMUISend(const GURL& source_url,
+ const std::string& message,
const std::string& content);
void OnMsgForwardMessageToExternalHost(const std::string& message,
const std::string& origin,
@@ -603,7 +604,9 @@ class RenderViewHost : public RenderWidgetHost {
void OnRequestNotificationPermission(const GURL& origin, int callback_id);
void OnExtensionRequest(const std::string& name, const ListValue& args,
- int request_id, bool has_callback);
+ const GURL& source_url,
+ int request_id,
+ bool has_callback);
void OnExtensionPostMessage(int port_id, const std::string& message);
void OnAccessibilityFocusChange(int acc_obj_id);
void OnAccessibilityObjectStateChange(int acc_obj_id);
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 1f93d31..332fd24 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -546,6 +546,7 @@ class RenderViewHostDelegate {
// By default we ignore such messages.
virtual void ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback) {}
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index bd9b517..cdd5d1f6 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2468,6 +2468,7 @@ void TabContents::DomOperationResponse(const std::string& json_string,
void TabContents::ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback) {
if (!render_manager_.dom_ui()) {
@@ -2476,7 +2477,8 @@ void TabContents::ProcessDOMUIMessage(const std::string& message,
render_view_host()->BlockExtensionRequest(request_id);
return;
}
- render_manager_.dom_ui()->ProcessDOMUIMessage(message, content, request_id,
+ render_manager_.dom_ui()->ProcessDOMUIMessage(message, content, source_url,
+ request_id,
has_callback);
}
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index de11dd2..b9e0f15 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -923,6 +923,7 @@ class TabContents : public PageNavigator,
int automation_id);
virtual void ProcessDOMUIMessage(const std::string& message,
const Value* content,
+ const GURL& source_url,
int request_id,
bool has_callback);
virtual void ProcessExternalHostMessage(const std::string& message,
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index b112e01..d7ea058 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1316,7 +1316,8 @@ IPC_BEGIN_MESSAGES(ViewHost)
// A message from HTML-based UI. When (trusted) Javascript calls
// send(message, args), this message is sent to the browser.
- IPC_MESSAGE_ROUTED2(ViewHostMsg_DOMUISend,
+ IPC_MESSAGE_ROUTED3(ViewHostMsg_DOMUISend,
+ GURL /* source_url */,
std::string /* message */,
std::string /* args (as a JSON string) */)
@@ -1865,9 +1866,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
// A renderer sends this message when an extension process starts an API
// request. The browser will always respond with a ViewMsg_ExtensionResponse.
- IPC_MESSAGE_ROUTED4(ViewHostMsg_ExtensionRequest,
+ IPC_MESSAGE_ROUTED5(ViewHostMsg_ExtensionRequest,
std::string /* name */,
ListValue /* argument */,
+ GURL /* source_url */,
int /* callback id */,
bool /* has_callback */)
diff --git a/chrome/renderer/dom_ui_bindings.cc b/chrome/renderer/dom_ui_bindings.cc
index 1183ceb..229cb29 100644
--- a/chrome/renderer/dom_ui_bindings.cc
+++ b/chrome/renderer/dom_ui_bindings.cc
@@ -8,6 +8,8 @@
#include "base/stl_util-inl.h"
#include "base/values.h"
#include "chrome/common/render_messages.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
DOMBoundBrowserObject::~DOMBoundBrowserObject() {
STLDeleteContainerPointers(properties_.begin(), properties_.end());
@@ -43,9 +45,15 @@ void DOMUIBindings::send(const CppArgumentList& args, CppVariant* result) {
base::JSONWriter::Write(&value, /* pretty_print= */ false, &content);
}
+ // Retrieve the source frame's url
+ GURL source_url;
+ WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext();
+ if (webframe)
+ source_url = webframe->url();
+
// Send the message up to the browser.
sender()->Send(
- new ViewHostMsg_DOMUISend(routing_id(), message, content));
+ new ViewHostMsg_DOMUISend(routing_id(), source_url, message, content));
}
void DOMBoundBrowserObject::SetProperty(const std::string& name,
diff --git a/chrome/renderer/extensions/extension_api_client_unittest.cc b/chrome/renderer/extensions/extension_api_client_unittest.cc
index 7158a8c..111c991 100644
--- a/chrome/renderer/extensions/extension_api_client_unittest.cc
+++ b/chrome/renderer/extensions/extension_api_client_unittest.cc
@@ -97,7 +97,7 @@ TEST_F(ExtensionAPIClientTest, CallbackDispatching) {
ASSERT_TRUE(request_msg);
ViewHostMsg_ExtensionRequest::Param params;
ViewHostMsg_ExtensionRequest::Read(request_msg, &params);
- int callback_id = params.c;
+ int callback_id = params.d;
ASSERT_GE(callback_id, 0);
// Now send the callback a response
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 71b77a5..3232237 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -421,6 +421,11 @@ class ExtensionImpl : public ExtensionBase {
return ExtensionProcessBindings::ThrowPermissionDeniedException(name);
}
+ GURL source_url;
+ WebFrame* webframe = WebFrame::frameForCurrentContext();
+ if (webframe)
+ source_url = webframe->url();
+
int request_id = args[2]->Int32Value();
bool has_callback = args[3]->BooleanValue();
@@ -435,7 +440,7 @@ class ExtensionImpl : public ExtensionBase {
GetPendingRequestMap()[request_id].reset(new PendingRequest(
current_context, name));
- renderview->SendExtensionRequest(name, args_holder,
+ renderview->SendExtensionRequest(name, args_holder, source_url,
request_id, has_callback);
return v8::Undefined();
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index a027d020..64403b0 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -4263,9 +4263,14 @@ void RenderView::OnWindowFrameChanged(gfx::Rect window_frame,
void RenderView::SendExtensionRequest(const std::string& name,
const ListValue& args,
+ const GURL& source_url,
int request_id,
bool has_callback) {
- Send(new ViewHostMsg_ExtensionRequest(routing_id_, name, args, request_id,
+ Send(new ViewHostMsg_ExtensionRequest(routing_id_,
+ name,
+ args,
+ source_url,
+ request_id,
has_callback));
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 963a142..ffd2ebb 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -477,7 +477,9 @@ class RenderView : public RenderWidget,
void OnClearFocusedNode();
void SendExtensionRequest(const std::string& name, const ListValue& args,
- int request_id, bool has_callback);
+ const GURL& source_url,
+ int request_id,
+ bool has_callback);
void OnExtensionResponse(int request_id, bool success,
const std::string& response,
const std::string& error);