Commit 5e66ebc5 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Separate LocationBarMediator and LoationBarSteadyViewMediator

This allows other coordinators to use the LocationBarSteadyViewMediator
if they want to use the LocationBarSteadyView.

Bug: 1094335
Change-Id: I6fd912f8a2d560d7f3928b2201d42c8fff2b937a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526425Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#827271}
parent a42ef11e
......@@ -13,6 +13,9 @@ source_set("location_bar") {
"location_bar_mediator.mm",
"location_bar_steady_view.h",
"location_bar_steady_view.mm",
"location_bar_steady_view_consumer.h",
"location_bar_steady_view_mediator.h",
"location_bar_steady_view_mediator.mm",
"location_bar_url_loader.h",
"location_bar_view_controller.h",
"location_bar_view_controller.mm",
......@@ -140,7 +143,7 @@ source_set("unit_tests") {
testonly = true
sources = [
"location_bar_coordinator_unittest.mm",
"location_bar_mediator_unittest.mm",
"location_bar_steady_view_mediator_unittest.mm",
]
deps = [
":location_bar",
......
......@@ -8,26 +8,9 @@
// Consumer for the location bar mediator.
@protocol LocationBarConsumer
// Notifies the consumer to update the location text.
// |clipTail| indicates whether the tail or the head should be clipped when the
// location text is too long.
- (void)updateLocationText:(NSString*)string clipTail:(BOOL)clipTail;
// Notifies the consumer to update the location icon and security status text.
- (void)updateLocationIcon:(UIImage*)icon
securityStatusText:(NSString*)statusText;
// Notifies the consumer about shareability of the current web page. Some web
// pages are not considered shareable (e.g. chrome://flags), and the share
// button for such pages should not be enabled.
- (void)updateLocationShareable:(BOOL)shareable;
// Notifies consumer to defocus the omnibox (for example on tab change).
- (void)defocusOmnibox;
// Notifies the consumer to update after a navigation to NTP. Will be called
// after -updateLocationText. Used for triggering NTP-specific location bar UI.
- (void)updateAfterNavigatingToNTP;
// Notifies the consumer to update after the search-by-image support status
// changes. (This is usually when the default search engine changes).
- (void)updateSearchByImageSupported:(BOOL)searchByImageSupported;
......
......@@ -37,7 +37,10 @@
#import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_updater.h"
#import "ios/chrome/browser/ui/infobars/infobar_feature.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_constants.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_consumer.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_mediator.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_steady_view_consumer.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_steady_view_mediator.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_url_loader.h"
#include "ios/chrome/browser/ui/location_bar/location_bar_view_controller.h"
#import "ios/chrome/browser/ui/ntp/ntp_util.h"
......@@ -69,6 +72,7 @@
LocationBarDelegate,
LocationBarViewControllerDelegate,
LocationBarConsumer,
LocationBarSteadyViewConsumer,
URLDragDataSource> {
// API endpoint for omnibox.
std::unique_ptr<WebOmniboxEditControllerImpl> _editController;
......@@ -88,6 +92,7 @@
// Coordinator for the omnibox.
@property(nonatomic, strong) OmniboxCoordinator* omniboxCoordinator;
@property(nonatomic, strong) LocationBarMediator* mediator;
@property(nonatomic, strong) LocationBarSteadyViewMediator* steadyViewMediator;
@property(nonatomic, strong) LocationBarViewController* viewController;
@property(nonatomic, readonly) ChromeBrowserState* browserState;
@property(nonatomic, readonly) WebStateList* webStateList;
......@@ -198,15 +203,19 @@
_badgeFullscreenUIUpdater = std::make_unique<FullscreenUIUpdater>(
fullscreenController, self.badgeViewController);
self.mediator = [[LocationBarMediator alloc]
initWithLocationBarModel:[self locationBarModel]];
self.mediator.webStateList = self.webStateList;
self.mediator.webContentAreaOverlayPresenter = OverlayPresenter::FromBrowser(
self.browser, OverlayModality::kWebContentArea);
self.mediator = [[LocationBarMediator alloc] init];
self.mediator.templateURLService =
ios::TemplateURLServiceFactory::GetForBrowserState(self.browserState);
self.mediator.consumer = self;
self.steadyViewMediator = [[LocationBarSteadyViewMediator alloc]
initWithLocationBarModel:[self locationBarModel]];
self.steadyViewMediator.webStateList = self.browser->GetWebStateList();
self.steadyViewMediator.webContentAreaOverlayPresenter =
OverlayPresenter::FromBrowser(self.browser,
OverlayModality::kWebContentArea);
self.steadyViewMediator.consumer = self;
_omniboxFullscreenUIUpdater = std::make_unique<FullscreenUIUpdater>(
fullscreenController, self.viewController);
......@@ -234,8 +243,9 @@
_editController.reset();
self.viewController = nil;
[self.mediator disconnect];
self.mediator = nil;
[self.steadyViewMediator disconnect];
self.steadyViewMediator = nil;
_badgeFullscreenUIUpdater = nullptr;
_omniboxFullscreenUIUpdater = nullptr;
......@@ -393,16 +403,22 @@
#pragma mark - LocationBarConsumer
- (void)defocusOmnibox {
[self cancelOmniboxEdit];
}
- (void)updateSearchByImageSupported:(BOOL)searchByImageSupported {
self.viewController.searchByImageEnabled = searchByImageSupported;
}
#pragma mark - LocationBarSteadyViewConsumer
- (void)updateLocationText:(NSString*)text clipTail:(BOOL)clipTail {
[self.omniboxCoordinator updateOmniboxState];
[self.viewController updateLocationText:text clipTail:clipTail];
[self.viewController updateForNTP:NO];
}
- (void)defocusOmnibox {
[self cancelOmniboxEdit];
}
- (void)updateLocationIcon:(UIImage*)icon
securityStatusText:(NSString*)statusText {
[self.viewController updateLocationIcon:icon securityStatusText:statusText];
......@@ -416,10 +432,6 @@
[self.viewController setShareButtonEnabled:shareable];
}
- (void)updateSearchByImageSupported:(BOOL)searchByImageSupported {
self.viewController.searchByImageEnabled = searchByImageSupported;
}
#pragma mark - URLDragDataSource
- (URLInfo*)URLInfoForView:(UIView*)view {
......
......@@ -9,29 +9,13 @@
@protocol LocationBarConsumer;
class TemplateURLService;
class WebStateList;
class OverlayPresenter;
class LocationBarModel;
// A mediator object that updates the mediator when the web state changes.
// A mediator object that updates location bar state not relating to the
// LocationBarSteadyView. In practice, this is any state not relating to the
// WebState.
@interface LocationBarMediator : NSObject
- (instancetype)initWithLocationBarModel:(LocationBarModel*)locationBarModel
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
// The WebStateList that this mediator listens for any changes on the active web
// state.
@property(nonatomic, assign) WebStateList* webStateList;
// The overlay presenter for OverlayModality::kWebContentArea. This mediator
// listens for overlay presentation events to determine whether the share button
// should be enabled.
@property(nonatomic, assign) OverlayPresenter* webContentAreaOverlayPresenter;
// The location bar model used by this mediator to extract the current URL and
// the security state.
@property(nonatomic, assign, readonly) LocationBarModel* locationBarModel;
- (instancetype)init;
// The templateURLService used by this mediator to extract whether the default
// search engine supports search-by-image.
......@@ -41,9 +25,6 @@ class LocationBarModel;
// object and may be nil.
@property(nonatomic, weak) id<LocationBarConsumer> consumer;
// Stops observing all objects.
- (void)disconnect;
@end
#endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_MEDIATOR_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_STEADY_VIEW_CONSUMER_H_
#define IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_STEADY_VIEW_CONSUMER_H_
#import <UIKit/UIKit.h>
// Consumer for the location bar steady view mediator.
@protocol LocationBarSteadyViewConsumer <NSObject>
// Notifies the consumer to update the location text.
// |clipTail| indicates whether the tail or the head should be clipped when the
// location text is too long.
- (void)updateLocationText:(NSString*)string clipTail:(BOOL)clipTail;
// Notifies the consumer to update the location icon and security status text.
- (void)updateLocationIcon:(UIImage*)icon
securityStatusText:(NSString*)statusText;
// Notifies the consumer about shareability of the current web page. Some web
// pages are not considered shareable (e.g. chrome://flags), and the share
// button for such pages should not be enabled.
- (void)updateLocationShareable:(BOOL)shareable;
// Notifies the consumer to update after a navigation to NTP. Will be called
// after -updateLocationText. Used for triggering NTP-specific location bar
// steady view UI.
- (void)updateAfterNavigatingToNTP;
@end
#endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_STEADY_VIEW_CONSUMER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_STEADY_VIEW_MEDIATOR_H_
#define IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_STEADY_VIEW_MEDIATOR_H_
#import <UIKit/UIKit.h>
class LocationBarModel;
@protocol LocationBarSteadyViewConsumer;
class OverlayPresenter;
class WebStateList;
// A mediator object that updates state relating to the LocationBarSteadyView.
// Mostly, this is any property that involves the WebState.
@interface LocationBarSteadyViewMediator : NSObject
- (instancetype)initWithLocationBarModel:(LocationBarModel*)locationBarModel
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
// The WebStateList that this mediator listens for any changes on the active web
// state.
@property(nonatomic, assign) WebStateList* webStateList;
// The overlay presenter for OverlayModality::kWebContentArea.
@property(nonatomic, assign) OverlayPresenter* webContentAreaOverlayPresenter;
// The consumer for this object. This can change during the lifetime of this
// object and may be nil.
@property(nonatomic, weak) id<LocationBarSteadyViewConsumer> consumer;
// Stops observing all objects.
- (void)disconnect;
@end
#endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_STEADY_VIEW_MEDIATOR_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// 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/location_bar/location_bar_steady_view_mediator.h"
#include "base/strings/sys_string_conversions.h"
#include "components/omnibox/browser/location_bar_model.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter_observer_bridge.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h"
#import "ios/chrome/browser/overlays/public/web_content_area/http_auth_overlay.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_steady_view_consumer.h"
#import "ios/chrome/browser/ui/ntp/ntp_util.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_util.h"
#import "ios/chrome/browser/web_state_list/active_web_state_observation_forwarder.h"
#import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h"
#import "ios/chrome/grit/ios_strings.h"
#import "ios/web/public/web_client.h"
#import "ios/web/public/web_state.h"
#import "ios/web/public/web_state_observer_bridge.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface LocationBarSteadyViewMediator () <CRWWebStateObserver,
WebStateListObserving,
OverlayPresenterObserving> {
std::unique_ptr<WebStateListObserverBridge> _webStateListObserver;
std::unique_ptr<web::WebStateObserverBridge> _observer;
std::unique_ptr<ActiveWebStateObservationForwarder> _forwarder;
std::unique_ptr<OverlayPresenterObserverBridge> _overlayObserver;
}
// Whether an overlay is currently presented over the web content area.
@property(nonatomic, assign, getter=isWebContentAreaShowingOverlay)
BOOL webContentAreaShowingOverlay;
// Whether an HTTP authentication dialog is currently presented over the
// web content area.
@property(nonatomic, assign, getter=isWebContentAreaShowingHTTPAuthDialog)
BOOL webContentAreaShowingHTTPAuthDialog;
// The location bar model used by this mediator to extract the current URL and
// the security state.
@property(nonatomic, assign, readonly) LocationBarModel* locationBarModel;
@property(nonatomic, readonly) web::WebState* currentWebState;
@end
@implementation LocationBarSteadyViewMediator
- (instancetype)initWithLocationBarModel:(LocationBarModel*)locationBarModel {
DCHECK(locationBarModel);
self = [super init];
if (self) {
_locationBarModel = locationBarModel;
_webStateListObserver = std::make_unique<WebStateListObserverBridge>(self);
_observer = std::make_unique<web::WebStateObserverBridge>(self);
_overlayObserver = std::make_unique<OverlayPresenterObserverBridge>(self);
}
return self;
}
- (void)dealloc {
[self disconnect];
}
- (void)disconnect {
self.webStateList = nullptr;
self.webContentAreaOverlayPresenter = nullptr;
}
#pragma mark - Setters
- (void)setConsumer:(id<LocationBarSteadyViewConsumer>)consumer {
_consumer = consumer;
if (self.webStateList) {
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
}
- (void)setWebStateList:(WebStateList*)webStateList {
if (_webStateList) {
_webStateList->RemoveObserver(_webStateListObserver.get());
_forwarder = nullptr;
}
_webStateList = webStateList;
if (_webStateList) {
_webStateList->AddObserver(_webStateListObserver.get());
_forwarder = std::make_unique<ActiveWebStateObservationForwarder>(
_webStateList, _observer.get());
}
}
- (void)setWebContentAreaShowingOverlay:(BOOL)webContentAreaShowingOverlay {
if (_webContentAreaShowingOverlay == webContentAreaShowingOverlay)
return;
_webContentAreaShowingOverlay = webContentAreaShowingOverlay;
[self.consumer updateLocationShareable:[self isSharingEnabled]];
}
- (void)setWebContentAreaShowingHTTPAuthDialog:
(BOOL)webContentAreaShowingHTTPAuthDialog {
if (_webContentAreaShowingHTTPAuthDialog ==
webContentAreaShowingHTTPAuthDialog) {
return;
}
_webContentAreaShowingHTTPAuthDialog = webContentAreaShowingHTTPAuthDialog;
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
- (void)setWebContentAreaOverlayPresenter:
(OverlayPresenter*)webContentAreaOverlayPresenter {
if (_webContentAreaOverlayPresenter)
_webContentAreaOverlayPresenter->RemoveObserver(_overlayObserver.get());
_webContentAreaOverlayPresenter = webContentAreaOverlayPresenter;
if (_webContentAreaOverlayPresenter)
_webContentAreaOverlayPresenter->AddObserver(_overlayObserver.get());
}
#pragma mark - CRWWebStateObserver
- (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success {
[self notifyConsumerOfChangedLocation];
}
- (void)webState:(web::WebState*)webState
didStartNavigation:(web::NavigationContext*)navigation {
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
- (void)webState:(web::WebState*)webState
didFinishNavigation:(web::NavigationContext*)navigation {
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
- (void)webStateDidStartLoading:(web::WebState*)webState {
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
- (void)webStateDidStopLoading:(web::WebState*)webState {
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
- (void)webStateDidChangeVisibleSecurityState:(web::WebState*)webState {
// Currently, because of https://crbug.com/448486 , interstitials are not
// commited navigations. This means that if a security interstitial (e.g. for
// broken HTTPS) is shown, didFinishNavigation: is not called, and
// didChangeVisibleSecurityState: is the only chance to update the URL.
// Otherwise it would be preferable to only update the icon here.
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
#pragma mark - WebStateListObserver
- (void)webStateList:(WebStateList*)webStateList
didChangeActiveWebState:(web::WebState*)newWebState
oldWebState:(web::WebState*)oldWebState
atIndex:(int)atIndex
reason:(ActiveWebStateChangeReason)reason {
[self notifyConsumerOfChangedLocation];
[self notifyConsumerOfChangedSecurityIcon];
}
#pragma mark - OverlayPresenterObserving
- (void)overlayPresenter:(OverlayPresenter*)presenter
willShowOverlayForRequest:(OverlayRequest*)request
initialPresentation:(BOOL)initialPresentation {
self.webContentAreaShowingOverlay = YES;
self.webContentAreaShowingHTTPAuthDialog =
!!request->GetConfig<HTTPAuthOverlayRequestConfig>();
}
- (void)overlayPresenter:(OverlayPresenter*)presenter
didHideOverlayForRequest:(OverlayRequest*)request {
self.webContentAreaShowingOverlay = NO;
self.webContentAreaShowingHTTPAuthDialog = NO;
}
#pragma mark - private
- (web::WebState*)currentWebState {
return self.webStateList ? self.webStateList->GetActiveWebState() : nullptr;
}
- (void)notifyConsumerOfChangedLocation {
[self.consumer updateLocationText:[self currentLocationString]
clipTail:[self locationShouldClipTail]];
GURL URL = self.currentWebState ? self.currentWebState->GetVisibleURL()
: GURL::EmptyGURL();
BOOL isNTP = IsURLNewTabPage(URL);
if (isNTP) {
[self.consumer updateAfterNavigatingToNTP];
}
[self.consumer updateLocationShareable:[self isSharingEnabled]];
}
- (void)notifyConsumerOfChangedSecurityIcon {
[self.consumer updateLocationIcon:[self currentLocationIcon]
securityStatusText:[self securityStatusText]];
}
#pragma mark Location helpers
- (NSString*)currentLocationString {
if (self.webContentAreaShowingHTTPAuthDialog)
return l10n_util::GetNSString(IDS_IOS_LOCATION_BAR_SIGN_IN);
base::string16 string = self.locationBarModel->GetURLForDisplay();
return base::SysUTF16ToNSString(string);
}
// Data URLs (data://) should have their tail clipped when presented; while for
// others (http://) it would be more appropriate to clip the head.
- (BOOL)locationShouldClipTail {
if (self.webContentAreaShowingHTTPAuthDialog)
return YES;
GURL url = self.locationBarModel->GetURL();
return url.SchemeIs(url::kDataScheme);
}
#pragma mark Security status icon helpers
- (UIImage*)currentLocationIcon {
if (!self.locationBarModel->ShouldDisplayURL() ||
self.webContentAreaShowingHTTPAuthDialog) {
return nil;
}
if (self.locationBarModel->IsOfflinePage()) {
return [self imageForOfflinePage];
}
return GetLocationBarSecurityIconForSecurityState(
self.locationBarModel->GetSecurityLevel());
}
// Returns a location icon for offline pages.
- (UIImage*)imageForOfflinePage {
return [[UIImage imageNamed:@"location_bar_connection_offline"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
// The status text associated with the current location icon.
- (NSString*)securityStatusText {
if (self.webContentAreaShowingHTTPAuthDialog)
return nil;
return base::SysUTF16ToNSString(
self.locationBarModel->GetSecureAccessibilityText());
}
#pragma mark Shareability helpers
- (BOOL)isSharingEnabled {
// Page sharing requires JavaScript execution, which is paused while overlays
// are displayed over the web content area.
if (self.webContentAreaShowingOverlay)
return NO;
if (!self.currentWebState) {
return NO;
}
const GURL& URL = self.currentWebState->GetLastCommittedURL();
return URL.is_valid() && !web::GetWebClient()->IsAppSpecificURL(URL);
}
@end
......@@ -2,7 +2,7 @@
// 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/location_bar/location_bar_mediator.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_steady_view_mediator.h"
#include "components/omnibox/browser/test_location_bar_model.h"
#import "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
......@@ -13,7 +13,7 @@
#import "ios/chrome/browser/overlays/public/web_content_area/http_auth_overlay.h"
#import "ios/chrome/browser/overlays/public/web_content_area/java_script_dialog_overlay.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_presentation_context.h"
#import "ios/chrome/browser/ui/location_bar/test/fake_location_bar_consumer.h"
#import "ios/chrome/browser/ui/location_bar/test/fake_location_bar_steady_view_consumer.h"
#import "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_opener.h"
......@@ -30,14 +30,14 @@
using java_script_dialog_overlays::JavaScriptDialogRequest;
// Test fixture for LocationBarMediator.
class LocationBarMediatorTest : public PlatformTest {
// Test fixture for LocationBarSteadyViewMediator.
class LocationBarSteadyViewMediatorTest : public PlatformTest {
protected:
LocationBarMediatorTest()
LocationBarSteadyViewMediatorTest()
: web_state_list_(&web_state_list_delegate_),
mediator_(
[[LocationBarMediator alloc] initWithLocationBarModel:&model_]),
consumer_([[FakeLocationBarConsumer alloc] init]) {
mediator_([[LocationBarSteadyViewMediator alloc]
initWithLocationBarModel:&model_]),
consumer_([[FakeLocationBarSteadyViewConsumer alloc] init]) {
// Set up the TestBrowser.
TestChromeBrowserState::Builder browser_state_builder;
browser_state_ = browser_state_builder.Build();
......@@ -52,7 +52,7 @@ class LocationBarMediatorTest : public PlatformTest {
mediator_.webContentAreaOverlayPresenter = overlay_presenter;
mediator_.consumer = consumer_;
}
~LocationBarMediatorTest() override { [mediator_ disconnect]; }
~LocationBarSteadyViewMediatorTest() override { [mediator_ disconnect]; }
FakeOverlayPresentationContext presentation_context_;
web::WebTaskEnvironment task_environment_;
......@@ -61,13 +61,13 @@ class LocationBarMediatorTest : public PlatformTest {
std::unique_ptr<TestChromeBrowserState> browser_state_;
std::unique_ptr<Browser> browser_;
TestLocationBarModel model_;
LocationBarMediator* mediator_;
FakeLocationBarConsumer* consumer_;
LocationBarSteadyViewMediator* mediator_;
FakeLocationBarSteadyViewConsumer* consumer_;
};
// Tests that the share button is disabled while overlays are presented
// over the web content area.
TEST_F(LocationBarMediatorTest, DisableShareForOverlays) {
TEST_F(LocationBarSteadyViewMediatorTest, DisableShareForOverlays) {
const GURL kUrl("https://chromium.test");
std::unique_ptr<web::TestWebState> passed_web_state =
std::make_unique<web::TestWebState>();
......@@ -95,7 +95,7 @@ TEST_F(LocationBarMediatorTest, DisableShareForOverlays) {
// Tests that the location text and page icon are updated when an HTTP auth
// dialog is displayed.
TEST_F(LocationBarMediatorTest, HTTPAuthDialog) {
TEST_F(LocationBarSteadyViewMediatorTest, HTTPAuthDialog) {
const GURL kUrl("https://chromium.test");
std::unique_ptr<web::TestWebState> passed_web_state =
std::make_unique<web::TestWebState>();
......@@ -122,7 +122,8 @@ TEST_F(LocationBarMediatorTest, HTTPAuthDialog) {
// Tests that the location text is updated correctly when an HTTP auth dialog
// finishes its dismissal after the active WebState is set to null.
TEST_F(LocationBarMediatorTest, HTTPAuthDialogDismissalWithNullWebState) {
TEST_F(LocationBarSteadyViewMediatorTest,
HTTPAuthDialogDismissalWithNullWebState) {
const GURL kUrl("https://chromium.test");
std::unique_ptr<web::TestWebState> passed_web_state =
std::make_unique<web::TestWebState>();
......
......@@ -10,7 +10,6 @@
#import "ios/chrome/browser/ui/badges/badge_consumer.h"
#import "ios/chrome/browser/ui/commands/omnibox_commands.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_element.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_consumer.h"
#import "ios/chrome/browser/ui/orchestrator/location_bar_animatee.h"
@class InfobarMetricsRecorder;
......
......@@ -6,8 +6,8 @@ source_set("test") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"fake_location_bar_consumer.h",
"fake_location_bar_consumer.mm",
"fake_location_bar_steady_view_consumer.h",
"fake_location_bar_steady_view_consumer.mm",
]
deps = [ "//ios/chrome/browser/ui/location_bar" ]
}
......@@ -2,22 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_CONSUMER_H_
#define IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_CONSUMER_H_
#ifndef IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_STEADY_VIEW_CONSUMER_H_
#define IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_STEADY_VIEW_CONSUMER_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/location_bar/location_bar_consumer.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_steady_view_consumer.h"
@interface FakeLocationBarConsumer : NSObject <LocationBarConsumer>
@interface FakeLocationBarSteadyViewConsumer
: NSObject <LocationBarSteadyViewConsumer>
@property(nonatomic, strong, readonly) NSString* locationText;
@property(nonatomic, assign, readonly) BOOL clipTail;
@property(nonatomic, strong, readonly) UIImage* icon;
@property(nonatomic, strong, readonly) NSString* statusText;
@property(nonatomic, assign, readonly, getter=isLocationShareable)
BOOL locationShareable;
@property(nonatomic, assign, readonly, getter=isSearchByImageSupported)
BOOL searchByImageSupported;
@end
#endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_CONSUMER_H_
#endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_STEADY_VIEW_CONSUMER_H_
......@@ -2,13 +2,13 @@
// 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/location_bar/test/fake_location_bar_consumer.h"
#import "ios/chrome/browser/ui/location_bar/test/fake_location_bar_steady_view_consumer.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation FakeLocationBarConsumer
@implementation FakeLocationBarSteadyViewConsumer
- (void)updateLocationText:(NSString*)string clipTail:(BOOL)clipTail {
_locationText = string;
......@@ -25,14 +25,7 @@
_locationShareable = shareable;
}
- (void)defocusOmnibox {
}
- (void)updateAfterNavigatingToNTP {
}
- (void)updateSearchByImageSupported:(BOOL)searchByImageSupported {
_searchByImageSupported = searchByImageSupported;
}
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment