summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
diff options
context:
space:
mode:
authordharani@chromium.org <dharani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-03 20:24:32 +0000
committerdharani@chromium.org <dharani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-03 20:24:32 +0000
commitb12b86d9a48887a9f6bfcbd3ffab408d6e3fd3b3 (patch)
tree44b3fdcdfd9858c2ac1a884181bbde6c7a245ac5 /chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
parent8cca9621a858256226dfc6d7588a2fda32ad2daf (diff)
downloadchromium_src-b12b86d9a48887a9f6bfcbd3ffab408d6e3fd3b3.zip
chromium_src-b12b86d9a48887a9f6bfcbd3ffab408d6e3fd3b3.tar.gz
chromium_src-b12b86d9a48887a9f6bfcbd3ffab408d6e3fd3b3.tar.bz2
Revert 145145 - Filtered events.
Check bug 134977 for details Makes web_navigation events support filters, eg: chrome.webNavigation.onBeforeCommitted.addListener(callback, {url: [{hostSuffix: 'google.com'}]}); Now callback will only be called when the event has a URL with a host suffix of google.com. BUG=121479 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=143872 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=143874 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=143896 Review URL: https://chromiumcodereview.appspot.com/10514013 TBR=koz@chromium.org Review URL: https://chromiumcodereview.appspot.com/10700092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/web_navigation/web_navigation_api.cc')
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_api.cc45
1 files changed, 24 insertions, 21 deletions
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 82fe920..906294a 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
@@ -20,7 +20,6 @@
#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"
@@ -75,18 +74,11 @@ double MilliSecondsFromTime(const base::Time& time) {
// Dispatches events to the extension message service.
void DispatchEvent(BrowserContext* browser_context,
const char* event_name,
- const ListValue& args,
- const GURL& url) {
- std::string json_args;
- base::JSONWriter::Write(&args, &json_args);
-
- extensions::EventFilteringInfo info;
- info.SetURL(url);
-
+ const std::string& json_args) {
Profile* profile = Profile::FromBrowserContext(browser_context);
if (profile && profile->GetExtensionEventRouter()) {
profile->GetExtensionEventRouter()->DispatchEventToRenderers(
- event_name, json_args, profile, GURL(), info);
+ event_name, json_args, profile, GURL());
}
}
@@ -103,10 +95,11 @@ 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,
- args,
- validated_url);
+ json_args);
}
// Constructs and dispatches an onCommitted or onReferenceFragmentUpdated
@@ -138,7 +131,9 @@ void DispatchOnCommitted(const char* event_name,
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
args.Append(dict);
- DispatchEvent(web_contents->GetBrowserContext(), event_name, args, url);
+ std::string json_args;
+ base::JSONWriter::Write(&args, &json_args);
+ DispatchEvent(web_contents->GetBrowserContext(), event_name, json_args);
}
// Constructs and dispatches an onDOMContentLoaded event.
@@ -155,10 +150,11 @@ 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,
- args,
- url);
+ json_args);
}
// Constructs and dispatches an onCompleted event.
@@ -175,8 +171,10 @@ void DispatchOnCompleted(WebContents* web_contents,
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
args.Append(dict);
- DispatchEvent(web_contents->GetBrowserContext(), keys::kOnCompleted, args,
- url);
+ std::string json_args;
+ base::JSONWriter::Write(&args, &json_args);
+ DispatchEvent(web_contents->GetBrowserContext(),
+ keys::kOnCompleted, json_args);
}
// Constructs and dispatches an onCreatedNavigationTarget event.
@@ -206,8 +204,10 @@ void DispatchOnCreatedNavigationTarget(
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
args.Append(dict);
- DispatchEvent(browser_context, keys::kOnCreatedNavigationTarget, args,
- target_url);
+ std::string json_args;
+ base::JSONWriter::Write(&args, &json_args);
+ DispatchEvent(
+ browser_context, keys::kOnCreatedNavigationTarget, json_args);
}
// Constructs and dispatches an onErrorOccurred event.
@@ -225,8 +225,11 @@ void DispatchOnErrorOccurred(WebContents* web_contents,
dict->SetDouble(keys::kTimeStampKey, MilliSecondsFromTime(base::Time::Now()));
args.Append(dict);
- DispatchEvent(web_contents->GetBrowserContext(), keys::kOnErrorOccurred,
- args, url);
+ std::string json_args;
+ base::JSONWriter::Write(&args, &json_args);
+ DispatchEvent(web_contents->GetBrowserContext(),
+ keys::kOnErrorOccurred,
+ json_args);
}
} // namespace