| 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..b396da66a3348ef2dd3aa5f7e3ca98c51455866c 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);
|
| }
|
|
|
| // 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);
|
| + DispatchEvent(web_contents->GetBrowserContext(), 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);
|
| + DispatchEvent(browser_context, keys::kOnCreatedNavigationTarget, args,
|
| + target_url);
|
| }
|
|
|
| // Constructs and dispatches an onErrorOccurred event.
|
| @@ -221,11 +221,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
|
|
|