Chromium Code Reviews| 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 a637e340b922dabbfed48b1d0a5cb392010aae00..e76d5f140c2c6729dc9bfa69a29f955edc1dde4a 100644 |
| --- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc |
| +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc |
| @@ -19,6 +19,7 @@ |
| #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| #include "chrome/browser/view_type_utils.h" |
| #include "chrome/common/chrome_notification_types.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" |
| @@ -70,11 +71,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); |
| } |
| } |
| @@ -91,11 +99,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 |
| @@ -127,9 +134,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. |
| @@ -146,11 +151,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); |
|
battre
2012/06/14 20:05:11
nit: different formatting here, in line 137, 175 a
koz (OOO until 15th September)
2012/06/15 00:07:15
Done.
|
| } |
| // Constructs and dispatches an onCompleted event. |
| @@ -167,10 +171,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); |
| + keys::kOnCompleted, args, url); |
| } |
| // Constructs and dispatches an onCreatedNavigationTarget event. |
| @@ -200,10 +202,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); |
| + browser_context, keys::kOnCreatedNavigationTarget, args, target_url); |
| } |
| // Constructs and dispatches an onErrorOccurred event. |
| @@ -221,11 +221,10 @@ 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); |
| + args, |
| + url); |
| } |
| } // namespace |