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