| 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 = require('chromeWebViewInternal').ChromeWebView; | 8 var ChromeWebView = require('chromeWebViewInternal').ChromeWebView; |
| 9 var ChromeWebViewSchema = | 9 var ChromeWebViewSchema = |
| 10 requireNative('schema_registry').GetSchema('chromeWebViewInternal'); | 10 requireNative('schema_registry').GetSchema('chromeWebViewInternal'); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 var WebViewContextMenus = Utils.expose( | 117 var WebViewContextMenus = Utils.expose( |
| 118 'WebViewContextMenus', WebViewContextMenusImpl, | 118 'WebViewContextMenus', WebViewContextMenusImpl, |
| 119 { functions: ['create', 'remove', 'removeAll', 'update'] }); | 119 { functions: ['create', 'remove', 'removeAll', 'update'] }); |
| 120 | 120 |
| 121 // ----------------------------------------------------------------------------- | 121 // ----------------------------------------------------------------------------- |
| 122 | 122 |
| 123 WebViewImpl.prototype.maybeSetupContextMenus = function() { | 123 WebViewImpl.prototype.maybeSetupContextMenus = function() { |
| 124 if (!this.contextMenusOnContextMenuEvent_) { | 124 if (!this.contextMenusOnContextMenuEvent_) { |
| 125 var eventName = 'chromeWebViewInternal.onContextMenuShow'; | 125 var eventName = 'chromeWebViewInternal.onContextMenuShow'; |
| 126 // TODO(lazyboy): Find event by name instead of events[1]. | 126 var eventSchema = |
| 127 var eventSchema = ChromeWebViewSchema.events[1]; | 127 Utils.lookup(ChromeWebViewSchema.events, 'name', 'onShow'); |
| 128 var eventOptions = {supportsListeners: true}; | 128 var eventOptions = {supportsListeners: true}; |
| 129 this.contextMenusOnContextMenuEvent_ = new ContextMenusOnContextMenuEvent( | 129 this.contextMenusOnContextMenuEvent_ = new ContextMenusOnContextMenuEvent( |
| 130 this, eventName, eventSchema, eventOptions, this.viewInstanceId); | 130 this, eventName, eventSchema, eventOptions, this.viewInstanceId); |
| 131 } | 131 } |
| 132 | 132 |
| 133 var createContextMenus = function() { | 133 var createContextMenus = function() { |
| 134 return function() { | 134 return function() { |
| 135 if (this.contextMenus_) { | 135 if (this.contextMenus_) { |
| 136 return this.contextMenus_; | 136 return this.contextMenus_; |
| 137 } | 137 } |
| 138 | 138 |
| 139 this.contextMenus_ = new WebViewContextMenus(this.viewInstanceId); | 139 this.contextMenus_ = new WebViewContextMenus(this.viewInstanceId); |
| 140 | 140 |
| 141 // Define 'onClicked' event property on |this.contextMenus_|. | 141 // Define 'onClicked' event property on |this.contextMenus_|. |
| 142 var getOnClickedEvent = function() { | 142 var getOnClickedEvent = function() { |
| 143 return function() { | 143 return function() { |
| 144 if (!this.contextMenusOnClickedEvent_) { | 144 if (!this.contextMenusOnClickedEvent_) { |
| 145 var eventName = 'chromeWebViewInternal.onClicked'; | 145 var eventName = 'chromeWebViewInternal.onClicked'; |
| 146 // TODO(lazyboy): Find event by name instead of events[0]. | 146 var eventSchema = |
| 147 var eventSchema = ChromeWebViewSchema.events[0]; | 147 Utils.lookup(ChromeWebViewSchema.events, 'name', 'onClicked'); |
| 148 var eventOptions = {supportsListeners: true}; | 148 var eventOptions = {supportsListeners: true}; |
| 149 var onClickedEvent = new ContextMenusOnClickedEvent( | 149 var onClickedEvent = new ContextMenusOnClickedEvent( |
| 150 eventName, eventSchema, eventOptions, this.viewInstanceId); | 150 eventName, eventSchema, eventOptions, this.viewInstanceId); |
| 151 this.contextMenusOnClickedEvent_ = onClickedEvent; | 151 this.contextMenusOnClickedEvent_ = onClickedEvent; |
| 152 return onClickedEvent; | 152 return onClickedEvent; |
| 153 } | 153 } |
| 154 return this.contextMenusOnClickedEvent_; | 154 return this.contextMenusOnClickedEvent_; |
| 155 }.bind(this); | 155 }.bind(this); |
| 156 }.bind(this); | 156 }.bind(this); |
| 157 $Object.defineProperty( | 157 $Object.defineProperty( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 179 'contextMenus', | 179 'contextMenus', |
| 180 { | 180 { |
| 181 get: createContextMenus(), | 181 get: createContextMenus(), |
| 182 enumerable: true | 182 enumerable: true |
| 183 }); | 183 }); |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 function GetUniqueSubEventName(eventName) { | 186 function GetUniqueSubEventName(eventName) { |
| 187 return eventName + '/' + idGeneratorNatives.GetNextId(); | 187 return eventName + '/' + idGeneratorNatives.GetNextId(); |
| 188 } | 188 } |
| OLD | NEW |