| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_ |
| 6 #define EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_ | 6 #define EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <set> | 9 #include <set> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 16 #include "extensions/browser/api/storage/settings_namespace.h" | 16 #include "extensions/browser/api/storage/settings_namespace.h" |
| 17 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
| 18 #include "extensions/browser/mock_extension_system.h" | 18 #include "extensions/browser/mock_extension_system.h" |
| 19 #include "extensions/browser/value_store/value_store_factory.h" | 19 #include "extensions/browser/value_store/value_store_factory.h" |
| 20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 21 | 21 |
| 22 class ValueStore; | 22 class ValueStore; |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 | 25 |
| 26 class StorageFrontend; | 26 class StorageFrontend; |
| 27 // Utilities for extension settings API tests. | 27 // Utilities for extension settings API tests. |
| 28 namespace settings_test_util { | 28 namespace settings_test_util { |
| 29 | 29 |
| 30 // Creates a kilobyte of data. | 30 // Creates a kilobyte of data. |
| 31 scoped_ptr<base::Value> CreateKilobyte(); | 31 std::unique_ptr<base::Value> CreateKilobyte(); |
| 32 | 32 |
| 33 // Creates a megabyte of data. | 33 // Creates a megabyte of data. |
| 34 scoped_ptr<base::Value> CreateMegabyte(); | 34 std::unique_ptr<base::Value> CreateMegabyte(); |
| 35 | 35 |
| 36 // Synchronously gets the storage area for an extension from |frontend|. | 36 // Synchronously gets the storage area for an extension from |frontend|. |
| 37 ValueStore* GetStorage(scoped_refptr<const Extension> extension, | 37 ValueStore* GetStorage(scoped_refptr<const Extension> extension, |
| 38 settings_namespace::Namespace setting_namespace, | 38 settings_namespace::Namespace setting_namespace, |
| 39 StorageFrontend* frontend); | 39 StorageFrontend* frontend); |
| 40 | 40 |
| 41 // Synchronously gets the SYNC storage for an extension from |frontend|. | 41 // Synchronously gets the SYNC storage for an extension from |frontend|. |
| 42 ValueStore* GetStorage(scoped_refptr<const Extension> extension, | 42 ValueStore* GetStorage(scoped_refptr<const Extension> extension, |
| 43 StorageFrontend* frontend); | 43 StorageFrontend* frontend); |
| 44 | 44 |
| 45 // Creates an extension with |id| and adds it to the registry for |context|. | 45 // Creates an extension with |id| and adds it to the registry for |context|. |
| 46 scoped_refptr<const Extension> AddExtensionWithId( | 46 scoped_refptr<const Extension> AddExtensionWithId( |
| 47 content::BrowserContext* context, | 47 content::BrowserContext* context, |
| 48 const std::string& id, | 48 const std::string& id, |
| 49 Manifest::Type type); | 49 Manifest::Type type); |
| 50 | 50 |
| 51 // Creates an extension with |id| with a set of |permissions| and adds it to | 51 // Creates an extension with |id| with a set of |permissions| and adds it to |
| 52 // the registry for |context|. | 52 // the registry for |context|. |
| 53 scoped_refptr<const Extension> AddExtensionWithIdAndPermissions( | 53 scoped_refptr<const Extension> AddExtensionWithIdAndPermissions( |
| 54 content::BrowserContext* context, | 54 content::BrowserContext* context, |
| 55 const std::string& id, | 55 const std::string& id, |
| 56 Manifest::Type type, | 56 Manifest::Type type, |
| 57 const std::set<std::string>& permissions); | 57 const std::set<std::string>& permissions); |
| 58 | 58 |
| 59 } // namespace settings_test_util | 59 } // namespace settings_test_util |
| 60 | 60 |
| 61 } // namespace extensions | 61 } // namespace extensions |
| 62 | 62 |
| 63 #endif // EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_ | 63 #endif // EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_ |
| OLD | NEW |