| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 provides --site-per-process overrides for WebView (<webview>). | 5 // This module provides --site-per-process overrides for WebView (<webview>). |
| 6 // See web_view.js for details. | 6 // See web_view.js for details. |
| 7 | 7 |
| 8 var IdGenerator = requireNative('id_generator'); | |
| 9 var WebViewImpl = require('webView').WebViewImpl; | |
| 10 // NOTE: Do not remove these, we implicitly depend on these in | 8 // NOTE: Do not remove these, we implicitly depend on these in |
| 11 // --site-per-process. | 9 // --site-per-process. |
| 12 var GuestViewIframe = require('guestViewIframe'); | 10 var GuestViewIframe = require('guestViewIframe'); |
| 13 var GuestViewIframeContainer = require('guestViewIframeContainer'); | 11 var GuestViewIframeContainer = require('guestViewIframeContainer'); |
| 14 | |
| 15 WebViewImpl.prototype.attachWindow$ = function(opt_guestInstanceId) { | |
| 16 // If |opt_guestInstanceId| was provided, then a different existing guest is | |
| 17 // being attached to this webview, and the current one will get destroyed. | |
| 18 if (opt_guestInstanceId) { | |
| 19 if (this.guest.getId() == opt_guestInstanceId) { | |
| 20 return true; | |
| 21 } | |
| 22 this.guest.destroy(); | |
| 23 this.guest = new GuestView('webview', opt_guestInstanceId); | |
| 24 } | |
| 25 | |
| 26 var generatedId = IdGenerator.GetNextId(); | |
| 27 // Generate an instance id for the container. | |
| 28 this.onInternalInstanceId(generatedId); | |
| 29 return true; | |
| 30 }; | |
| OLD | NEW |