OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COMMON_EXTENSION_BUILDER_H_ | 5 #ifndef EXTENSIONS_COMMON_EXTENSION_BUILDER_H_ |
6 #define EXTENSIONS_COMMON_EXTENSION_BUILDER_H_ | 6 #define EXTENSIONS_COMMON_EXTENSION_BUILDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "extensions/common/manifest.h" | 13 #include "extensions/common/manifest.h" |
14 #include "extensions/common/value_builder.h" | 14 #include "extensions/common/value_builder.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 class Extension; | 17 class Extension; |
18 | 18 |
19 // An easier way to create extensions than Extension::Create. The | 19 // An easier way to create extensions than Extension::Create. The |
20 // constructor sets up some defaults which are customized using the | 20 // constructor sets up some defaults which are customized using the |
21 // methods. The only method that must be called is SetManifest(). | 21 // methods. The only method that must be called is SetManifest(). |
22 class ExtensionBuilder { | 22 class ExtensionBuilder { |
23 public: | 23 public: |
24 ExtensionBuilder(); | 24 ExtensionBuilder(); |
25 ~ExtensionBuilder(); | 25 ~ExtensionBuilder(); |
26 | 26 |
27 ExtensionBuilder(ExtensionBuilder&& other); | |
danakj
2015/12/09 18:46:44
you should make a move-operator= when you add a mo
limasdf
2015/12/16 09:34:54
Yes, https://www.chromium.org/rvalue-references #9
| |
28 | |
27 // Can only be called once, after which it's invalid to use the builder. | 29 // Can only be called once, after which it's invalid to use the builder. |
28 // CHECKs that the extension was created successfully. | 30 // CHECKs that the extension was created successfully. |
29 scoped_refptr<Extension> Build(); | 31 scoped_refptr<Extension> Build(); |
30 | 32 |
31 // Workaround to allow you to pass rvalue ExtensionBuilders by reference to | |
32 // other functions, e.g. UseBuilder(ExtensionBuilder().Pass()) | |
33 ExtensionBuilder& Pass() { return *this; } | |
34 | |
35 // Defaults to FilePath(). | 33 // Defaults to FilePath(). |
36 ExtensionBuilder& SetPath(const base::FilePath& path); | 34 ExtensionBuilder& SetPath(const base::FilePath& path); |
37 | 35 |
38 // Defaults to Manifest::UNPACKED. | 36 // Defaults to Manifest::UNPACKED. |
39 ExtensionBuilder& SetLocation(Manifest::Location location); | 37 ExtensionBuilder& SetLocation(Manifest::Location location); |
40 | 38 |
41 ExtensionBuilder& SetManifest(scoped_ptr<base::DictionaryValue> manifest); | 39 ExtensionBuilder& SetManifest(scoped_ptr<base::DictionaryValue> manifest); |
42 ExtensionBuilder& SetManifest(DictionaryBuilder& manifest_builder) { | 40 ExtensionBuilder& SetManifest(DictionaryBuilder& manifest_builder) { |
43 return SetManifest(manifest_builder.Build()); | 41 return SetManifest(manifest_builder.Build()); |
44 } | 42 } |
(...skipping 11 matching lines...) Expand all Loading... | |
56 base::FilePath path_; | 54 base::FilePath path_; |
57 Manifest::Location location_; | 55 Manifest::Location location_; |
58 scoped_ptr<base::DictionaryValue> manifest_; | 56 scoped_ptr<base::DictionaryValue> manifest_; |
59 int flags_; | 57 int flags_; |
60 std::string id_; | 58 std::string id_; |
61 }; | 59 }; |
62 | 60 |
63 } // namespace extensions | 61 } // namespace extensions |
64 | 62 |
65 #endif // EXTENSIONS_COMMON_EXTENSION_BUILDER_H_ | 63 #endif // EXTENSIONS_COMMON_EXTENSION_BUILDER_H_ |
OLD | NEW |