| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This module implements chrome-specific <webview> API. | 5 // This module implements chrome-specific <webview> API. |
| 6 // See web_view_api_methods.js for details. | 6 // See web_view_api_methods.js for details. |
| 7 | 7 |
| 8 var ChromeWebView = getInternalApi ? | 8 var ChromeWebView = getInternalApi ? |
| 9 getInternalApi('chromeWebViewInternal') : | 9 getInternalApi('chromeWebViewInternal') : |
| 10 require('chromeWebViewInternal').ChromeWebView; | 10 require('chromeWebViewInternal').ChromeWebView; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // it to the subEvent's listeners. This way | 25 // it to the subEvent's listeners. This way |
| 26 // <webview>.contextMenus.onClicked behave as a regular chrome Event type. | 26 // <webview>.contextMenus.onClicked behave as a regular chrome Event type. |
| 27 var ContextMenusEvent = CreateEvent('chromeWebViewInternal.onClicked'); | 27 var ContextMenusEvent = CreateEvent('chromeWebViewInternal.onClicked'); |
| 28 // See comment above. | 28 // See comment above. |
| 29 var ContextMenusHandlerEvent = | 29 var ContextMenusHandlerEvent = |
| 30 CreateEvent('chromeWebViewInternal.onContextMenuShow'); | 30 CreateEvent('chromeWebViewInternal.onContextMenuShow'); |
| 31 | 31 |
| 32 var jsEvent; | 32 var jsEvent; |
| 33 function createCustomEvent(name, schema, options, webviewId) { | 33 function createCustomEvent(name, schema, options, webviewId) { |
| 34 if (bindingUtil) | 34 if (bindingUtil) |
| 35 return bindingUtil.createCustomEvent(name, undefined, false); | 35 return bindingUtil.createCustomEvent(name, undefined, false, false); |
| 36 if (!jsEvent) | 36 if (!jsEvent) |
| 37 jsEvent = require('event_bindings').Event; | 37 jsEvent = require('event_bindings').Event; |
| 38 return new jsEvent(name, schema, options, webviewId); | 38 return new jsEvent(name, schema, options, webviewId); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // This event is exposed as <webview>.contextMenus.onClicked. | 41 // This event is exposed as <webview>.contextMenus.onClicked. |
| 42 function createContextMenusOnClickedEvent(webViewInstanceId, | 42 function createContextMenusOnClickedEvent(webViewInstanceId, |
| 43 opt_eventName, | 43 opt_eventName, |
| 44 opt_argSchemas, | 44 opt_argSchemas, |
| 45 opt_eventOptions) { | 45 opt_eventOptions) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ], | 139 ], |
| 140 }); | 140 }); |
| 141 | 141 |
| 142 // ----------------------------------------------------------------------------- | 142 // ----------------------------------------------------------------------------- |
| 143 | 143 |
| 144 WebViewImpl.prototype.maybeSetupContextMenus = function() { | 144 WebViewImpl.prototype.maybeSetupContextMenus = function() { |
| 145 if (!this.contextMenusOnContextMenuEvent_) { | 145 if (!this.contextMenusOnContextMenuEvent_) { |
| 146 var eventName = 'chromeWebViewInternal.onContextMenuShow'; | 146 var eventName = 'chromeWebViewInternal.onContextMenuShow'; |
| 147 var eventSchema = | 147 var eventSchema = |
| 148 utils.lookup(ChromeWebViewSchema.events, 'name', 'onShow'); | 148 utils.lookup(ChromeWebViewSchema.events, 'name', 'onShow'); |
| 149 var eventOptions = {supportsListeners: true}; | 149 var eventOptions = {supportsListeners: true, supportsLazyListeners: false}; |
| 150 this.contextMenusOnContextMenuEvent_ = createContextMenusOnContextMenuEvent( | 150 this.contextMenusOnContextMenuEvent_ = createContextMenusOnContextMenuEvent( |
| 151 this.viewInstanceId, eventName, eventSchema, eventOptions); | 151 this.viewInstanceId, eventName, eventSchema, eventOptions); |
| 152 } | 152 } |
| 153 | 153 |
| 154 var createContextMenus = $Function.bind(function() { | 154 var createContextMenus = $Function.bind(function() { |
| 155 return this.weakWrapper(function() { | 155 return this.weakWrapper(function() { |
| 156 if (this.contextMenus_) { | 156 if (this.contextMenus_) { |
| 157 return this.contextMenus_; | 157 return this.contextMenus_; |
| 158 } | 158 } |
| 159 | 159 |
| 160 this.contextMenus_ = new WebViewContextMenus(this.viewInstanceId); | 160 this.contextMenus_ = new WebViewContextMenus(this.viewInstanceId); |
| 161 | 161 |
| 162 // Define 'onClicked' event property on |this.contextMenus_|. | 162 // Define 'onClicked' event property on |this.contextMenus_|. |
| 163 var getOnClickedEvent = $Function.bind(function() { | 163 var getOnClickedEvent = $Function.bind(function() { |
| 164 return this.weakWrapper(function() { | 164 return this.weakWrapper(function() { |
| 165 if (!this.contextMenusOnClickedEvent_) { | 165 if (!this.contextMenusOnClickedEvent_) { |
| 166 var eventName = 'chromeWebViewInternal.onClicked'; | 166 var eventName = 'chromeWebViewInternal.onClicked'; |
| 167 var eventSchema = | 167 var eventSchema = |
| 168 utils.lookup(ChromeWebViewSchema.events, 'name', 'onClicked'); | 168 utils.lookup(ChromeWebViewSchema.events, 'name', 'onClicked'); |
| 169 var eventOptions = {supportsListeners: true}; | 169 var eventOptions = |
| 170 {supportsListeners: true, supportsLazyListeners: false}; |
| 170 var onClickedEvent = createContextMenusOnClickedEvent( | 171 var onClickedEvent = createContextMenusOnClickedEvent( |
| 171 this.viewInstanceId, eventName, eventSchema, eventOptions); | 172 this.viewInstanceId, eventName, eventSchema, eventOptions); |
| 172 this.contextMenusOnClickedEvent_ = onClickedEvent; | 173 this.contextMenusOnClickedEvent_ = onClickedEvent; |
| 173 return onClickedEvent; | 174 return onClickedEvent; |
| 174 } | 175 } |
| 175 return this.contextMenusOnClickedEvent_; | 176 return this.contextMenusOnClickedEvent_; |
| 176 }); | 177 }); |
| 177 }, this); | 178 }, this); |
| 178 $Object.defineProperty( | 179 $Object.defineProperty( |
| 179 this.contextMenus_, | 180 this.contextMenus_, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 198 'contextMenus', | 199 'contextMenus', |
| 199 { | 200 { |
| 200 get: createContextMenus(), | 201 get: createContextMenus(), |
| 201 enumerable: true | 202 enumerable: true |
| 202 }); | 203 }); |
| 203 }; | 204 }; |
| 204 | 205 |
| 205 function GetUniqueSubEventName(eventName) { | 206 function GetUniqueSubEventName(eventName) { |
| 206 return eventName + '/' + idGeneratorNatives.GetNextId(); | 207 return eventName + '/' + idGeneratorNatives.GetNextId(); |
| 207 } | 208 } |
| OLD | NEW |