| // Copyright 2023 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #import "ios/chrome/browser/ui/main/wrangled_browser.h" |
| |
| #import "base/check.h" |
| #import "ios/chrome/browser/shared/model/browser/browser.h" |
| #import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h" |
| #import "ios/chrome/browser/ui/browser_view/browser_coordinator.h" |
| #import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" |
| |
| #if !defined(__has_feature) || !__has_feature(objc_arc) |
| #error "This file requires ARC support." |
| #endif |
| |
| @interface WrangledBrowser () |
| @property(nonatomic, weak, readonly) BrowserCoordinator* coordinator; |
| @end |
| |
| @implementation WrangledBrowser |
| |
| #pragma mark - Public |
| |
| @synthesize inactiveBrowser = _inactiveBrowser; |
| |
| - (instancetype)initWithCoordinator:(BrowserCoordinator*)coordinator { |
| if (self = [super init]) { |
| DCHECK(coordinator.browser); |
| _coordinator = coordinator; |
| } |
| return self; |
| } |
| |
| - (UIViewController*)viewController { |
| return self.coordinator.viewController; |
| } |
| |
| - (BrowserViewController*)bvc { |
| return self.coordinator.viewController; |
| } |
| |
| - (id<SyncPresenter>)syncPresenter { |
| return self.coordinator; |
| } |
| |
| - (Browser*)browser { |
| return self.coordinator.browser; |
| } |
| |
| - (ChromeBrowserState*)browserState { |
| return self.browser->GetBrowserState(); |
| } |
| |
| - (BOOL)userInteractionEnabled { |
| return self.coordinator.active; |
| } |
| |
| - (void)setUserInteractionEnabled:(BOOL)userInteractionEnabled { |
| self.coordinator.active = userInteractionEnabled; |
| } |
| |
| - (BOOL)incognito { |
| return self.browserState->IsOffTheRecord(); |
| } |
| |
| - (BOOL)playingTTS { |
| return self.coordinator.playingTTS; |
| } |
| |
| - (void)setPrimary:(BOOL)primary { |
| [self.coordinator.viewController setPrimary:primary]; |
| } |
| |
| - (void)clearPresentedStateWithCompletion:(ProceduralBlock)completion |
| dismissOmnibox:(BOOL)dismissOmnibox { |
| [self.coordinator clearPresentedStateWithCompletion:completion |
| dismissOmnibox:dismissOmnibox]; |
| } |
| |
| @end |