Skip to content

Commit

Permalink
Fix #6212: CWTS options in webview need to be reflected in native set…
Browse files Browse the repository at this point in the history
…tings (#6219)

* Fix #6212: CWTS options in webview need to be reflected in native settings

* remove for loop
  • Loading branch information
garvankeeley committed Mar 5, 2020
1 parent deda15f commit bb18830
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ extension BrowserViewController: IntroViewControllerDelegate {
func getSignInOrFxASettingsVC(_ fxaOptions: FxALaunchParams? = nil, flowType: FxAPageType) -> UIViewController {
// Show the settings page if we have already signed in. If we haven't then show the signin page
guard profile.hasSyncableAccount() else {
let vc = FxAWebView(pageType: flowType)
let vc = FxAWebView(pageType: flowType, profile: profile)
vc.dismissType = .dismiss
return vc
}
Expand Down
2 changes: 1 addition & 1 deletion Client/Frontend/Settings/AppSettingsOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ConnectSetting: WithoutAccountSetting {
override var accessibilityIdentifier: String? { return "SignInToSync" }

override func onClick(_ navigationController: UINavigationController?) {
let viewController = FxAWebView(pageType: .emailLoginFlow)
let viewController = FxAWebView(pageType: .emailLoginFlow, profile: profile)
navigationController?.pushViewController(viewController, animated: true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ManageFxAccountSetting: Setting {
}

override func onClick(_ navigationController: UINavigationController?) {
let viewController = FxAWebView(pageType: .settingsPage)
let viewController = FxAWebView(pageType: .settingsPage, profile: profile)
navigationController?.pushViewController(viewController, animated: true)
}
}
Expand Down
13 changes: 9 additions & 4 deletions RustFxA/FxAWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ fileprivate enum RemoteCommand: String {
}

class FxAWebView: UIViewController, WKNavigationDelegate {
private var webView: WKWebView
var dismissType: DismissType = .dismiss
let pageType: FxAPageType

fileprivate var webView: WKWebView
fileprivate let pageType: FxAPageType
fileprivate var baseURL: URL?
private var helpBrowser: WKWebView?
fileprivate var helpBrowser: WKWebView?
fileprivate let profile: Profile

init(pageType: FxAPageType) {
init(pageType: FxAPageType, profile: Profile) {
self.pageType = pageType
self.profile = profile

let contentController = WKUserContentController()
if let path = Bundle.main.path(forResource: "FxASignIn", ofType: "js"), let source = try? String(contentsOfFile: path, encoding: .utf8) {
Expand Down Expand Up @@ -189,6 +192,8 @@ extension FxAWebView: WKScriptMessageHandler {

let auth = FxaAuthData(code: code, state: state, actionQueryParam: "signin")
RustFirefoxAccounts.shared.accountManager.finishAuthentication(authData: auth) { _ in
self.profile.syncManager.onAddedAccount()

// ask for push notification
KeychainWrapper.sharedAppContainerKeychain.removeObject(forKey: "apnsToken", withAccessibility: .afterFirstUnlock)
let center = UNUserNotificationCenter.current()
Expand Down

0 comments on commit bb18830

Please sign in to comment.