#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/values.h"
-#include "chrome/browser/extensions/api/storage/settings_frontend.h"
-#include "chrome/browser/extensions/api/storage/settings_namespace.h"
#include "chrome/browser/extensions/api/storage/settings_sync_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_system_factory.h"
-#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/test/base/ui_test_utils.h"
+#include "extensions/browser/api/storage/settings_namespace.h"
+#include "extensions/browser/api/storage/storage_frontend.h"
+#include "extensions/browser/extension_system.h"
#include "extensions/common/value_builder.h"
+#include "extensions/test/extension_test_message_listener.h"
+#include "extensions/test/result_catcher.h"
+#include "sync/api/fake_sync_change_processor.h"
#include "sync/api/sync_change.h"
#include "sync/api/sync_change_processor.h"
+#include "sync/api/sync_change_processor_wrapper_for_test.h"
#include "sync/api/sync_error_factory.h"
#include "sync/api/sync_error_factory_mock.h"
+#include "sync/api/syncable_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#if defined(ENABLE_CONFIGURATION_POLICY)
// the extension.
const char kManagedStorageExtensionId[] = "kjmkgkdkpedkejedfhmfcenooemhbpbo";
-class NoopSyncChangeProcessor : public syncer::SyncChangeProcessor {
- public:
- virtual syncer::SyncError ProcessSyncChanges(
- const tracked_objects::Location& from_here,
- const syncer::SyncChangeList& change_list) OVERRIDE {
- return syncer::SyncError();
- }
-
- virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const
- OVERRIDE {
- return syncer::SyncDataList();
- }
-
- virtual ~NoopSyncChangeProcessor() {};
-};
-
-class SyncChangeProcessorDelegate : public syncer::SyncChangeProcessor {
- public:
- explicit SyncChangeProcessorDelegate(syncer::SyncChangeProcessor* recipient)
- : recipient_(recipient) {
- DCHECK(recipient_);
- }
- virtual ~SyncChangeProcessorDelegate() {}
-
- // syncer::SyncChangeProcessor implementation.
- virtual syncer::SyncError ProcessSyncChanges(
- const tracked_objects::Location& from_here,
- const syncer::SyncChangeList& change_list) OVERRIDE {
- return recipient_->ProcessSyncChanges(from_here, change_list);
- }
-
- virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const
- OVERRIDE {
- return recipient_->GetAllSyncData(type);
- }
-
- private:
- // The recipient of all sync changes.
- syncer::SyncChangeProcessor* recipient_;
-
- DISALLOW_COPY_AND_ASSIGN(SyncChangeProcessorDelegate);
-};
-
class MockSchemaRegistryObserver : public policy::SchemaRegistry::Observer {
public:
MockSchemaRegistryObserver() {}
class ExtensionSettingsApiTest : public ExtensionApiTest {
protected:
- virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+ void SetUpInProcessBrowserTestFixture() override {
ExtensionApiTest::SetUpInProcessBrowserTestFixture();
#if defined(ENABLE_CONFIGURATION_POLICY)
settings_namespace, normal_action, incognito_action, NULL, true);
}
+ syncer::SyncableService* GetSyncableService() {
+ return settings_sync_util::GetSyncableService(browser()->profile(),
+ kModelType);
+ }
+
void InitSync(syncer::SyncChangeProcessor* sync_processor) {
base::MessageLoop::current()->RunUntilIdle();
- InitSyncWithSyncableService(
- sync_processor,
- browser()->profile()->GetExtensionService()->settings_frontend()->
- GetBackendForSync(kModelType));
+ InitSyncWithSyncableService(sync_processor, GetSyncableService());
}
void SendChanges(const syncer::SyncChangeList& change_list) {
base::MessageLoop::current()->RunUntilIdle();
- SendChangesToSyncableService(
- change_list,
- browser()->profile()->GetExtensionService()->settings_frontend()->
- GetBackendForSync(kModelType));
+ SendChangesToSyncableService(change_list, GetSyncableService());
}
#if defined(ENABLE_CONFIGURATION_POLICY)
void InitSyncWithSyncableService(
syncer::SyncChangeProcessor* sync_processor,
syncer::SyncableService* settings_service) {
- EXPECT_FALSE(settings_service->MergeDataAndStartSyncing(
- kModelType,
- syncer::SyncDataList(),
- scoped_ptr<syncer::SyncChangeProcessor>(
- new SyncChangeProcessorDelegate(sync_processor)),
- scoped_ptr<syncer::SyncErrorFactory>(
- new syncer::SyncErrorFactoryMock())).error().IsSet());
+ EXPECT_FALSE(
+ settings_service->MergeDataAndStartSyncing(
+ kModelType,
+ syncer::SyncDataList(),
+ scoped_ptr<syncer::SyncChangeProcessor>(
+ new syncer::SyncChangeProcessorWrapperForTest(
+ sync_processor)),
+ scoped_ptr<syncer::SyncErrorFactory>(
+ new syncer::SyncErrorFactoryMock()))
+ .error()
+ .IsSet());
}
void SendChangesToSyncableService(
// We need 2 ResultCatchers because we'll be running the same test in both
// regular and incognito mode.
ResultCatcher catcher, catcher_incognito;
- catcher.RestrictToProfile(browser()->profile());
- catcher_incognito.RestrictToProfile(
+ catcher.RestrictToBrowserContext(browser()->profile());
+ catcher_incognito.RestrictToBrowserContext(
browser()->profile()->GetOffTheRecordProfile());
LoadAndReplyWhenSatisfied(SYNC,
// We need 2 ResultCatchers because we'll be running the same test in both
// regular and incognito mode.
ResultCatcher catcher, catcher_incognito;
- catcher.RestrictToProfile(browser()->profile());
- catcher_incognito.RestrictToProfile(
+ catcher.RestrictToBrowserContext(browser()->profile());
+ catcher_incognito.RestrictToBrowserContext(
browser()->profile()->GetOffTheRecordProfile());
LoadAndReplyWhenSatisfied(SYNC,
// We need 2 ResultCatchers because we'll be running the same test in both
// regular and incognito mode.
ResultCatcher catcher, catcher_incognito;
- catcher.RestrictToProfile(browser()->profile());
- catcher_incognito.RestrictToProfile(
+ catcher.RestrictToBrowserContext(browser()->profile());
+ catcher_incognito.RestrictToBrowserContext(
browser()->profile()->GetOffTheRecordProfile());
LoadAndReplyWhenSatisfied(SYNC,
// We need 2 ResultCatchers because we'll be running the same test in both
// regular and incognito mode.
ResultCatcher catcher, catcher_incognito;
- catcher.RestrictToProfile(browser()->profile());
- catcher_incognito.RestrictToProfile(
+ catcher.RestrictToBrowserContext(browser()->profile());
+ catcher_incognito.RestrictToBrowserContext(
browser()->profile()->GetOffTheRecordProfile());
const Extension* extension =
"assertNoNotifications", "assertNoNotifications", "split_incognito");
const std::string& extension_id = extension->id();
- NoopSyncChangeProcessor sync_processor;
+ syncer::FakeSyncChangeProcessor sync_processor;
InitSync(&sync_processor);
// Set "foo" to "bar" via sync.
// We need 2 ResultCatchers because we'll be running the same test in both
// regular and incognito mode.
ResultCatcher catcher, catcher_incognito;
- catcher.RestrictToProfile(browser()->profile());
- catcher_incognito.RestrictToProfile(
+ catcher.RestrictToBrowserContext(browser()->profile());
+ catcher_incognito.RestrictToBrowserContext(
browser()->profile()->GetOffTheRecordProfile());
const Extension* extension =
"assertNoNotifications", "assertNoNotifications", "split_incognito");
const std::string& extension_id = extension->id();
- NoopSyncChangeProcessor sync_processor;
+ syncer::FakeSyncChangeProcessor sync_processor;
InitSync(&sync_processor);
// Set "foo" to "bar" via sync.
}
IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, IsStorageEnabled) {
- SettingsFrontend* frontend =
- browser()->profile()->GetExtensionService()->settings_frontend();
+ StorageFrontend* frontend = StorageFrontend::Get(browser()->profile());
EXPECT_TRUE(frontend->IsStorageEnabled(LOCAL));
EXPECT_TRUE(frontend->IsStorageEnabled(SYNC));
IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ExtensionsSchemas) {
// Verifies that the Schemas for the extensions domain are created on startup.
Profile* profile = browser()->profile();
- ExtensionSystem* extension_system =
- ExtensionSystemFactory::GetForProfile(profile);
+ ExtensionSystem* extension_system = ExtensionSystem::Get(profile);
if (!extension_system->ready().is_signaled()) {
// Wait until the extension system is ready.
base::RunLoop run_loop;
message_.clear();
policy::SchemaRegistry* registry =
- policy::SchemaRegistryServiceFactory::GetForContext(profile);
+ policy::SchemaRegistryServiceFactory::GetForContext(profile)->registry();
ASSERT_TRUE(registry);
EXPECT_FALSE(registry->schema_map()->GetSchema(policy::PolicyNamespace(
policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId)));
IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ManagedStorageDisabled) {
// Disable the 'managed' namespace. This is redundant when
// ENABLE_CONFIGURATION_POLICY is not defined.
- SettingsFrontend* frontend =
- browser()->profile()->GetExtensionService()->settings_frontend();
+ StorageFrontend* frontend = StorageFrontend::Get(browser()->profile());
frontend->DisableStorageForTesting(MANAGED);
EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED));
// Now run the extension.