| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 9 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
| 10 #include "chrome/browser/extensions/api/storage/settings_namespace.h" | 10 #include "chrome/browser/extensions/api/storage/settings_namespace.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const char kManagedStorageExtensionId[] = "kjmkgkdkpedkejedfhmfcenooemhbpbo"; | 58 const char kManagedStorageExtensionId[] = "kjmkgkdkpedkejedfhmfcenooemhbpbo"; |
| 59 | 59 |
| 60 class NoopSyncChangeProcessor : public syncer::SyncChangeProcessor { | 60 class NoopSyncChangeProcessor : public syncer::SyncChangeProcessor { |
| 61 public: | 61 public: |
| 62 virtual syncer::SyncError ProcessSyncChanges( | 62 virtual syncer::SyncError ProcessSyncChanges( |
| 63 const tracked_objects::Location& from_here, | 63 const tracked_objects::Location& from_here, |
| 64 const syncer::SyncChangeList& change_list) OVERRIDE { | 64 const syncer::SyncChangeList& change_list) OVERRIDE { |
| 65 return syncer::SyncError(); | 65 return syncer::SyncError(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const |
| 69 OVERRIDE { |
| 70 return syncer::SyncDataList(); |
| 71 } |
| 72 |
| 68 virtual ~NoopSyncChangeProcessor() {}; | 73 virtual ~NoopSyncChangeProcessor() {}; |
| 69 }; | 74 }; |
| 70 | 75 |
| 71 class SyncChangeProcessorDelegate : public syncer::SyncChangeProcessor { | 76 class SyncChangeProcessorDelegate : public syncer::SyncChangeProcessor { |
| 72 public: | 77 public: |
| 73 explicit SyncChangeProcessorDelegate(syncer::SyncChangeProcessor* recipient) | 78 explicit SyncChangeProcessorDelegate(syncer::SyncChangeProcessor* recipient) |
| 74 : recipient_(recipient) { | 79 : recipient_(recipient) { |
| 75 DCHECK(recipient_); | 80 DCHECK(recipient_); |
| 76 } | 81 } |
| 77 virtual ~SyncChangeProcessorDelegate() {} | 82 virtual ~SyncChangeProcessorDelegate() {} |
| 78 | 83 |
| 79 // syncer::SyncChangeProcessor implementation. | 84 // syncer::SyncChangeProcessor implementation. |
| 80 virtual syncer::SyncError ProcessSyncChanges( | 85 virtual syncer::SyncError ProcessSyncChanges( |
| 81 const tracked_objects::Location& from_here, | 86 const tracked_objects::Location& from_here, |
| 82 const syncer::SyncChangeList& change_list) OVERRIDE { | 87 const syncer::SyncChangeList& change_list) OVERRIDE { |
| 83 return recipient_->ProcessSyncChanges(from_here, change_list); | 88 return recipient_->ProcessSyncChanges(from_here, change_list); |
| 84 } | 89 } |
| 85 | 90 |
| 91 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const |
| 92 OVERRIDE { |
| 93 return recipient_->GetAllSyncData(type); |
| 94 } |
| 95 |
| 86 private: | 96 private: |
| 87 // The recipient of all sync changes. | 97 // The recipient of all sync changes. |
| 88 syncer::SyncChangeProcessor* recipient_; | 98 syncer::SyncChangeProcessor* recipient_; |
| 89 | 99 |
| 90 DISALLOW_COPY_AND_ASSIGN(SyncChangeProcessorDelegate); | 100 DISALLOW_COPY_AND_ASSIGN(SyncChangeProcessorDelegate); |
| 91 }; | 101 }; |
| 92 | 102 |
| 93 } // namespace | 103 } // namespace |
| 94 | 104 |
| 95 class ExtensionSettingsApiTest : public ExtensionApiTest { | 105 class ExtensionSettingsApiTest : public ExtensionApiTest { |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 SettingsFrontend* frontend = | 558 SettingsFrontend* frontend = |
| 549 browser()->profile()->GetExtensionService()->settings_frontend(); | 559 browser()->profile()->GetExtensionService()->settings_frontend(); |
| 550 frontend->DisableStorageForTesting(MANAGED); | 560 frontend->DisableStorageForTesting(MANAGED); |
| 551 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); | 561 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); |
| 552 // Now run the extension. | 562 // Now run the extension. |
| 553 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) | 563 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) |
| 554 << message_; | 564 << message_; |
| 555 } | 565 } |
| 556 | 566 |
| 557 } // namespace extensions | 567 } // namespace extensions |
| OLD | NEW |