<commit_before>/* 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/. */

import Foundation
import Telemetry
import OnePasswordExtension

class OpenUtils: NSObject {
    private let app = UIApplication.shared
    fileprivate let selectedURL: URL
    fileprivate let browserFillIdentifier = "org.appextension.fill-browser-action"
    fileprivate let webViewController: WebViewController

    init(url: URL, webViewController: WebViewController) {
        self.selectedURL = url
        self.webViewController = webViewController
    }
    
    private var canOpenInFirefox: Bool {
        return app.canOpenURL(URL(string: "firefox://")!)
    }

    private var canOpenInChrome: Bool {
        return app.canOpenURL(URL(string: "googlechrome://")!)
    }

    func buildShareViewController(url: URL, title: String? = nil, printFormatter: UIPrintFormatter?, anchor: UIView) -> UIActivityViewController {
        var activities = [UIActivity]()
        var activityItems: [Any] = [url]
        
        activities.append(RequestDesktopActivity(url: url))

        activities.append(FindInPageActivity())

        if canOpenInFirefox {
            activities.append(OpenInFirefoxActivity(url: url))
        }

        if canOpenInChrome {
            activities.append(OpenInChromeActivity(url: url))
        }

        activities.append(OpenInSafariActivity(url: url))
        activityItems.append(self)<commit_msg>Fixes #1008: reorder action sheet items (#1020)<commit_after>/* 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/. */

import Foundation
import Telemetry
import OnePasswordExtension

class OpenUtils: NSObject {
    private let app = UIApplication.shared
    fileprivate let selectedURL: URL
    fileprivate let browserFillIdentifier = "org.appextension.fill-browser-action"
    fileprivate let webViewController: WebViewController

    init(url: URL, webViewController: WebViewController) {
        self.selectedURL = url
        self.webViewController = webViewController
    }
    
    private var canOpenInFirefox: Bool {
        return app.canOpenURL(URL(string: "firefox://")!)
    }

    private var canOpenInChrome: Bool {
        return app.canOpenURL(URL(string: "googlechrome://")!)
    }

    func buildShareViewController(url: URL, title: String? = nil, printFormatter: UIPrintFormatter?, anchor: UIView) -> UIActivityViewController {
        var activities = [UIActivity]()
        var activityItems: [Any] = [url]
        activities.append(FindInPageActivity())
        activities.append(RequestDesktopActivity(url: url))
        
        if canOpenInFirefox {
            activities.append(OpenInFirefoxActivity(url: url))
        }

        if canOpenInChrome {
            activities.append(OpenInChromeActivity(url: url))
        }

        activities.append(OpenInSafariActivity(url: url))
        activityItems.append(self)
{'fraction_non_alphanumeric': 0.08984126984126985, 'fraction_numerical': 0.005079365079365079, 'mean_word_length': 3.184594953519256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5493508', 'n_tokens_mistral': 888, 'n_tokens_neox': 855, 'n_words': 233}