Index: chrome/browser/extensions/api/web_navigation/web_navigation_api.cc |
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc |
index 906294a4a4de0088ffa6056668c3052ca62ffff5..82fe920c80c7217b6126fac03f45f1dc1834f97d 100644 |
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc |
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc |
@@ -20,6 +20,7 @@ |
#include "chrome/browser/view_type_utils.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/extensions/api/web_navigation.h" |
+#include "chrome/common/extensions/event_filtering_info.h" |
#include "chrome/common/url_constants.h" |
#include "content/public/browser/resource_request_details.h" |
#include "content/public/browser/navigation_details.h" |
@@ -74,11 +75,18 @@ double MilliSecondsFromTime(const base::Time& time) { |
// Dispatches events to the extension message service. |
void DispatchEvent(BrowserContext* browser_context, |
const char* event_name, |
- const std::string& json_args) { |
+ const ListValue& args, |
+ const GURL& url) { |
+ std::string json_args; |
+ base::JSONWriter::Write(&args, &json_args); |
+ |
+ extensions::EventFilteringInfo info; |
+ info.SetURL(url); |
+ |
Profile* profile = Profile::FromBrowserContext(browser_context); |
if (profile && profile->GetExtensionEventRouter()) { |
profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
- event_name, json_args, profile, GURL()); |
+ event_name, json_args, profile, GURL(), info); |
} |
} |
@@ -95,11 +103,10 @@ void DispatchOnBeforeNavigate(WebContents* web_contents, |
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
args.Append(dict); |
- std::string json_args; |
- base::JSONWriter::Write(&args, &json_args); |
DispatchEvent(web_contents->GetBrowserContext(), |
keys::kOnBeforeNavigate, |
- json_args); |
+ args, |
+ validated_url); |
} |
// Constructs and dispatches an onCommitted or onReferenceFragmentUpdated |
@@ -131,9 +138,7 @@ void DispatchOnCommitted(const char* event_name, |
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
args.Append(dict); |
- std::string json_args; |
- base::JSONWriter::Write(&args, &json_args); |
- DispatchEvent(web_contents->GetBrowserContext(), event_name, json_args); |
+ DispatchEvent(web_contents->GetBrowserContext(), event_name, args, url); |
} |
// Constructs and dispatches an onDOMContentLoaded event. |
@@ -150,11 +155,10 @@ void DispatchOnDOMContentLoaded(WebContents* web_contents, |
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
args.Append(dict); |
- std::string json_args; |
- base::JSONWriter::Write(&args, &json_args); |
DispatchEvent(web_contents->GetBrowserContext(), |
keys::kOnDOMContentLoaded, |
- json_args); |
+ args, |
+ url); |
} |
// Constructs and dispatches an onCompleted event. |
@@ -171,10 +175,8 @@ void DispatchOnCompleted(WebContents* web_contents, |
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
args.Append(dict); |
- std::string json_args; |
- base::JSONWriter::Write(&args, &json_args); |
- DispatchEvent(web_contents->GetBrowserContext(), |
- keys::kOnCompleted, json_args); |
+ DispatchEvent(web_contents->GetBrowserContext(), keys::kOnCompleted, args, |
+ url); |
} |
// Constructs and dispatches an onCreatedNavigationTarget event. |
@@ -204,10 +206,8 @@ void DispatchOnCreatedNavigationTarget( |
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
args.Append(dict); |
- std::string json_args; |
- base::JSONWriter::Write(&args, &json_args); |
- DispatchEvent( |
- browser_context, keys::kOnCreatedNavigationTarget, json_args); |
+ DispatchEvent(browser_context, keys::kOnCreatedNavigationTarget, args, |
+ target_url); |
} |
// Constructs and dispatches an onErrorOccurred event. |
@@ -225,11 +225,8 @@ void DispatchOnErrorOccurred(WebContents* web_contents, |
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now())); |
args.Append(dict); |
- std::string json_args; |
- base::JSONWriter::Write(&args, &json_args); |
- DispatchEvent(web_contents->GetBrowserContext(), |
- keys::kOnErrorOccurred, |
- json_args); |
+ DispatchEvent(web_contents->GetBrowserContext(), keys::kOnErrorOccurred, |
+ args, url); |
} |
} // namespace |