| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 experimental API for <webview>. | 5 // This module implements experimental API for <webview>. |
| 6 // See web_view.js for details. | 6 // See web_view.js for details. |
| 7 // | 7 // |
| 8 // <webview> Experimental API is only available on canary and dev channels of | 8 // <webview> Experimental API is only available on canary and dev channels of |
| 9 // Chrome. | 9 // Chrome. |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // accessible to <webview> developers. | 28 // accessible to <webview> developers. |
| 29 // |customHandler| allows a handler function to be called each time an extension | 29 // |customHandler| allows a handler function to be called each time an extension |
| 30 // event is caught by its event listener. The DOM event should be dispatched | 30 // event is caught by its event listener. The DOM event should be dispatched |
| 31 // within this handler function. With no handler function, the DOM event | 31 // within this handler function. With no handler function, the DOM event |
| 32 // will be dispatched by default each time the extension event is caught. | 32 // will be dispatched by default each time the extension event is caught. |
| 33 // |cancelable| (default: false) specifies whether the event's default | 33 // |cancelable| (default: false) specifies whether the event's default |
| 34 // behavior can be canceled. If the default action associated with the event | 34 // behavior can be canceled. If the default action associated with the event |
| 35 // is prevented, then its dispatch function will return false in its event | 35 // is prevented, then its dispatch function will return false in its event |
| 36 // handler. The event must have a custom handler for this to be meaningful. | 36 // handler. The event must have a custom handler for this to be meaningful. |
| 37 var WEB_VIEW_EXPERIMENTAL_EVENTS = { | 37 var WEB_VIEW_EXPERIMENTAL_EVENTS = { |
| 38 'findupdate': { | |
| 39 evt: CreateEvent('webViewInternal.onFindReply'), | |
| 40 fields: [ | |
| 41 'searchText', | |
| 42 'numberOfMatches', | |
| 43 'activeMatchOrdinal', | |
| 44 'selectionRect', | |
| 45 'canceled', | |
| 46 'finalUpdate' | |
| 47 ] | |
| 48 }, | |
| 49 'zoomchange': { | 38 'zoomchange': { |
| 50 evt: CreateEvent('webViewInternal.onZoomChange'), | 39 evt: CreateEvent('webViewInternal.onZoomChange'), |
| 51 fields: ['oldZoomFactor', 'newZoomFactor'] | 40 fields: ['oldZoomFactor', 'newZoomFactor'] |
| 52 } | 41 } |
| 53 }; | 42 }; |
| 54 | 43 |
| 55 function GetUniqueSubEventName(eventName) { | 44 function GetUniqueSubEventName(eventName) { |
| 56 return eventName + "/" + idGeneratorNatives.GetNextId(); | 45 return eventName + "/" + idGeneratorNatives.GetNextId(); |
| 57 } | 46 } |
| 58 | 47 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return; | 189 return; |
| 201 } | 190 } |
| 202 WebView.getZoom(this.instanceId, callback); | 191 WebView.getZoom(this.instanceId, callback); |
| 203 }; | 192 }; |
| 204 | 193 |
| 205 /** @private */ | 194 /** @private */ |
| 206 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { | 195 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { |
| 207 WebView.captureVisibleRegion(this.instanceId, spec, callback); | 196 WebView.captureVisibleRegion(this.instanceId, spec, callback); |
| 208 }; | 197 }; |
| 209 | 198 |
| 210 /** @private */ | |
| 211 WebViewInternal.prototype.find = function(search_text, options, callback) { | |
| 212 if (!this.instanceId) { | |
| 213 return; | |
| 214 } | |
| 215 WebView.find(this.instanceId, search_text, options, callback); | |
| 216 }; | |
| 217 | |
| 218 /** @private */ | |
| 219 WebViewInternal.prototype.stopFinding = function(action) { | |
| 220 if (!this.instanceId) { | |
| 221 return; | |
| 222 } | |
| 223 WebView.stopFinding(this.instanceId, action); | |
| 224 }; | |
| 225 | |
| 226 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto) { | 199 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto) { |
| 227 proto.setZoom = function(zoomFactor, callback) { | 200 proto.setZoom = function(zoomFactor, callback) { |
| 228 privates(this).internal.setZoom(zoomFactor, callback); | 201 privates(this).internal.setZoom(zoomFactor, callback); |
| 229 }; | 202 }; |
| 230 | 203 |
| 231 proto.getZoom = function(callback) { | 204 proto.getZoom = function(callback) { |
| 232 return privates(this).internal.getZoom(callback); | 205 return privates(this).internal.getZoom(callback); |
| 233 }; | 206 }; |
| 234 | 207 |
| 235 proto.captureVisibleRegion = function(spec, callback) { | 208 proto.captureVisibleRegion = function(spec, callback) { |
| 236 privates(this).internal.captureVisibleRegion(spec, callback); | 209 privates(this).internal.captureVisibleRegion(spec, callback); |
| 237 }; | 210 }; |
| 238 | |
| 239 proto.find = function(search_text, options, callback) { | |
| 240 privates(this).internal.find(search_text, options, callback); | |
| 241 }; | |
| 242 | |
| 243 proto.stopFinding = function(action) { | |
| 244 privates(this).internal.stopFinding(action); | |
| 245 }; | |
| 246 }; | 211 }; |
| 247 | 212 |
| 248 /** @private */ | 213 /** @private */ |
| 249 WebViewInternal.prototype.setupExperimentalContextMenus = function() { | 214 WebViewInternal.prototype.setupExperimentalContextMenus = function() { |
| 250 var self = this; | 215 var self = this; |
| 251 var createContextMenus = function() { | 216 var createContextMenus = function() { |
| 252 return function() { | 217 return function() { |
| 253 if (self.contextMenus_) { | 218 if (self.contextMenus_) { |
| 254 return self.contextMenus_; | 219 return self.contextMenus_; |
| 255 } | 220 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 283 | 248 |
| 284 // Expose <webview>.contextMenus object. | 249 // Expose <webview>.contextMenus object. |
| 285 Object.defineProperty( | 250 Object.defineProperty( |
| 286 this.webviewNode, | 251 this.webviewNode, |
| 287 'contextMenus', | 252 'contextMenus', |
| 288 { | 253 { |
| 289 get: createContextMenus(), | 254 get: createContextMenus(), |
| 290 enumerable: true | 255 enumerable: true |
| 291 }); | 256 }); |
| 292 }; | 257 }; |
| OLD | NEW |