Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: extensions/renderer/resources/guest_view/extension_view_events.js

Issue 913393003: Restrict extensionview to chrome-extension:// (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/resources/guest_view/extension_view_events.js
diff --git a/extensions/renderer/resources/guest_view/extension_view_events.js b/extensions/renderer/resources/guest_view/extension_view_events.js
new file mode 100644
index 0000000000000000000000000000000000000000..a30c5fd7fdfc05bb5a3635a81a52e64d47c8e9ac
--- /dev/null
+++ b/extensions/renderer/resources/guest_view/extension_view_events.js
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Event management for ExtensionView.
+
+var EventBindings = require('event_bindings');
+
+var CreateEvent = function(name) {
+ var eventOpts = {supportsListeners: true, supportsFilters: true};
+ return new EventBindings.Event(name, undefined, eventOpts);
+};
+
+var EXTENSION_VIEW_EVENTS = {
+ 'loadcommit': {
+ handler: function(event) {
+ ExtensionViewEvents.prototype.handleLoadCommitEvent.call(this, event);
+ },
+ evt: CreateEvent('extensionViewInternal.onLoadCommit'),
+ }
+};
+
+// Constructor.
+function ExtensionViewEvents(extensionViewImpl, viewInstanceId) {
+ this.extensionViewImpl = extensionViewImpl;
+ this.viewInstanceId = viewInstanceId;
+
+ // Set up the events.
+ var events = this.getEvents();
+ for (var eventName in events) {
+ this.setupEvent(eventName, events[eventName]);
+ }
+}
+
+ExtensionViewEvents.prototype.getEvents = function() {
+ return EXTENSION_VIEW_EVENTS;
+};
+
+ExtensionViewEvents.prototype.setupEvent = function(name, info) {
+ info.evt.addListener(function(e) {
+ if (info.handler)
+ info.handler.call(this, e);
+ }.bind(this), {instanceId: this.viewInstanceId});
+};
+
+ExtensionViewEvents.prototype.handleLoadCommitEvent = function(event) {
+ this.extensionViewImpl.onLoadCommit(event.url);
+};
+
+exports.ExtensionViewEvents = ExtensionViewEvents;
« no previous file with comments | « extensions/renderer/resources/guest_view/extension_view_constants.js ('k') | tools/metrics/actions/actions.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698