Commit edce2e6a authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

[ios] Fix uses of ios::ChromeBrowserState in /ios/chrome/browser/url_loading

The ChromeBrowserState has been moved from the "ios" namespace
to the global namespace by http://crrev.com/c/2014913. Fix the
uses from ios::ChromeBrowserState to ChromeBrowserState.

Also remove includes of chrome_browser_state_forward.h and use
a simple forward declaration instead (since the old name is no
longer necessary).

This CL was uploaded by git cl split.

R=marq@chromium.org

Bug: 1042208
Change-Id: I4f115443c7eafc2749f5211f797f38028dd2f75b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015251
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735291}
parent c4025e00
......@@ -11,9 +11,9 @@
#include "base/ios/block_types.h"
#import "ios/chrome/app/application_delegate/tab_opening.h"
#include "ios/chrome/app/application_mode.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state_forward.h"
#include "ui/base/page_transition_types.h"
class ChromeBrowserState;
struct UrlLoadParams;
@class TabModel;
......@@ -50,7 +50,7 @@ struct UrlLoadParams;
- (void)expectNewForegroundTabForMode:(ApplicationMode)targetMode;
// TODO(crbug.com/907527): refactor to remove these and most methods above.
- (ios::ChromeBrowserState*)currentBrowserState;
- (ChromeBrowserState*)currentBrowserState;
- (TabModel*)currentTabModel;
@end
......@@ -66,7 +66,7 @@ class AppUrlLoadingService {
virtual void LoadUrlInNewTab(const UrlLoadParams& params);
// Returns the current browser state.
virtual ios::ChromeBrowserState* GetCurrentBrowserState();
virtual ChromeBrowserState* GetCurrentBrowserState();
private:
__weak id<AppURLLoadingServiceDelegate> delegate_;
......
......@@ -81,6 +81,6 @@ void AppUrlLoadingService::LoadUrlInNewTab(const UrlLoadParams& params) {
}
}
ios::ChromeBrowserState* AppUrlLoadingService::GetCurrentBrowserState() {
ChromeBrowserState* AppUrlLoadingService::GetCurrentBrowserState() {
return [delegate_ currentBrowserState];
}
......@@ -5,10 +5,11 @@
#ifndef IOS_CHROME_BROWSER_URL_LOADING_TEST_APP_URL_LOADING_SERVICE_H_
#define IOS_CHROME_BROWSER_URL_LOADING_TEST_APP_URL_LOADING_SERVICE_H_
#include "ios/chrome/browser/browser_state/chrome_browser_state_forward.h"
#include "ios/chrome/browser/url_loading/app_url_loading_service.h"
#import "ios/chrome/browser/url_loading/url_loading_params.h"
class ChromeBrowserState;
// Service used to manage url loading at application level.
class TestAppUrlLoadingService : public AppUrlLoadingService {
public:
......@@ -18,14 +19,14 @@ class TestAppUrlLoadingService : public AppUrlLoadingService {
void LoadUrlInNewTab(const UrlLoadParams& params) override;
// Returns the current browser state.
ios::ChromeBrowserState* GetCurrentBrowserState() override;
ChromeBrowserState* GetCurrentBrowserState() override;
// These are the last parameters passed to |LoadUrlInNewTab|.
UrlLoadParams last_params;
int load_new_tab_call_count = 0;
// This can be set by the test.
ios::ChromeBrowserState* currentBrowserState;
ChromeBrowserState* currentBrowserState;
};
#endif // IOS_CHROME_BROWSER_URL_LOADING_APP_URL_LOADING_SERVICE_H_
......@@ -15,6 +15,6 @@ void TestAppUrlLoadingService::LoadUrlInNewTab(const UrlLoadParams& params) {
load_new_tab_call_count++;
}
ios::ChromeBrowserState* TestAppUrlLoadingService::GetCurrentBrowserState() {
ChromeBrowserState* TestAppUrlLoadingService::GetCurrentBrowserState() {
return currentBrowserState;
}
......@@ -12,7 +12,7 @@
// static
UrlLoadingNotifier* UrlLoadingNotifierFactory::GetForBrowserState(
ios::ChromeBrowserState* browser_state) {
ChromeBrowserState* browser_state) {
return static_cast<UrlLoadingNotifier*>(
GetInstance()->GetServiceForBrowserState(browser_state, true));
}
......
......@@ -10,16 +10,16 @@
#include "base/macros.h"
#include "base/no_destructor.h"
#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state_forward.h"
class ChromeBrowserState;
class UrlLoadingNotifier;
// Singleton that owns all UrlLoadingNotifiers and associates them with
// ios::ChromeBrowserState.
// ChromeBrowserState.
class UrlLoadingNotifierFactory : public BrowserStateKeyedServiceFactory {
public:
static UrlLoadingNotifier* GetForBrowserState(
ios::ChromeBrowserState* browser_state);
ChromeBrowserState* browser_state);
static UrlLoadingNotifierFactory* GetInstance();
......
......@@ -85,7 +85,7 @@ void UrlLoadingService::Load(const UrlLoadParams& params) {
break;
}
case UrlLoadStrategy::ALWAYS_IN_INCOGNITO: {
ios::ChromeBrowserState* browser_state = browser_->GetBrowserState();
ChromeBrowserState* browser_state = browser_->GetBrowserState();
if (params.disposition == WindowOpenDisposition::CURRENT_TAB &&
!browser_state->IsOffTheRecord()) {
UrlLoadingServiceFactory::GetForBrowserState(
......@@ -127,7 +127,7 @@ void UrlLoadingService::Dispatch(const UrlLoadParams& params) {
void UrlLoadingService::LoadUrlInCurrentTab(const UrlLoadParams& params) {
web::NavigationManager::WebLoadParams web_params = params.web_params;
ios::ChromeBrowserState* browser_state = browser_->GetBrowserState();
ChromeBrowserState* browser_state = browser_->GetBrowserState();
notifier_->TabWillLoadUrl(web_params.url, web_params.transition_type);
......@@ -224,7 +224,7 @@ void UrlLoadingService::SwitchToTab(const UrlLoadParams& params) {
Load(UrlLoadParams::InCurrentTab(web_params));
} else {
// Load the URL in foreground.
ios::ChromeBrowserState* browser_state = browser_->GetBrowserState();
ChromeBrowserState* browser_state = browser_->GetBrowserState();
UrlLoadParams new_tab_params =
UrlLoadParams::InNewTab(web_params.url, web_params.virtual_url);
new_tab_params.web_params.referrer = web::Referrer();
......@@ -254,7 +254,7 @@ void UrlLoadingService::LoadUrlInNewTab(const UrlLoadParams& params) {
DCHECK(app_service_);
DCHECK(delegate_);
DCHECK(browser_);
ios::ChromeBrowserState* browser_state = browser_->GetBrowserState();
ChromeBrowserState* browser_state = browser_->GetBrowserState();
// Two UrlLoadingServices exist, normal and incognito. Handle two special
// cases that need to be sent up to the AppUrlLoadingService:
......
......@@ -10,16 +10,16 @@
#include "base/macros.h"
#include "base/no_destructor.h"
#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state_forward.h"
class ChromeBrowserState;
class UrlLoadingService;
// Singleton that owns all UrlLoadingServices and associates them with
// ios::ChromeBrowserState.
// ChromeBrowserState.
class UrlLoadingServiceFactory : public BrowserStateKeyedServiceFactory {
public:
static UrlLoadingService* GetForBrowserState(
ios::ChromeBrowserState* browser_state);
ChromeBrowserState* browser_state);
static UrlLoadingServiceFactory* GetInstance();
......
......@@ -18,7 +18,7 @@
// static
UrlLoadingService* UrlLoadingServiceFactory::GetForBrowserState(
ios::ChromeBrowserState* browser_state) {
ChromeBrowserState* browser_state) {
return static_cast<UrlLoadingService*>(
GetInstance()->GetServiceForBrowserState(browser_state, true));
}
......@@ -31,8 +31,8 @@ UrlLoadingServiceFactory* UrlLoadingServiceFactory::GetInstance() {
std::unique_ptr<KeyedService> BuildTestUrlLoadingService(
web::BrowserState* context) {
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromBrowserState(context);
ChromeBrowserState* browser_state =
ChromeBrowserState::FromBrowserState(context);
return std::make_unique<TestUrlLoadingService>(
UrlLoadingNotifierFactory::GetForBrowserState(browser_state));
}
......@@ -54,8 +54,8 @@ UrlLoadingServiceFactory::~UrlLoadingServiceFactory() {}
std::unique_ptr<KeyedService> UrlLoadingServiceFactory::BuildServiceInstanceFor(
web::BrowserState* context) const {
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromBrowserState(context);
ChromeBrowserState* browser_state =
ChromeBrowserState::FromBrowserState(context);
return std::make_unique<UrlLoadingService>(
UrlLoadingNotifierFactory::GetForBrowserState(browser_state));
}
......
......@@ -39,7 +39,7 @@
@interface ULSTestTabModel : OCMockComplexTypeHelper
- (instancetype)init NS_DESIGNATED_INITIALIZER;
@property(nonatomic, assign) ios::ChromeBrowserState* browserState;
@property(nonatomic, assign) ChromeBrowserState* browserState;
@property(nonatomic, readonly) WebStateList* webStateList;
@end
......@@ -146,7 +146,7 @@ class URLLoadingServiceTest : public BlockCleanupTest {
service_->SetBrowser(browser_);
service_->SetAppService(app_service_);
ios::ChromeBrowserState* otr_browser_state =
ChromeBrowserState* otr_browser_state =
chrome_browser_state_.get()->GetOffTheRecordChromeBrowserState();
id otrTabModel = CreateTestTabModel(otr_browser_state);
......@@ -181,7 +181,7 @@ class URLLoadingServiceTest : public BlockCleanupTest {
return web_state;
}
id CreateTestTabModel(ios::ChromeBrowserState* browser_state) {
id CreateTestTabModel(ChromeBrowserState* browser_state) {
id tabModel = [[ULSTestTabModel alloc] init];
[tabModel setBrowserState:browser_state];
......@@ -351,7 +351,7 @@ TEST_F(URLLoadingServiceTest, TestOpenInCurrentIncognitoTab) {
ASSERT_EQ(0, otr_web_state_list->count());
// Make app level to be otr.
ios::ChromeBrowserState* otr_browser_state =
ChromeBrowserState* otr_browser_state =
chrome_browser_state_.get()->GetOffTheRecordChromeBrowserState();
app_service_->currentBrowserState = otr_browser_state;
......@@ -393,7 +393,7 @@ TEST_F(URLLoadingServiceTest, TestOpenInNewIncognitoTab) {
WebStateList* otr_web_state_list = otr_tab_model_.webStateList;
ASSERT_EQ(0, otr_web_state_list->count());
ios::ChromeBrowserState* otr_browser_state =
ChromeBrowserState* otr_browser_state =
chrome_browser_state_.get()->GetOffTheRecordChromeBrowserState();
app_service_->currentBrowserState = otr_browser_state;
......@@ -424,7 +424,7 @@ TEST_F(URLLoadingServiceTest, TestOpenNormalInNewTabWithIncognitoService) {
WebStateList* otr_web_state_list = otr_tab_model_.webStateList;
ASSERT_EQ(0, otr_web_state_list->count());
ios::ChromeBrowserState* otr_browser_state =
ChromeBrowserState* otr_browser_state =
chrome_browser_state_.get()->GetOffTheRecordChromeBrowserState();
app_service_->currentBrowserState = otr_browser_state;
......@@ -513,7 +513,7 @@ TEST_F(URLLoadingServiceTest, TestOpenIncognitoInCurrentTabWithLoadStrategy) {
ASSERT_EQ(0, otr_web_state_list->count());
// Make app level to be otr.
ios::ChromeBrowserState* otr_browser_state =
ChromeBrowserState* otr_browser_state =
chrome_browser_state_.get()->GetOffTheRecordChromeBrowserState();
app_service_->currentBrowserState = otr_browser_state;
......
......@@ -8,9 +8,9 @@
#import <Foundation/Foundation.h>
#include "components/sessions/core/session_id.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state_forward.h"
#include "ui/base/window_open_disposition.h"
class ChromeBrowserState;
class GURL;
namespace web {
......@@ -24,13 +24,13 @@ bool IsURLAllowedInIncognito(const GURL& url);
// |browser_state|. It is an error to pass a value of GURL that doesn't have a
// javascript: scheme.
void LoadJavaScriptURL(const GURL& url,
ios::ChromeBrowserState* browser_state,
ChromeBrowserState* browser_state,
web::WebState* web_state);
// Restores the closed tab identified by |session_id|, using |disposition|,
// into |browser_state|.
void RestoreTab(const SessionID session_id,
WindowOpenDisposition disposition,
ios::ChromeBrowserState* browser_state);
ChromeBrowserState* browser_state);
#endif // IOS_CHROME_BROWSER_URL_LOADING_URL_LOADING_UTIL_H_
......@@ -30,7 +30,7 @@ bool IsURLAllowedInIncognito(const GURL& url) {
}
void LoadJavaScriptURL(const GURL& url,
ios::ChromeBrowserState* browser_state,
ChromeBrowserState* browser_state,
web::WebState* web_state) {
DCHECK(url.SchemeIs(url::kJavaScriptScheme));
DCHECK(web_state);
......@@ -47,7 +47,7 @@ void LoadJavaScriptURL(const GURL& url,
void RestoreTab(const SessionID session_id,
WindowOpenDisposition disposition,
ios::ChromeBrowserState* browser_state) {
ChromeBrowserState* browser_state) {
TabRestoreServiceDelegateImplIOS* delegate =
TabRestoreServiceDelegateImplIOSFactory::GetForBrowserState(
browser_state);
......
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