@@ -139,12 +139,13 @@ extension PhotonActionSheetProtocol {
139
139
toggleActionTitle = tab. changedUserAgent ? Strings . Menu. ViewMobileSiteTitleString : Strings . Menu. ViewDesktopSiteTitleString
140
140
}
141
141
142
- let toggleDesktopSite = PhotonActionSheetItem ( title: toggleActionTitle, iconString: " menu-RequestDesktopSite " , isEnabled: tab. changedUserAgent, badgeIconNamed: " menuBadge " ) { action in
142
+ let toggleDesktopSite = PhotonActionSheetItem ( title: toggleActionTitle, iconString: " menu-RequestDesktopSite " , isEnabled: tab. changedUserAgent, accessory : . Switch , badgeIconNamed: " menuBadge " ) { action in
143
143
if let url = tab. url {
144
144
tab. toggleChangeUserAgent ( )
145
145
Tab . ChangeUserAgent. updateDomainList ( forUrl: url, isChangedUA: tab. changedUserAgent, isPrivate: tab. isPrivate)
146
146
}
147
147
}
148
+ var domainActions = [ toggleDesktopSite]
148
149
149
150
let bookmarkPage = PhotonActionSheetItem ( title: Strings . Menu. AddBookmarkTitleString, iconString: " menu-Bookmark " ) { action in
150
151
guard let url = tab. canonicalURL? . displayURL,
@@ -192,25 +193,7 @@ extension PhotonActionSheetProtocol {
192
193
} . uponQueue ( . main) { _ in }
193
194
}
194
195
195
- let sharePage = PhotonActionSheetItem ( title: Strings . Menu. SharePageTitleString, iconString: " action_share " ) { action in
196
- guard let url = tab. canonicalURL? . displayURL else { return }
197
-
198
- if let temporaryDocument = tab. temporaryDocument {
199
- temporaryDocument. getURL ( ) . uponQueue ( . main, block: { tempDocURL in
200
- // If we successfully got a temp file URL, share it like a downloaded file,
201
- // otherwise present the ordinary share menu for the web URL.
202
- if tempDocURL. isFileURL {
203
- self . share ( fileURL: tempDocURL, buttonView: buttonView, presentableVC: presentableVC)
204
- } else {
205
- presentShareMenu ( url, tab, buttonView, . up)
206
- }
207
- } )
208
- } else {
209
- presentShareMenu ( url, tab, buttonView, . up)
210
- }
211
- }
212
-
213
- var mainActions = [ sharePage]
196
+ var mainActions = [ PhotonActionSheetItem] ( )
214
197
215
198
// Disable bookmarking if the URL is too long.
216
199
if !tab. urlIsTooLong {
@@ -222,8 +205,6 @@ extension PhotonActionSheetProtocol {
222
205
223
206
let refreshPage = self . refreshPageItem ( )
224
207
225
- var domainActions = [ toggleDesktopSite]
226
-
227
208
if let isReaderModeEnabled = isReaderModeEnabled {
228
209
let readerModeAction = PhotonActionSheetItem ( title: Strings . Menu. ReaderModeTitleString, iconString: " reader " , isEnabled: isReaderModeEnabled, accessory: . Switch, badgeIconNamed: " menuBadge " ) { ( item) in
229
210
tab. toggleChangeReaderMode ( )
@@ -232,6 +213,23 @@ extension PhotonActionSheetProtocol {
232
213
domainActions. append ( readerModeAction)
233
214
}
234
215
216
+ if let url = tab. url {
217
+ let popupsBlocking = PhotonActionSheetItem (
218
+ title: Strings . PrivacyDashboard. Switch. PopupsBlocking,
219
+ iconString: " menu-PopupBlocking " ,
220
+ isEnabled: !ContentBlocker. shared. isPopupsWhitelisted ( url: url) ,
221
+ accessory: . Switch
222
+ ) { action in
223
+ ContentBlocker . shared. popupsWhitelist (
224
+ enable: !ContentBlocker. shared. isPopupsWhitelisted ( url: url) ,
225
+ url: url
226
+ ) {
227
+ tab. reload ( )
228
+ }
229
+ }
230
+ domainActions. append ( popupsBlocking)
231
+ }
232
+
235
233
var commonActions = [ refreshPage]
236
234
237
235
// Disable find in page if document is pdf.
@@ -242,7 +240,26 @@ extension PhotonActionSheetProtocol {
242
240
commonActions. insert ( findInPageAction, at: 0 )
243
241
}
244
242
245
- return [ mainActions, domainActions, commonActions]
243
+ let sharePage = PhotonActionSheetItem ( title: Strings . Menu. SharePageTitleString, iconString: " action_share " ) { action in
244
+ guard let url = tab. canonicalURL? . displayURL else { return }
245
+
246
+ if let temporaryDocument = tab. temporaryDocument {
247
+ temporaryDocument. getURL ( ) . uponQueue ( . main, block: { tempDocURL in
248
+ // If we successfully got a temp file URL, share it like a downloaded file,
249
+ // otherwise present the ordinary share menu for the web URL.
250
+ if tempDocURL. isFileURL {
251
+ self . share ( fileURL: tempDocURL, buttonView: buttonView, presentableVC: presentableVC)
252
+ } else {
253
+ presentShareMenu ( url, tab, buttonView, . up)
254
+ }
255
+ } )
256
+ } else {
257
+ presentShareMenu ( url, tab, buttonView, . up)
258
+ }
259
+ }
260
+
261
+ commonActions. append ( sharePage)
262
+ return [ mainActions, domainActions, [ PhotonActionSheetItem ( title: " " , collectionItems: commonActions) ] ]
246
263
}
247
264
248
265
func fetchBookmarkStatus( for url: String ) -> Deferred < Maybe < Bool > > {
@@ -366,21 +383,7 @@ extension PhotonActionSheetProtocol {
366
383
}
367
384
}
368
385
369
- let popupsBlocking = PhotonActionSheetItem (
370
- title: Strings . PrivacyDashboard. Switch. PopupsBlocking,
371
- iconString: " menu-PopupBlocking " ,
372
- isEnabled: !ContentBlocker. shared. isPopupsWhitelisted ( url: currentURL) ,
373
- accessory: . Switch
374
- ) { action in
375
- ContentBlocker . shared. popupsWhitelist (
376
- enable: !ContentBlocker. shared. isPopupsWhitelisted ( url: currentURL) ,
377
- url: currentURL
378
- ) {
379
- tab. reload ( )
380
- }
381
- }
382
-
383
- return [ trackingProtection, adBlocking, popupsBlocking]
386
+ return [ trackingProtection, adBlocking]
384
387
}
385
388
386
389
@available ( iOS 11 . 0 , * )
0 commit comments