This repository was archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 970
/
Copy pathwindowActions.js
1124 lines (1027 loc) · 31 KB
/
windowActions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict'
const {dispatch} = require('../dispatcher/appDispatcher')
const windowConstants = require('../constants/windowConstants')
const windowActions = {
/**
* Dispatches an event to the main process to replace the window state
*
* @param {object} windowState - Initial window state object
*/
setState: function (windowState) {
dispatch({
actionType: windowConstants.WINDOW_SET_STATE,
windowState
})
},
/**
* Dispatches a message to the store to let it know a page has been navigated.
*
* @param {string} location - The URL of the page that was navigated to.
* @param {number} key - The frame key to modify.
* @param {boolean} isNavigatedInPage - true if it was a navigation within the same page.
* @param {number} tabId - the tab id
*/
setNavigated: function (location, key, isNavigatedInPage, tabId) {
dispatch({
actionType: windowConstants.WINDOW_SET_NAVIGATED,
location,
key,
isNavigatedInPage,
tabId
})
},
/**
* Dispatches a message to set the security state.
* @param {Object} frameProps - The frame properties to modify.
* @param {Object} securityState - The security state properties that have
* changed.
*/
setSecurityState: function (frameProps, securityState) {
dispatch({
actionType: windowConstants.WINDOW_SET_SECURITY_STATE,
securityState,
frameProps
})
},
/**
* Dispatches a message to change the frame tabId
* @param {Object} frameProps - The frame properties
* @param {Number} oldTabId - the current tabId
* @param {Number} newTabId - the new tabId
*/
frameTabIdChanged: function (frameProps, oldTabId, newTabId) {
dispatch({
actionType: windowConstants.WINDOW_FRAME_TAB_ID_CHANGED,
frameProps,
oldTabId,
newTabId
})
},
/**
* Dispatches a message when the guestInstanceId changes for a frame
* @param {Object} frameProps - The frame properties
* @param {Number} oldGuestInstanceId - the current guestInstanceId
* @param {Number} newGuestInstanceId - the new guestInstanceId
*/
frameGuestInstanceIdChanged: function (frameProps, oldGuestInstanceId, newGuestInstanceId) {
dispatch({
actionType: windowConstants.WINDOW_FRAME_GUEST_INSTANCE_ID_CHANGED,
frameProps,
oldGuestInstanceId,
newGuestInstanceId
})
},
/**
* Dispatches a message to set the frame error state
* @param {Object} frameProps - The frame properties
* @param {Object} errorDetails - The error properties
* changed.
*/
setFrameError: function (frameProps, errorDetails) {
dispatch({
actionType: windowConstants.WINDOW_SET_FRAME_ERROR,
frameProps,
errorDetails
})
},
/**
* Shows/hides the find-in-page bar.
* @param {number} frameKey - Key of the frame that we want to modify
* @param {boolean} shown - Whether to show the find bar
*/
setFindbarShown: function (frameKey, shown) {
dispatch({
actionType: windowConstants.WINDOW_SET_FINDBAR_SHOWN,
frameKey,
shown
})
},
/**
* Highlight text in the find bar
* @param {Object} frameKey - The frame key to modify
* @param {boolean} selected - Whether to select the find bar search text
*/
setFindbarSelected: function (frameKey, selected) {
dispatch({
actionType: windowConstants.WINDOW_SET_FINDBAR_SELECTED,
frameKey,
selected
})
},
/**
* Dispatches a message to the store to indicate that the webview is loading.
*
* @param {Object} frameProps - The frame properties for the webview in question.
* @param {string} location - The location being loaded.
*/
onWebviewLoadStart: function (frameProps, location) {
dispatch({
actionType: windowConstants.WINDOW_WEBVIEW_LOAD_START,
frameProps,
location
})
},
/**
* Dispatches a message to the store to indicate that the webview is done loading.
*
* @param {Object} frameProps - The frame properties for the webview in question.
*/
onWebviewLoadEnd: function (frameProps) {
dispatch({
actionType: windowConstants.WINDOW_WEBVIEW_LOAD_END,
frameProps
})
},
/**
* Dispatches a message to the store to indicate that the webview entered full screen mode.
*
* @param {Object} frameProps - The frame properties to put in full screen
* @param {boolean} isFullScreen - true if the webview is entering full screen mode.
* @param {boolean} showFullScreenWarning - true if a warning about entering full screen should be shown.
*/
setFullScreen: function (frameProps, isFullScreen, showFullScreenWarning) {
dispatch({
actionType: windowConstants.WINDOW_SET_FULL_SCREEN,
frameProps,
isFullScreen,
showFullScreenWarning
})
},
/**
* Dispatches a message to close a frame
*
* @param {Object} frameKey - Frame key of the frame to close
*/
closeFrame: function (frameKey) {
dispatch({
actionType: windowConstants.WINDOW_CLOSE_FRAME,
frameKey
})
},
/**
* Dispatches a message to close multiple frames
* @param {Object[]} framePropsList - The properties of all frames to close
*/
closeFrames: function (framePropsList) {
dispatch({
actionType: windowConstants.WINDOW_CLOSE_FRAMES,
framePropsList
})
},
/**
* Dispatches a message to the store to undo a closed frame
* The new frame is expected to appear at the index it was last closed at
*/
undoClosedFrame: function () {
dispatch({
actionType: windowConstants.WINDOW_UNDO_CLOSED_FRAME
})
},
/**
* Dispatches a message to the store to clear closed frames
*/
clearClosedFrames: function () {
dispatch({
actionType: windowConstants.WINDOW_CLEAR_CLOSED_FRAMES
})
},
activeFrameChanged: function (frameProps) {
dispatch({
actionType: windowConstants.WINDOW_ACTIVE_FRAME_CHANGED,
frameProps: frameProps
})
},
/**
* Dispatches a message to the store when the frame is active and the window is focused
*
* @param {Object} frameProps - the frame properties for the webview in question.
*/
setFocusedFrame: function (frameProps) {
if (frameProps) {
dispatch({
actionType: windowConstants.WINDOW_SET_FOCUSED_FRAME,
frameProps: frameProps
})
}
},
/**
* Dispatches a message to the store to set a preview frame.
* This should only be called internally by `WINDOW_SET_TAB_HOVER_STATE`
* when we need to delay updating the preview frame value
*
* @param {Object} frameKey - the frame key for the webview in question.
*/
setPreviewFrame: function (frameKey) {
dispatch({
actionType: windowConstants.WINDOW_SET_PREVIEW_FRAME,
frameKey
})
},
/**
* Dispatches a message to the store to set the tab page index.
*
* @param {number} index - the tab page index to change to
*/
setTabPageIndex: function (index) {
dispatch({
actionType: windowConstants.WINDOW_SET_TAB_PAGE_INDEX,
index
})
},
/**
* Dispatches a message to the store to set the tab breakpoint.
*
* @param {Object} frameKey - the frame key for the webview in question.
* @param {string} breakpoint - the tab breakpoint to change to
*/
setTabBreakpoint: function (frameKey, breakpoint) {
dispatch({
actionType: windowConstants.WINDOW_SET_TAB_BREAKPOINT,
frameKey,
breakpoint
})
},
/**
* Dispatches a message to the store to set the current tab hover state.
*
* @param {Object} frameKey - the frame key for the webview in question.
* @param {boolean} hoverState - whether or not mouse is over tab
*/
setTabHoverState: function (frameKey, hoverState) {
dispatch({
actionType: windowConstants.WINDOW_SET_TAB_HOVER_STATE,
frameKey,
hoverState
})
},
/**
* Dispatches a message to the store to set the current tab hover state.
*
* @param {Object} tabPageIndex - the frame key for the webview in question.
* @param {boolean} hoverState - whether or not mouse is over tabPage
*/
setTabPageHoverState: function (tabPageIndex, hoverState) {
dispatch({
actionType: windowConstants.WINDOW_SET_TAB_PAGE_HOVER_STATE,
tabPageIndex,
hoverState
})
},
/**
* Dispatches a message to the store to set the tab page index being previewed.
*
* @param {number} previewTabPageIndex - The tab page index to preview
*/
setPreviewTabPageIndex: function (previewTabPageIndex) {
dispatch({
actionType: windowConstants.WINDOW_SET_PREVIEW_TAB_PAGE_INDEX,
previewTabPageIndex
})
},
/**
* Dispatches a message to the store to set the tab page index.
*
* @param {number} frameProps - The frame props to center around
*/
setTabPageIndexByFrame: function (frameProps) {
dispatch({
actionType: windowConstants.WINDOW_SET_TAB_PAGE_INDEX,
frameProps
})
},
/**
* Dispatches a message to the store to indicate that the specified frame should move locations.
*
* @param {Object} sourceFrameKey - the frame key for the webview to move.
* @param {Object} destinationFrameKey - the frame key for the webview to move to.
* @param {boolean} prepend - Whether or not to prepend to the destinationFrameProps
*/
moveTab: function (sourceFrameKey, destinationFrameKey, prepend) {
dispatch({
actionType: windowConstants.WINDOW_TAB_MOVE,
sourceFrameKey,
destinationFrameKey,
prepend
})
},
/**
* The active URL bar suggestion was clicked
* @param {boolean} isForSecondaryAction - Whether the secondary action is expected
* which happens when a modifier key is pressed.
* @param {boolean} shiftKey - Whether the shift key is being pressed
*/
activeSuggestionClicked: function (isForSecondaryAction, shiftKey) {
dispatch({
actionType: windowConstants.WINDOW_ACTIVE_URL_BAR_SUGGESTION_CLICKED,
isForSecondaryAction,
shiftKey
})
},
/**
* The previous suggestion is being selected
*/
previousUrlBarSuggestionSelected: function () {
dispatch({
actionType: windowConstants.WINDOW_PREVIOUS_URL_BAR_SUGGESTION_SELECTED
})
},
/**
* The next suggestion is being selected
*/
nextUrlBarSuggestionSelected: function () {
dispatch({
actionType: windowConstants.WINDOW_NEXT_URL_BAR_SUGGESTION_SELECTED
})
},
/**
* autocomplete for urlbar is being enabled or disabled.
* Autocomplete is defined to be the action of inserting text into the urlbar itself
* to the first item's URL match if possible. The inserted text is auto selected so
* that the next character inserted will replace it.
* This is sometimes only temporarily disabled, e.g. a user is pressing backspace.
*
* @param {boolean} enabled - true if the urlbar should autocomplete
*/
urlBarAutocompleteEnabled: function (enabled) {
dispatch({
actionType: windowConstants.WINDOW_URL_BAR_AUTOCOMPLETE_ENABLED,
enabled
})
},
/*
* Sets if we should render URL bar suggestions.
*
* @param enabled If false URL bar suggestions will not be rendered.
*/
setRenderUrlBarSuggestions: function (enabled) {
dispatch({
actionType: windowConstants.WINDOW_SET_RENDER_URL_BAR_SUGGESTIONS,
enabled
})
},
/**
* Marks the URL bar text as selected or not
*
* @param {boolean} isSelected - Whether or not the URL bar text input should be selected
*/
setUrlBarSelected: function (selected) {
dispatch({
actionType: windowConstants.WINDOW_SET_URL_BAR_SELECTED,
selected
})
},
/**
* Marks the URL bar as active or not.
* If the URL bar is active that means it's in a position that it should be displaying
* autocomplete. It may choose not to display autocomplete and still be active if there
* are no autocomplete results.
*
* @param {boolean} isActive - Whether or not the URL bar should be marked as active
*/
setUrlBarActive: function (isActive) {
dispatch({
actionType: windowConstants.WINDOW_SET_URL_BAR_ACTIVE,
isActive
})
},
urlBarOnFocus: function (windowId) {
dispatch({
actionType: windowConstants.WINDOW_URL_BAR_ON_FOCUS,
windowId
})
},
urlBarOnBlur: function (windowId, targetValue, locationValue, fromSuggestion) {
dispatch({
actionType: windowConstants.WINDOW_URL_BAR_ON_BLUR,
windowId,
targetValue,
locationValue,
fromSuggestion
})
},
tabOnFocus: function (tabId) {
dispatch({
actionType: windowConstants.WINDOW_TAB_ON_FOCUS,
tabId
})
},
/**
* Dispatches a message to the store to indicate that the pending frame shortcut info should be updated.
*
* @param {Object} frameProps - Properties of the frame in question
* @param {string} activeShortcut - The text for the new shortcut. Usually this is null to clear info which was previously
* set from an IPC call.
* @param {string} activeShortcutDetails - Parameters for the shortcut action
*/
frameShortcutChanged: function (frameProps, activeShortcut, activeShortcutDetails) {
dispatch({
actionType: windowConstants.WINDOW_FRAME_SHORTCUT_CHANGED,
frameProps,
activeShortcut,
activeShortcutDetails
})
},
/**
* Dispatches a message to set the find-in-page details.
* @param {Object} frameKey - Frame key of the frame in question
* @param {Object} findDetail - the find details
*/
setFindDetail: function (frameKey, findDetail) {
dispatch({
actionType: windowConstants.WINDOW_SET_FIND_DETAIL,
frameKey,
findDetail
})
},
/**
* Dispatches a message to set add/edit bookmark details
* If set, also indicates that add/edit is shown
* @param {Object} currentDetail - Properties of the bookmark to change to
* @param {Object} originalDetail - Properties of the bookmark to edit
* @param {Object} destinationDetail - Will move the added bookmark to the specified position
* @param {boolean} shouldShowLocation - Whether or not to show the URL input
* @param {boolean} isBookmarkHanger - true if triggered from star icon in nav bar
*/
setBookmarkDetail: function (currentDetail, originalDetail, destinationDetail, shouldShowLocation, isBookmarkHanger) {
dispatch({
actionType: windowConstants.WINDOW_SET_BOOKMARK_DETAIL,
currentDetail,
originalDetail,
destinationDetail,
shouldShowLocation,
isBookmarkHanger
})
},
/**
* Dispatches a message to set context menu detail.
* If set, also indicates that the context menu is shown.
* @param {Object} detail - The context menu detail
*/
setContextMenuDetail: function (detail) {
dispatch({
actionType: windowConstants.WINDOW_SET_CONTEXT_MENU_DETAIL,
detail
})
},
/**
* Dispatches a message to set popup window detail.
* If set, also indicates that the popup window is shown.
* @param {Object} detail - The popup window detail
*/
setPopupWindowDetail: function (detail) {
dispatch({
actionType: windowConstants.WINDOW_SET_POPUP_WINDOW_DETAIL,
detail
})
},
/**
* Dispatches a message to indicate that the frame should be muted
*
* @param {number} frameKey - Key of the frame in question
* @param {number} tabId - Id of the tab in question
* @param {boolean} muted - true if the frame is muted
*/
setAudioMuted: function (frameKey, tabId, muted) {
dispatch({
actionType: windowConstants.WINDOW_SET_AUDIO_MUTED,
frameKey,
tabId,
muted
})
},
/**
* Dispatches a mute/unmute call to all frames in a provided list.
*
* @param {Object} frameList - List of frames to consider (frameKey and tabId)
*/
muteAllAudio: function (frameList) {
dispatch({
actionType: windowConstants.WINDOW_SET_ALL_AUDIO_MUTED,
frameList
})
},
/**
* Dispatches a message to indicate that audio is playing
*
* @param {Object} frameProps - Properties of the frame in question
* @param {boolean} audioPlaybackActive - true if audio is playing in the frame
*/
setAudioPlaybackActive: function (frameProps, audioPlaybackActive) {
dispatch({
actionType: windowConstants.WINDOW_SET_AUDIO_PLAYBACK_ACTIVE,
frameProps,
audioPlaybackActive
})
},
/**
* Dispatches a message to indicate that the theme color has changed for a page
*
* @param {Object} frameProps - Properties of the frame in question
* @param {string} themeColor - Theme color of the frame
* @param {string} computedThemeColor - Computed theme color of the
* frame which is used if no frame color is present
*/
setThemeColor: function (frameProps, themeColor, computedThemeColor) {
dispatch({
actionType: windowConstants.WINDOW_SET_THEME_COLOR,
frameProps,
themeColor,
computedThemeColor
})
},
/**
* Dispatches a message to indicate that the favicon has changed
*
* @param {Object} frameProps - Properties of the frame in question
* @param {string} favicon - A url to the favicon to use
*/
setFavicon: function (frameProps, favicon) {
dispatch({
actionType: windowConstants.WINDOW_SET_FAVICON,
frameProps,
favicon
})
},
/**
* Dispatches a message to store the last zoom percentage.
* This is mainly just used to trigger updates throughout React.
*
* @param {object} frameProps - The frame to set blocked info on
* @param {number} percentage - The new zoom percentage
*/
setLastZoomPercentage: function (frameProps, percentage) {
dispatch({
actionType: windowConstants.WINDOW_SET_LAST_ZOOM_PERCENTAGE,
frameProps,
percentage
})
},
/**
* Saves the position of the window in the window state
* @param {Array} position - [x, y]
*/
savePosition: function (position) {
dispatch({
actionType: windowConstants.WINDOW_SAVE_POSITION,
position
})
},
/**
* Dispatches a message to indicate if the mouse is in the titlebar
*
* @param {boolean} mouseInTitlebar - true if the mouse is in the titlebar
*/
setMouseInTitlebar: function (mouseInTitlebar) {
dispatch({
actionType: windowConstants.WINDOW_SET_MOUSE_IN_TITLEBAR,
mouseInTitlebar
})
},
/**
* Dispatches a message to indicate the site info, such as # of blocked ads, should be shown
*
* @param {boolean} isVisible - true if the site info should be shown
*/
setSiteInfoVisible: function (isVisible) {
dispatch({
actionType: windowConstants.WINDOW_SET_SITE_INFO_VISIBLE,
isVisible
})
},
/**
* Dispatches a message to indicate the bravery panel should be shown
*
* @param {Object} braveryPanelDetail - Details about how to show the bravery panel.
* Set to undefined to hide the panel. See state documentation for more info.
*/
setBraveryPanelDetail: function (braveryPanelDetail) {
dispatch({
actionType: windowConstants.WINDOW_SET_BRAVERY_PANEL_DETAIL,
braveryPanelDetail
})
},
/**
* Dispatches a message to indicate if the downloads toolbar is visible
*
* @param {boolean} isVisible - true if the site info should be shown
*/
setDownloadsToolbarVisible: function (isVisible) {
dispatch({
actionType: windowConstants.WINDOW_SET_DOWNLOADS_TOOLBAR_VISIBLE,
isVisible
})
},
/**
* Dispatches a message to indicate the release notes should be visible
*
* @param {boolean} isVisible - true if the site info should be shown
*/
setReleaseNotesVisible: function (isVisible) {
dispatch({
actionType: windowConstants.WINDOW_SET_RELEASE_NOTES_VISIBLE,
isVisible
})
},
/**
* Dispatches a message to indicate the href preview should be shown
* for a hovered link
* @param {string} href - the href of the link
* @param {boolean} showOnRight - display in the right corner
*/
setLinkHoverPreview: function (href, showOnRight) {
dispatch({
actionType: windowConstants.WINDOW_SET_LINK_HOVER_PREVIEW,
href,
showOnRight
})
},
/**
* Dispatches a message to indicate the site info, such as # of blocked ads, should be shown
*
* @param {object} frameProps - The frame to set blocked info on
* @param {string} blockType - type of the block
* @param {string} location - URL that was blocked
*/
setBlockedBy: function (frameProps, blockType, location) {
dispatch({
actionType: windowConstants.WINDOW_SET_BLOCKED_BY,
frameProps,
blockType,
location
})
},
/**
* Similar to setBlockedBy but for httpse redirects
* @param {Object} frameProps - The frame to set blocked info on
* @param {string} ruleset - Name of the HTTPS Everywhere ruleset XML file
* @param {string} location - URL that was redirected
*/
setRedirectedBy: function (frameProps, ruleset, location) {
dispatch({
actionType: windowConstants.WINDOW_SET_REDIRECTED_BY,
frameProps,
ruleset,
location
})
},
/**
* Sets/toggles whether the noscriptinfo dialog is visible.
* @param {boolean=} isVisible - if undefined, toggle the current state
*/
setNoScriptVisible: function (isVisible) {
dispatch({
actionType: windowConstants.WINDOW_SET_NOSCRIPT_VISIBLE,
isVisible
})
},
/**
* Adds a history entry
* @param {Object} frameProps - The frame properties to change history for.
*/
addHistory: function (frameProps) {
dispatch({
actionType: windowConstants.WINDOW_ADD_HISTORY,
frameProps
})
},
/**
* Sets whether the clear browsing data popup is visible
* @param {boolean} isVisible
*/
setClearBrowsingDataPanelVisible: function (isVisible) {
dispatch({
actionType: windowConstants.WINDOW_SET_CLEAR_BROWSING_DATA_VISIBLE,
isVisible
})
},
/**
* Sets the import browser data popup detail
* @param {Array} importBrowserDataDetail - list of supported browsers
*/
setImportBrowserDataDetail: function (importBrowserDataDetail) {
dispatch({
actionType: windowConstants.WINDOW_SET_IMPORT_BROWSER_DATA_DETAIL,
importBrowserDataDetail
})
},
/**
* Sets the selected import browser data
* @param {Object} selected - selected browser data to import
*/
setImportBrowserDataSelected: function (selected) {
dispatch({
actionType: windowConstants.WINDOW_SET_IMPORT_BROWSER_DATA_SELECTED,
selected
})
},
widevineSiteAccessedWithoutInstall: function () {
dispatch({
actionType: windowConstants.WINDOW_WIDEVINE_SITE_ACCESSED_WITHOUT_INSTALL
})
},
/**
* Widevine popup detail changed
* @param {Object} widevinePanelDetail - detail of the widevine panel
*/
widevinePanelDetailChanged: function (widevinePanelDetail) {
dispatch({
actionType: windowConstants.WINDOW_WIDEVINE_PANEL_DETAIL_CHANGED,
widevinePanelDetail
})
},
/**
* Sets the manage autofill address popup detail
* @param {string} property - Property that we want change
* @param {string} newValue - New value for this property
* @param {Object} wholeObject - Whole object of address detail
*/
setAutofillAddressDetail: function (property, newValue, wholeObject) {
dispatch({
actionType: windowConstants.WINDOW_SET_AUTOFILL_ADDRESS_DETAIL,
property,
newValue,
wholeObject
})
},
/**
* Sets the manage autofill credit card popup detail
* @param {string} property - Property that we want change
* @param {string} newValue - New value for this property
* @param {Object} wholeObject - Whole object of credit card detail
*/
setAutofillCreditCardDetail: function (property, newValue, wholeObject) {
dispatch({
actionType: windowConstants.WINDOW_SET_AUTOFILL_CREDIT_CARD_DETAIL,
property,
newValue,
wholeObject
})
},
/**
* Sets source of blocked active mixed content.
* @param {Object} frameProps - The frame to set source of
* blocked active mixed content on
* @param {string} source - Source of blocked active mixed content
*/
setBlockedRunInsecureContent: function (frameProps, source) {
dispatch({
actionType: windowConstants.WINDOW_SET_BLOCKED_RUN_INSECURE_CONTENT,
frameProps,
source
})
},
/**
* (Windows only)
* Dispatches a message to indicate the custom rendered Menubar should be toggled (shown/hidden)
* @param {boolean} isVisible (optional)
*/
toggleMenubarVisible: function (isVisible) {
dispatch({
actionType: windowConstants.WINDOW_TOGGLE_MENUBAR_VISIBLE,
isVisible
})
},
/**
* (Windows only)
* Used to trigger the click() action for a menu
* Called from the Menubar control, handled in menu.js
* @param {string} label - text of the label that was clicked
*/
clickMenubarSubmenu: function (label) {
dispatch({
actionType: windowConstants.WINDOW_CLICK_MENUBAR_SUBMENU,
label
})
},
/**
* Used by `main.js` when click happens on content area (not on a link or react control).
* - closes context menu
* - closes popup menu
* - nulls out menubar item selected (Windows only)
* - hides menubar if auto-hide preference is set (Windows only)
*/
resetMenuState: function () {
dispatch({
actionType: windowConstants.WINDOW_RESET_MENU_STATE
})
},
/**
* (Windows only)
* Used to track selected index of a menu bar
* Needed because arrow keys can be used to navigate the custom menu
* @param {number} index - zero based index of the item.
* Index excludes menu separators and hidden items.
*/
setMenuBarSelectedIndex: function (index) {
dispatch({
actionType: windowConstants.WINDOW_SET_MENUBAR_SELECTED_INDEX,
index
})
},
/**
* Used to track selected index of a context menu
* Needed because arrow keys can be used to navigate the context menu
* @param {number} index - zero based index of the item.
* Index excludes menu separators and hidden items.
*/
setContextMenuSelectedIndex: function (index) {
dispatch({
actionType: windowConstants.WINDOW_SET_CONTEXT_MENU_SELECTED_INDEX,
index
})
},
/**
* (Windows only at the moment)
* Used to track last selected element (typically the URL bar or the frame)
* Important because focus is lost when using the custom menu and needs
* to be returned in order for the cut/copy operation to work
* @param {string} selector - selector used w/ querySelectorAll to return focus
* after a menu item is selected (via the custom titlebar / menubar)
*/
setLastFocusedSelector: function (selector) {
dispatch({
actionType: windowConstants.WINDOW_SET_LAST_FOCUSED_SELECTOR,
selector
})
},
/**
* Used to get response details (such as the HTTP response code) from a response
* See `eventStore.js` for an example use-case
* @param {number} tabId - the tab id to set
* @param {Object} details - object containing response details
*/
gotResponseDetails: function (tabId, details) {
dispatch({
actionType: windowConstants.WINDOW_GOT_RESPONSE_DETAILS,
tabId,
details
})
},
/**
* Fired when the mouse clicks or hovers over a bookmark folder in the bookmarks toolbar
* @param {number} folderId - from the siteDetail for the bookmark folder
* If set to null, no menu is open. If set to -1, mouse is over a bookmark, not a folder
*/
setBookmarksToolbarSelectedFolderId: function (folderId) {
dispatch({
actionType: windowConstants.WINDOW_SET_BOOKMARKS_TOOLBAR_SELECTED_FOLDER_ID,
folderId
})
},
/**
* Set Modal Dialog detail
* @param {string} className - name of modal dialog
* @param {Object} props - properties of the modal dialog
*/
setModalDialogDetail: function (className, props) {
dispatch({
actionType: windowConstants.WINDOW_SET_MODAL_DIALOG_DETAIL,
className,
props
})
},
autofillSelectionClicked: function (tabId, value, frontEndId, index) {
dispatch({
actionType: windowConstants.WINDOW_AUTOFILL_SELECTION_CLICKED,
tabId,
value,
frontEndId,
index
})
},
autofillPopupHidden: function (tabId, notify = false) {
dispatch({
actionType: windowConstants.WINDOW_AUTOFILL_POPUP_HIDDEN,
tabId,
notify
})
},
onTabClosedWithMouse: function (data) {
dispatch({
actionType: windowConstants.WINDOW_TAB_CLOSED_WITH_MOUSE,
data
})
},
onTabMouseLeave: function (data) {
dispatch({
actionType: windowConstants.WINDOW_TAB_MOUSE_LEAVE,
data
})
},
onFrameMouseEnter: function (tabId) {
dispatch({
actionType: windowConstants.WINDOW_FRAME_MOUSE_ENTER,
tabId
})
},