Commit 0c966880 authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Migrate away from downstream URLLoadingService use (1/7).

As part of preparing for multi-window, the URLLoadingService needs
to be migrated to be a BrowserAgent instead of a KeyedService. That
change is itself fairly large, but as an additional complication
URLLoadingService is used in downstream code.

This CL is the first in a series of changes needed to complete this
refactor:

1. Add a new provider API upstream that passes both a Browser and
   temporary URL loading shim to CreateLogoVendor.
2. Implement this new API downstream and add support for initializing
   the LogoController with both Browser and the loading shim. Use the
   loading shim for loading URLs if it is present.
3. Upstream, call the new CreateLogoVendor() API.
4. Downstream, remove support for the old CreateLogoVendor() API and
   update LogoController to only be initialized with a Browser and the
   shim loader. Remove downstream use of the URLLoadingService.
5. Upstream, refactor URLLoadingService to be URLLoadingBrowserAgent,
   including updating the upstream implementation of the loading shim
   passed downstream in CreateLogoVendor().
6. Upstream, add a new provider API that no longer passes the loading
   shim into CreateLogoVendor().
7. Downstream, remove use of the loading shim from LogoController and
   have it fetch the URLLoadingBrowserAgent from its Browser parameter.
   Implement the new shim-less CreateLogoVendor() API. Remove the
   implementation of the shimmed API.
8. Upstream, remove the loading shim protocol and the old shimmed
   CreateLogoVendor() API. Call only the new shimless API.

Specifically, this CL creates a shim URLLoadingBridge protocol so that
the implementation of the actual URL load can be changed upstream in
a single CL upstream (step 5 in the process above). At the same time,
a Browser object is also passed into the provider so that after the
loading service is changed, it can be fetched (via Browser) in the
downstream code.

This CL doesn't introduce any implementation of the shim protocol; that
will be in step 3.

Bug: 1046374
Change-Id: Ic2388c0f9680dabc8cb10349255cc9ab281cccbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089687Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747748}
parent 001aef23
...@@ -15,12 +15,14 @@ source_set("browser") { ...@@ -15,12 +15,14 @@ source_set("browser") {
"geolocation_updater_provider.mm", "geolocation_updater_provider.mm",
"overrides_provider.h", "overrides_provider.h",
"overrides_provider.mm", "overrides_provider.mm",
"url_loading_bridge.h",
] ]
deps = [ deps = [
"//base", "//base",
"//components/metrics", "//components/metrics",
"//ios//web/public",
"//ios/public/provider/chrome/browser/mailto", "//ios/public/provider/chrome/browser/mailto",
"//ios/web/public",
"//url",
] ]
libs = [ "CoreLocation.framework" ] libs = [ "CoreLocation.framework" ]
} }
......
...@@ -39,6 +39,7 @@ class WebState; ...@@ -39,6 +39,7 @@ class WebState;
class GURL; class GURL;
@protocol LogoVendor; @protocol LogoVendor;
@protocol URLLoadingBridge;
@class UITextField; @class UITextField;
@class UIView; @class UIView;
class Browser; class Browser;
...@@ -138,6 +139,11 @@ class ChromeBrowserProvider { ...@@ -138,6 +139,11 @@ class ChromeBrowserProvider {
web::WebState* web_state) const web::WebState* web_state) const
NS_RETURNS_RETAINED; NS_RETURNS_RETAINED;
virtual id<LogoVendor> CreateLogoVendor(
Browser* browser,
web::WebState* web_state,
id<URLLoadingBridge> loading_bridge) const NS_RETURNS_RETAINED;
// Returns an instance of the omaha service provider. // Returns an instance of the omaha service provider.
virtual OmahaServiceProvider* GetOmahaServiceProvider() const; virtual OmahaServiceProvider* GetOmahaServiceProvider() const;
......
...@@ -104,6 +104,13 @@ id<LogoVendor> ChromeBrowserProvider::CreateLogoVendor( ...@@ -104,6 +104,13 @@ id<LogoVendor> ChromeBrowserProvider::CreateLogoVendor(
return nil; return nil;
} }
id<LogoVendor> ChromeBrowserProvider::CreateLogoVendor(
Browser* browser,
web::WebState* web_state,
id<URLLoadingBridge> loading_bridge) const {
return nil;
}
OmahaServiceProvider* ChromeBrowserProvider::GetOmahaServiceProvider() const { OmahaServiceProvider* ChromeBrowserProvider::GetOmahaServiceProvider() const {
return nullptr; return nullptr;
} }
......
// 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_PUBLIC_PROVIDER_CHROME_BROWSER_URL_LOADING_BRIDGE_H_
#define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_URL_LOADING_BRIDGE_H_
#import "url/gurl.h"
// A temporary bridge protocol to change the class used to load URLs.
@protocol URLLoadingBridge <NSObject>
// Asks the implementer to load |URL| in response to a tappable logo.
- (void)loadLogoURL:(GURL)URL;
@end
#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_URL_LOADING_BRIDGE_H_
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