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

Side by Side Diff: chrome/renderer/resources/extensions/web_view/chrome_web_view.js

Issue 1938123002: Ensure that privates are private. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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');
11 var CreateEvent = require('guestViewEvents').CreateEvent; 11 var CreateEvent = require('guestViewEvents').CreateEvent;
12 var EventBindings = require('event_bindings'); 12 var EventBindings = require('event_bindings');
13 var GuestViewInternalNatives = requireNative('guest_view_internal'); 13 var GuestViewInternalNatives = requireNative('guest_view_internal');
14 var idGeneratorNatives = requireNative('id_generator'); 14 var idGeneratorNatives = requireNative('id_generator');
15 var Utils = require('utils'); 15 var utils = require('utils');
16 var WebViewImpl = require('webView').WebViewImpl; 16 var WebViewImpl = require('webView').WebViewImpl;
17 17
18 // This is the only "webViewInternal.onClicked" named event for this renderer. 18 // This is the only "webViewInternal.onClicked" named event for this renderer.
19 // 19 //
20 // Since we need an event per <webview>, we define events with suffix 20 // Since we need an event per <webview>, we define events with suffix
21 // (subEventName) in each of the <webview>. Behind the scenes, this event is 21 // (subEventName) in each of the <webview>. Behind the scenes, this event is
22 // registered as a ContextMenusEvent, with filter set to the webview's 22 // registered as a ContextMenusEvent, with filter set to the webview's
23 // |viewInstanceId|. Any time a ContextMenusEvent is dispatched, we re-dispatch 23 // |viewInstanceId|. Any time a ContextMenusEvent is dispatched, we re-dispatch
24 // it to the subEvent's listeners. This way 24 // it to the subEvent's listeners. This way
25 // <webview>.contextMenus.onClicked behave as a regular chrome Event type. 25 // <webview>.contextMenus.onClicked behave as a regular chrome Event type.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 WebViewContextMenusImpl.prototype.removeAll = function() { 115 WebViewContextMenusImpl.prototype.removeAll = function() {
116 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments)); 116 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments));
117 return $Function.apply(ChromeWebView.contextMenusRemoveAll, null, args); 117 return $Function.apply(ChromeWebView.contextMenusRemoveAll, null, args);
118 }; 118 };
119 119
120 WebViewContextMenusImpl.prototype.update = function() { 120 WebViewContextMenusImpl.prototype.update = function() {
121 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments)); 121 var args = $Array.concat([this.viewInstanceId_], $Array.slice(arguments));
122 return $Function.apply(ChromeWebView.contextMenusUpdate, null, args); 122 return $Function.apply(ChromeWebView.contextMenusUpdate, null, args);
123 }; 123 };
124 124
125 var WebViewContextMenus = Utils.expose( 125 function WebViewContextMenus() {
126 'WebViewContextMenus', WebViewContextMenusImpl, 126 privates(WebViewContextMenus).constructPrivate(this, arguments);
127 { functions: ['create', 'remove', 'removeAll', 'update'] }); 127 }
128 utils.expose(WebViewContextMenus, WebViewContextMenusImpl, {
129 functions: [
130 'create',
131 'remove',
132 'removeAll',
133 'update',
134 ],
135 });
128 136
129 // ----------------------------------------------------------------------------- 137 // -----------------------------------------------------------------------------
130 138
131 WebViewImpl.prototype.maybeSetupContextMenus = function() { 139 WebViewImpl.prototype.maybeSetupContextMenus = function() {
132 if (!this.contextMenusOnContextMenuEvent_) { 140 if (!this.contextMenusOnContextMenuEvent_) {
133 var eventName = 'chromeWebViewInternal.onContextMenuShow'; 141 var eventName = 'chromeWebViewInternal.onContextMenuShow';
134 var eventSchema = 142 var eventSchema =
135 Utils.lookup(ChromeWebViewSchema.events, 'name', 'onShow'); 143 utils.lookup(ChromeWebViewSchema.events, 'name', 'onShow');
136 var eventOptions = {supportsListeners: true}; 144 var eventOptions = {supportsListeners: true};
137 this.contextMenusOnContextMenuEvent_ = new ContextMenusOnContextMenuEvent( 145 this.contextMenusOnContextMenuEvent_ = new ContextMenusOnContextMenuEvent(
138 this.viewInstanceId, eventName, eventSchema, eventOptions); 146 this.viewInstanceId, eventName, eventSchema, eventOptions);
139 } 147 }
140 148
141 var createContextMenus = function() { 149 var createContextMenus = function() {
142 return this.weakWrapper(function() { 150 return this.weakWrapper(function() {
143 if (this.contextMenus_) { 151 if (this.contextMenus_) {
144 return this.contextMenus_; 152 return this.contextMenus_;
145 } 153 }
146 154
147 this.contextMenus_ = new WebViewContextMenus(this.viewInstanceId); 155 this.contextMenus_ = new WebViewContextMenus(this.viewInstanceId);
148 156
149 // Define 'onClicked' event property on |this.contextMenus_|. 157 // Define 'onClicked' event property on |this.contextMenus_|.
150 var getOnClickedEvent = function() { 158 var getOnClickedEvent = function() {
151 return this.weakWrapper(function() { 159 return this.weakWrapper(function() {
152 if (!this.contextMenusOnClickedEvent_) { 160 if (!this.contextMenusOnClickedEvent_) {
153 var eventName = 'chromeWebViewInternal.onClicked'; 161 var eventName = 'chromeWebViewInternal.onClicked';
154 var eventSchema = 162 var eventSchema =
155 Utils.lookup(ChromeWebViewSchema.events, 'name', 'onClicked'); 163 utils.lookup(ChromeWebViewSchema.events, 'name', 'onClicked');
156 var eventOptions = {supportsListeners: true}; 164 var eventOptions = {supportsListeners: true};
157 var onClickedEvent = new ContextMenusOnClickedEvent( 165 var onClickedEvent = new ContextMenusOnClickedEvent(
158 this.viewInstanceId, eventName, eventSchema, eventOptions); 166 this.viewInstanceId, eventName, eventSchema, eventOptions);
159 this.contextMenusOnClickedEvent_ = onClickedEvent; 167 this.contextMenusOnClickedEvent_ = onClickedEvent;
160 return onClickedEvent; 168 return onClickedEvent;
161 } 169 }
162 return this.contextMenusOnClickedEvent_; 170 return this.contextMenusOnClickedEvent_;
163 }); 171 });
164 }.bind(this); 172 }.bind(this);
165 $Object.defineProperty( 173 $Object.defineProperty(
(...skipping 21 matching lines...) Expand all
187 'contextMenus', 195 'contextMenus',
188 { 196 {
189 get: createContextMenus(), 197 get: createContextMenus(),
190 enumerable: true 198 enumerable: true
191 }); 199 });
192 }; 200 };
193 201
194 function GetUniqueSubEventName(eventName) { 202 function GetUniqueSubEventName(eventName) {
195 return eventName + '/' + idGeneratorNatives.GetNextId(); 203 return eventName + '/' + idGeneratorNatives.GetNextId();
196 } 204 }
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/platform_keys/subtle_crypto.js ('k') | extensions/renderer/module_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698