| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 
| 6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 
| 7 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include <string> | 9 #include <string> | 
| 10 | 10 | 
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" | 
| 12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" | 
| 13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" | 
| 14 | 14 | 
| 15 class DictionaryValue; | 15 class DictionaryValue; | 
| 16 class ExtensionPrefs; | 16 class ExtensionPrefs; | 
| 17 class PrefService; | 17 class PrefService; | 
| 18 | 18 class Profile; | 
| 19 | 19 | 
| 20 // This is a test class intended to make it easier to work with ExtensionPrefs | 20 // This is a test class intended to make it easier to work with ExtensionPrefs | 
| 21 // in tests. | 21 // in tests. | 
| 22 class TestExtensionPrefs { | 22 class TestExtensionPrefs { | 
| 23  public: | 23  public: | 
| 24   TestExtensionPrefs(); | 24   TestExtensionPrefs(); | 
| 25   virtual ~TestExtensionPrefs(); | 25   virtual ~TestExtensionPrefs(); | 
| 26 | 26 | 
| 27   ExtensionPrefs* prefs() { return prefs_.get(); } | 27   ExtensionPrefs* prefs() { return prefs_.get(); } | 
| 28   PrefService* pref_service() { return pref_service_.get(); } | 28   PrefService* pref_service() { return pref_service_; } | 
| 29   const FilePath& temp_dir() const { return temp_dir_.path(); } | 29   const FilePath& temp_dir() const { return temp_dir_.path(); } | 
| 30 | 30 | 
| 31   // This will cause the ExtensionPrefs to be deleted and recreated, based on | 31   // This will cause the ExtensionPrefs to be deleted and recreated, based on | 
| 32   // any existing backing file we had previously created. | 32   // any existing backing file we had previously created. | 
| 33   void RecreateExtensionPrefs(); | 33   void RecreateExtensionPrefs(); | 
| 34 | 34 | 
| 35   // Creates a new Extension with the given name in our temp dir, adds it to | 35   // Creates a new Extension with the given name in our temp dir, adds it to | 
| 36   // our ExtensionPrefs, and returns it. | 36   // our ExtensionPrefs, and returns it. | 
| 37   scoped_refptr<Extension> AddExtension(std::string name); | 37   scoped_refptr<Extension> AddExtension(std::string name); | 
| 38 | 38 | 
| 39   // Similar to AddExtension, but takes a dictionary with manifest values. | 39   // Similar to AddExtension, but takes a dictionary with manifest values. | 
| 40   scoped_refptr<Extension> AddExtensionWithManifest( | 40   scoped_refptr<Extension> AddExtensionWithManifest( | 
| 41       const DictionaryValue& manifest, Extension::Location location); | 41       const DictionaryValue& manifest, Extension::Location location); | 
| 42 | 42 | 
| 43   // Similar to AddExtension, this adds a new test Extension. This is useful for | 43   // Similar to AddExtension, this adds a new test Extension. This is useful for | 
| 44   // cases when you don't need the Extension object, but just the id it was | 44   // cases when you don't need the Extension object, but just the id it was | 
| 45   // assigned. | 45   // assigned. | 
| 46   std::string AddExtensionAndReturnId(std::string name); | 46   std::string AddExtensionAndReturnId(std::string name); | 
| 47 | 47 | 
| 48  protected: | 48  protected: | 
| 49   ScopedTempDir temp_dir_; | 49   ScopedTempDir temp_dir_; | 
| 50   FilePath preferences_file_; | 50   FilePath preferences_file_; | 
| 51   FilePath extensions_dir_; | 51   FilePath extensions_dir_; | 
| 52   scoped_ptr<PrefService> pref_service_; | 52   PrefService* pref_service_;  // Weak pointer, owned by profile_. | 
| 53   scoped_ptr<ExtensionPrefs> prefs_; | 53   scoped_ptr<ExtensionPrefs> prefs_; | 
|  | 54   scoped_ptr<Profile> profile_; | 
| 54 | 55 | 
| 55  private: | 56  private: | 
| 56   DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs); | 57   DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs); | 
| 57 }; | 58 }; | 
| 58 | 59 | 
| 59 #endif  // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 60 #endif  // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 
| OLD | NEW | 
|---|