summaryrefslogtreecommitdiffstats
path: root/chrome/test/base
diff options
context:
space:
mode:
authorbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-28 16:56:41 +0000
committerbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-28 16:56:41 +0000
commita43b9a8ecf880e2a48b2a14cae3e0a9c5811087b (patch)
treef8de1beeb3bdaf86e30bd9510450e7f8676673c0 /chrome/test/base
parent2fcae0f28b8c7dee14fa611c22fe198651e8cde0 (diff)
downloadchromium_src-a43b9a8ecf880e2a48b2a14cae3e0a9c5811087b.zip
chromium_src-a43b9a8ecf880e2a48b2a14cae3e0a9c5811087b.tar.gz
chromium_src-a43b9a8ecf880e2a48b2a14cae3e0a9c5811087b.tar.bz2
Add CloudExternalDataPolicyObserver
This CL adds the CloudExternalDataPolicyObserver. This helper can be used to observe a policy referencing external data for all users on a device, covering both device-local accounts (whose policy is available and may change anytime) and regular accounts (whose policy is available and may change only when the user is logged in). The helper emits notifications when an external data reference is set, cleared or an external data fetch completes successfully. The helper will be used to implement a policy for setting the avatar image and a policy for setting the wallpaper. The CL also adds the first policy referencing external data. The policy is not wired up yet but having it defined unblocks server-side work and makes testing easier. The policy will be implemented in a follow-up CL coming soon. BUG=152957,152959,220418 TEST=Full unit test coverage TBR=askvitkine@chromium.org Review URL: https://codereview.chromium.org/88423002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/base')
-rw-r--r--chrome/test/base/testing_profile.cc26
-rw-r--r--chrome/test/base/testing_profile.h8
2 files changed, 27 insertions, 7 deletions
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 3fa3ef9..73efdfb 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -41,6 +41,7 @@
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
+#include "chrome/browser/policy/policy_service.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/prefs/browser_prefs.h"
@@ -233,6 +234,7 @@ TestingProfile::TestingProfile(
scoped_ptr<PrefServiceSyncable> prefs,
bool incognito,
const std::string& managed_user_id,
+ scoped_ptr<policy::PolicyService> policy_service,
const TestingFactories& factories)
: start_time_(Time::Now()),
prefs_(prefs.release()),
@@ -247,7 +249,8 @@ TestingProfile::TestingProfile(
browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()),
resource_context_(NULL),
- delegate_(delegate) {
+ delegate_(delegate),
+ policy_service_(policy_service.release()) {
// If no profile path was supplied, create one.
if (profile_path_.empty()) {
@@ -628,22 +631,25 @@ void TestingProfile::CreateTestingPrefService() {
}
void TestingProfile::CreateProfilePolicyConnector() {
- scoped_ptr<policy::PolicyService> service;
#if defined(ENABLE_CONFIGURATION_POLICY)
schema_registry_service_ =
policy::SchemaRegistryServiceFactory::CreateForContext(
this, policy::Schema(), NULL);
CHECK_EQ(schema_registry_service_.get(),
policy::SchemaRegistryServiceFactory::GetForContext(this));
+#endif // defined(ENABLE_CONFIGURATION_POLICY)
- std::vector<policy::ConfigurationPolicyProvider*> providers;
- service.reset(new policy::PolicyServiceImpl(
- providers, policy::PolicyServiceImpl::PreprocessCallback()));
+if (!policy_service_) {
+#if defined(ENABLE_CONFIGURATION_POLICY)
+ std::vector<policy::ConfigurationPolicyProvider*> providers;
+ policy_service_.reset(new policy::PolicyServiceImpl(
+ providers, policy::PolicyServiceImpl::PreprocessCallback()));
#else
- service.reset(new policy::PolicyServiceStub());
+ policy_service_.reset(new policy::PolicyServiceStub());
#endif
+ }
profile_policy_connector_.reset(new policy::ProfilePolicyConnector());
- profile_policy_connector_->InitForTesting(service.Pass());
+ profile_policy_connector_->InitForTesting(policy_service_.Pass());
policy::ProfilePolicyConnectorFactory::GetInstance()->SetServiceForTesting(
this, profile_policy_connector_.get());
CHECK_EQ(profile_policy_connector_.get(),
@@ -886,6 +892,11 @@ void TestingProfile::Builder::SetManagedUserId(
managed_user_id_ = managed_user_id;
}
+void TestingProfile::Builder::SetPolicyService(
+ scoped_ptr<policy::PolicyService> policy_service) {
+ policy_service_ = policy_service.Pass();
+}
+
void TestingProfile::Builder::AddTestingFactory(
BrowserContextKeyedServiceFactory* service_factory,
BrowserContextKeyedServiceFactory::FactoryFunction callback) {
@@ -903,5 +914,6 @@ scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
pref_service_.Pass(),
incognito_,
managed_user_id_,
+ policy_service_.Pass(),
testing_factories_));
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index 48b0962..7014623 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -31,6 +31,7 @@ class URLRequestContextGetter;
}
namespace policy {
+class PolicyService;
class ProfilePolicyConnector;
class SchemaRegistryService;
}
@@ -105,6 +106,9 @@ class TestingProfile : public Profile {
// non-empty string, the profile is managed.
void SetManagedUserId(const std::string& managed_user_id);
+ // Sets the PolicyService to be used by this profile.
+ void SetPolicyService(scoped_ptr<policy::PolicyService> policy_service);
+
// Creates the TestingProfile using previously-set settings.
scoped_ptr<TestingProfile> Build();
@@ -119,6 +123,7 @@ class TestingProfile : public Profile {
Delegate* delegate_;
bool incognito_;
std::string managed_user_id_;
+ scoped_ptr<policy::PolicyService> policy_service_;
TestingFactories testing_factories_;
DISALLOW_COPY_AND_ASSIGN(Builder);
@@ -145,6 +150,7 @@ class TestingProfile : public Profile {
scoped_ptr<PrefServiceSyncable> prefs,
bool incognito,
const std::string& managed_user_id,
+ scoped_ptr<policy::PolicyService> policy_service,
const TestingFactories& factories);
virtual ~TestingProfile();
@@ -402,6 +408,8 @@ class TestingProfile : public Profile {
Delegate* delegate_;
std::string profile_name_;
+
+ scoped_ptr<policy::PolicyService> policy_service_;
};
#endif // CHROME_TEST_BASE_TESTING_PROFILE_H_