| 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 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_ |
| 7 | 7 |
| 8 #include "base/file_path.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/manifest.h" |
| 11 #include "chrome/common/extensions/value_builder.h" | 12 #include "chrome/common/extensions/value_builder.h" |
| 12 | 13 |
| 13 namespace extensions { | 14 namespace extensions { |
| 15 class Extension; |
| 14 | 16 |
| 15 // An easier way to create extensions than Extension::Create. The | 17 // An easier way to create extensions than Extension::Create. The |
| 16 // constructor sets up some defaults which are customized using the | 18 // constructor sets up some defaults which are customized using the |
| 17 // methods. The only method that must be called is SetManifest(). | 19 // methods. The only method that must be called is SetManifest(). |
| 18 class ExtensionBuilder { | 20 class ExtensionBuilder { |
| 19 public: | 21 public: |
| 20 ExtensionBuilder(); | 22 ExtensionBuilder(); |
| 21 ~ExtensionBuilder(); | 23 ~ExtensionBuilder(); |
| 22 | 24 |
| 23 // Can only be called once, after which it's invalid to use the builder. | 25 // Can only be called once, after which it's invalid to use the builder. |
| 24 // CHECKs that the extension was created successfully. | 26 // CHECKs that the extension was created successfully. |
| 25 scoped_refptr<Extension> Build(); | 27 scoped_refptr<Extension> Build(); |
| 26 | 28 |
| 27 // Defaults to FilePath(). | 29 // Defaults to FilePath(). |
| 28 ExtensionBuilder& SetPath(const FilePath& path); | 30 ExtensionBuilder& SetPath(const FilePath& path); |
| 29 | 31 |
| 30 // Defaults to Extension::LOAD. | 32 // Defaults to Manifest::LOAD. |
| 31 ExtensionBuilder& SetLocation(Extension::Location location); | 33 ExtensionBuilder& SetLocation(Manifest::Location location); |
| 32 | 34 |
| 33 ExtensionBuilder& SetManifest(scoped_ptr<base::DictionaryValue> manifest); | 35 ExtensionBuilder& SetManifest(scoped_ptr<base::DictionaryValue> manifest); |
| 34 ExtensionBuilder& SetManifest(DictionaryBuilder& manifest_builder) { | 36 ExtensionBuilder& SetManifest(DictionaryBuilder& manifest_builder) { |
| 35 return SetManifest(manifest_builder.Build()); | 37 return SetManifest(manifest_builder.Build()); |
| 36 } | 38 } |
| 37 | 39 |
| 38 ExtensionBuilder& AddFlags(int init_from_value_flags); | 40 ExtensionBuilder& AddFlags(int init_from_value_flags); |
| 39 | 41 |
| 40 // Defaults to the default extension ID created in Extension::Create. | 42 // Defaults to the default extension ID created in Extension::Create. |
| 41 ExtensionBuilder& SetID(const std::string& id); | 43 ExtensionBuilder& SetID(const std::string& id); |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 FilePath path_; | 46 FilePath path_; |
| 45 Extension::Location location_; | 47 Manifest::Location location_; |
| 46 scoped_ptr<base::DictionaryValue> manifest_; | 48 scoped_ptr<base::DictionaryValue> manifest_; |
| 47 int flags_; | 49 int flags_; |
| 48 std::string id_; | 50 std::string id_; |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 } // namespace extensions | 53 } // namespace extensions |
| 52 | 54 |
| 53 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_ | 55 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_ |
| OLD | NEW |