Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: chrome/common/extensions/extension_builder.h

Issue 48643003: Moved extension and value builder code to extensions component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_
7
8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/common/extensions/value_builder.h"
12 #include "extensions/common/manifest.h"
13
14 namespace extensions {
15 class Extension;
16
17 // An easier way to create extensions than Extension::Create. The
18 // constructor sets up some defaults which are customized using the
19 // methods. The only method that must be called is SetManifest().
20 class ExtensionBuilder {
21 public:
22 ExtensionBuilder();
23 ~ExtensionBuilder();
24
25 // Can only be called once, after which it's invalid to use the builder.
26 // CHECKs that the extension was created successfully.
27 scoped_refptr<Extension> Build();
28
29 // Workaround to allow you to pass rvalue ExtensionBuilders by reference to
30 // other functions, e.g. UseBuilder(ExtensionBuilder().Pass())
31 ExtensionBuilder& Pass() { return *this; }
32
33 // Defaults to FilePath().
34 ExtensionBuilder& SetPath(const base::FilePath& path);
35
36 // Defaults to Manifest::UNPACKED.
37 ExtensionBuilder& SetLocation(Manifest::Location location);
38
39 ExtensionBuilder& SetManifest(scoped_ptr<base::DictionaryValue> manifest);
40 ExtensionBuilder& SetManifest(DictionaryBuilder& manifest_builder) {
41 return SetManifest(manifest_builder.Build());
42 }
43
44 // Adds the keys from the DictionaryBuilder to the manifest, with new keys
45 // taking precedence.
46 ExtensionBuilder& MergeManifest(DictionaryBuilder& builder);
47
48 ExtensionBuilder& AddFlags(int init_from_value_flags);
49
50 // Defaults to the default extension ID created in Extension::Create.
51 ExtensionBuilder& SetID(const std::string& id);
52
53 private:
54 base::FilePath path_;
55 Manifest::Location location_;
56 scoped_ptr<base::DictionaryValue> manifest_;
57 int flags_;
58 std::string id_;
59 };
60
61 } // namespace extensions
62
63 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698