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..1fc46274fb6319314f2112d8b1e343ad8d511964 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,21 @@ 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) { |
+ std::string json_args; |
+ base::JSONWriter::Write(&args, &json_args); |
+ |
+ DictionaryValue* dict; |
+ args.GetDictionary(0, &dict); |
+ std::string url_string; |
+ dict->GetString(std::string(keys::kUrlKey), &url_string); |
+ extensions::EventFilteringInfo info; |
+ info.SetURL(GURL(url_string)); |
Matt Perry
2012/06/13 01:24:27
This feels dirty. Let's just pass the URL in as a
koz (OOO until 15th September)
2012/06/14 02:15:55
Cool, done.
|
+ |
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 +102,9 @@ 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); |
} |
// Constructs and dispatches an onCommitted or onReferenceFragmentUpdated |
@@ -127,9 +136,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); |
} |
// Constructs and dispatches an onDOMContentLoaded event. |
@@ -146,11 +153,9 @@ 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); |
} |
// Constructs and dispatches an onCompleted event. |
@@ -167,10 +172,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); |
} |
// Constructs and dispatches an onCreatedNavigationTarget event. |
@@ -200,10 +203,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); |
} |
// Constructs and dispatches an onErrorOccurred event. |
@@ -221,11 +222,9 @@ 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); |
} |
} // namespace |