Commit cbb40ac3 authored by Glen Robertson's avatar Glen Robertson Committed by Commit Bot

Remove ConfigureNetworkContextParams from profile.

This was a method call simply passed through to profile so that
chrome_content_browser_client.cc could have different behaviour for
testing profiles. It introduced a dependency "up" the build hierarchy
(in the wrong direction) when profile should be a dependency leaf
within //chrome/browser. That made #include cycles which prevent profile
from being extracted into a separate target.

Unfortunately, need to early-construct
ProfileNetworkContextServiceFactory in
ChromeBrowserMainExtraPartsProfiles so that ServiceIsNULLWhileTesting
works as expected.

Bug: 1149277,1150733
Change-Id: I608ec127813086db3aa5550e2fe9af5afb7b7e05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2539813
Commit-Queue: Glen Robertson <glenrob@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830083}
parent 1eb44164
...@@ -4889,10 +4889,17 @@ void ChromeContentBrowserClient::ConfigureNetworkContextParams( ...@@ -4889,10 +4889,17 @@ void ChromeContentBrowserClient::ConfigureNetworkContextParams(
const base::FilePath& relative_partition_path, const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params, network::mojom::NetworkContextParams* network_context_params,
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) { network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
Profile* profile = Profile::FromBrowserContext(context); ProfileNetworkContextService* service =
profile->ConfigureNetworkContextParams(in_memory, relative_partition_path, ProfileNetworkContextServiceFactory::GetForContext(context);
network_context_params, if (service) {
cert_verifier_creation_params); service->ConfigureNetworkContextParams(in_memory, relative_partition_path,
network_context_params,
cert_verifier_creation_params);
} else {
// Set default params.
network_context_params->user_agent = GetUserAgent();
network_context_params->accept_language = GetApplicationLocale();
}
} }
std::vector<base::FilePath> std::vector<base::FilePath>
......
...@@ -47,3 +47,7 @@ ProfileNetworkContextServiceFactory::GetBrowserContextToUse( ...@@ -47,3 +47,7 @@ ProfileNetworkContextServiceFactory::GetBrowserContextToUse(
// Create separate service for incognito profiles. // Create separate service for incognito profiles.
return context; return context;
} }
bool ProfileNetworkContextServiceFactory::ServiceIsNULLWhileTesting() const {
return true;
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
class KeyedService; class KeyedService;
class ProfileNetworkContextService; class ProfileNetworkContextService;
namespace contenet { namespace content {
class BrowserContext; class BrowserContext;
} }
...@@ -39,6 +39,7 @@ class ProfileNetworkContextServiceFactory ...@@ -39,6 +39,7 @@ class ProfileNetworkContextServiceFactory
content::BrowserContext* profile) const override; content::BrowserContext* profile) const override;
content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override; content::BrowserContext* context) const override;
bool ServiceIsNULLWhileTesting() const override;
DISALLOW_COPY_AND_ASSIGN(ProfileNetworkContextServiceFactory); DISALLOW_COPY_AND_ASSIGN(ProfileNetworkContextServiceFactory);
}; };
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "chrome/browser/media/router/presentation/chrome_local_presentation_manager_factory.h" #include "chrome/browser/media/router/presentation/chrome_local_presentation_manager_factory.h"
#include "chrome/browser/media/webrtc/webrtc_event_log_manager_keyed_service_factory.h" #include "chrome/browser/media/webrtc/webrtc_event_log_manager_keyed_service_factory.h"
#include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
#include "chrome/browser/net/profile_network_context_service_factory.h"
#include "chrome/browser/notifications/notifier_state_tracker_factory.h" #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
#include "chrome/browser/page_load_metrics/observers/https_engagement_metrics/https_engagement_service_factory.h" #include "chrome/browser/page_load_metrics/observers/https_engagement_metrics/https_engagement_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/password_manager/password_store_factory.h"
...@@ -351,6 +352,7 @@ void ChromeBrowserMainExtraPartsProfiles:: ...@@ -351,6 +352,7 @@ void ChromeBrowserMainExtraPartsProfiles::
predictors::PredictorDatabaseFactory::GetInstance(); predictors::PredictorDatabaseFactory::GetInstance();
prerender::PrerenderLinkManagerFactory::GetInstance(); prerender::PrerenderLinkManagerFactory::GetInstance();
prerender::PrerenderManagerFactory::GetInstance(); prerender::PrerenderManagerFactory::GetInstance();
ProfileNetworkContextServiceFactory::GetInstance();
ProfileSyncServiceFactory::GetInstance(); ProfileSyncServiceFactory::GetInstance();
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
ProfileThemeUpdateServiceFactory::GetInstance(); ProfileThemeUpdateServiceFactory::GetInstance();
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
#include "chrome/browser/net/profile_network_context_service.h"
#include "chrome/browser/net/profile_network_context_service_factory.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_observer.h" #include "chrome/browser/profiles/profile_observer.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
...@@ -448,17 +446,6 @@ bool Profile::ShouldPersistSessionCookies() const { ...@@ -448,17 +446,6 @@ bool Profile::ShouldPersistSessionCookies() const {
return false; return false;
} }
void Profile::ConfigureNetworkContextParams(
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
ProfileNetworkContextServiceFactory::GetForContext(this)
->ConfigureNetworkContextParams(in_memory, relative_partition_path,
network_context_params,
cert_verifier_creation_params);
}
bool Profile::IsNewProfile() const { bool Profile::IsNewProfile() const {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// The profile is new if the preference files has just been created, except on // The profile is new if the preference files has just been created, except on
......
...@@ -223,7 +223,7 @@ class Profile : public content::BrowserContext { ...@@ -223,7 +223,7 @@ class Profile : public content::BrowserContext {
// the creation time of the profile object instance. // the creation time of the profile object instance.
virtual base::Time GetCreationTime() const = 0; virtual base::Time GetCreationTime() const = 0;
// Typesafe upcast. // Typesafe downcast.
virtual TestingProfile* AsTestingProfile(); virtual TestingProfile* AsTestingProfile();
// Returns sequenced task runner where browser context dependent I/O // Returns sequenced task runner where browser context dependent I/O
...@@ -473,16 +473,6 @@ class Profile : public content::BrowserContext { ...@@ -473,16 +473,6 @@ class Profile : public content::BrowserContext {
virtual bool ShouldRestoreOldSessionCookies() const; virtual bool ShouldRestoreOldSessionCookies() const;
virtual bool ShouldPersistSessionCookies() const; virtual bool ShouldPersistSessionCookies() const;
// Configures NetworkContextParams and CertVerifierCreationParams for the
// specified isolated app (or for the profile itself, if |relative_path| is
// empty).
virtual void ConfigureNetworkContextParams(
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
network::mojom::CertVerifierCreationParams*
cert_verifier_creation_params);
// Stop sending accessibility events until ResumeAccessibilityEvents(). // Stop sending accessibility events until ResumeAccessibilityEvents().
// Calls to Pause nest; no events will be sent until the number of // Calls to Pause nest; no events will be sent until the number of
// Resume calls matches the number of Pause calls received. // Resume calls matches the number of Pause calls received.
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/signin/chrome_signin_client_factory.h" #include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/net/profile_network_context_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
...@@ -11,6 +12,7 @@ ChromeSigninClientFactory::ChromeSigninClientFactory() ...@@ -11,6 +12,7 @@ ChromeSigninClientFactory::ChromeSigninClientFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"ChromeSigninClient", "ChromeSigninClient",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(ProfileNetworkContextServiceFactory::GetInstance());
} }
ChromeSigninClientFactory::~ChromeSigninClientFactory() {} ChromeSigninClientFactory::~ChromeSigninClientFactory() {}
......
...@@ -1007,15 +1007,6 @@ Profile::ExitType TestingProfile::GetLastSessionExitType() const { ...@@ -1007,15 +1007,6 @@ Profile::ExitType TestingProfile::GetLastSessionExitType() const {
return last_session_exited_cleanly_ ? EXIT_NORMAL : EXIT_CRASHED; return last_session_exited_cleanly_ ? EXIT_NORMAL : EXIT_CRASHED;
} }
void TestingProfile::ConfigureNetworkContextParams(
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
network_context_params->user_agent = GetUserAgent();
network_context_params->accept_language = "en-us,en";
}
TestingProfile::Builder::Builder() TestingProfile::Builder::Builder()
: build_called_(false), : build_called_(false),
delegate_(nullptr), delegate_(nullptr),
......
...@@ -371,12 +371,6 @@ class TestingProfile : public Profile { ...@@ -371,12 +371,6 @@ class TestingProfile : public Profile {
bool IsNewProfile() const override; bool IsNewProfile() const override;
void SetExitType(ExitType exit_type) override {} void SetExitType(ExitType exit_type) override {}
ExitType GetLastSessionExitType() const override; ExitType GetLastSessionExitType() const override;
void ConfigureNetworkContextParams(
bool in_memory,
const base::FilePath& relative_partition_path,
network::mojom::NetworkContextParams* network_context_params,
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params)
override;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
void ChangeAppLocale(const std::string&, AppLocaleChangedVia) override; void ChangeAppLocale(const std::string&, AppLocaleChangedVia) override;
......
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