@@ -43,6 +43,16 @@ function getFrameByIndex (windowState, i) {
43
43
return windowState . getIn ( [ 'frames' , i ] )
44
44
}
45
45
46
+ // This will eventually go away fully when we replace frameKey by tabId
47
+ function getFrameKeyByTabId ( windowState , tabId ) {
48
+ let parentFrameKey
49
+ const openerFrame = getFrameByTabId ( windowState , tabId )
50
+ if ( openerFrame ) {
51
+ parentFrameKey = openerFrame . get ( 'key' )
52
+ }
53
+ return parentFrameKey
54
+ }
55
+
46
56
function getFrameKeysByDisplayIndex ( frames ) {
47
57
let framesByDisplayIndex = [ [ ] , [ ] ]
48
58
frames . forEach ( ( frame ) => {
@@ -232,38 +242,6 @@ function getPartition (frameOpts) {
232
242
return partition
233
243
}
234
244
235
- function cloneFrame ( frameOpts , guestInstanceId , key ) {
236
- const cloneableAttributes = [
237
- 'audioMuted' ,
238
- 'canGoBack' ,
239
- 'canGoForward' ,
240
- 'icon' ,
241
- 'title' ,
242
- 'isPrivate' ,
243
- 'partitionNumber' ,
244
- 'themeColor' ,
245
- 'computedThemeColor'
246
- ]
247
- let clone = { }
248
- cloneableAttributes . forEach ( ( attr ) => {
249
- clone [ attr ] = frameOpts [ attr ]
250
- } )
251
-
252
- clone . guestInstanceId = guestInstanceId
253
- // copy the history
254
- clone . history = frameOpts . history . slice ( 0 )
255
- // location is loaded by the webcontents
256
- clone . delayedLoadUrl = frameOpts . location
257
- clone . location = 'about:blank'
258
- clone . src = 'about:blank'
259
- clone . parentFrameKey = frameOpts . key
260
- if ( frameOpts . aboutDetails !== undefined ) {
261
- clone . aboutDetails = frameOpts . aboutDetails
262
- clone . aboutDetails . frameKey = key
263
- }
264
- return clone
265
- }
266
-
267
245
/**
268
246
* Returns an object in the same format that was passed to it (ImmutableJS/POD)
269
247
* for the subset of frame data that is used for tabs.
@@ -306,7 +284,8 @@ const tabFromFrame = (frame) => {
306
284
* Adds a frame specified by frameOpts and newKey and sets the activeFrameKey
307
285
* @return Immutable top level application state ready to merge back in
308
286
*/
309
- function addFrame ( frames , tabs , frameOpts , newKey , partitionNumber , activeFrameKey , insertionIndex ) {
287
+ function addFrame ( windowState , tabs , frameOpts , newKey , partitionNumber , activeFrameKey , insertionIndex ) {
288
+ const frames = windowState . get ( 'frames' )
310
289
const url = frameOpts . location || config . defaultUrl
311
290
312
291
// delayedLoadUrl is used as a placeholder when the new frame is created
@@ -329,6 +308,13 @@ function addFrame (frames, tabs, frameOpts, newKey, partitionNumber, activeFrame
329
308
}
330
309
}
331
310
311
+ // TODO: longer term get rid of parentFrameKey completely instead of
312
+ // calculating it here.
313
+ let parentFrameKey = frameOpts . parentFrameKey
314
+ if ( frameOpts . openerTabId ) {
315
+ parentFrameKey = getFrameKeyByTabId ( windowState , frameOpts . openerTabId )
316
+ }
317
+
332
318
const frame = Immutable . fromJS ( Object . assign ( {
333
319
zoomLevel : config . zoom . defaultValue ,
334
320
audioMuted : false , // frame is muted
@@ -371,6 +357,7 @@ function addFrame (frames, tabs, frameOpts, newKey, partitionNumber, activeFrame
371
357
certDetails : null
372
358
} ,
373
359
unloaded : frameOpts . unloaded ,
360
+ parentFrameKey,
374
361
history : [ ]
375
362
} , frameOpts ) )
376
363
@@ -537,11 +524,11 @@ module.exports = {
537
524
getFramePropsIndex,
538
525
getFrameKeysByDisplayIndex,
539
526
getPartition,
540
- cloneFrame,
541
527
addFrame,
542
528
undoCloseFrame,
543
529
removeFrame,
544
530
removeOtherFrames,
545
531
tabFromFrame,
532
+ getFrameKeyByTabId,
546
533
getFrameTabPageIndex
547
534
}
0 commit comments