Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / extensions / common / extension_builder.cc
blobf993e9467ac89758efc2c1e50f0fe50c82d2d4a6
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
3 // found in the LICENSE file.
5 #include "extensions/common/extension_builder.h"
7 #include "extensions/common/extension.h"
9 namespace extensions {
11 ExtensionBuilder::ExtensionBuilder()
12 : location_(Manifest::UNPACKED),
13 flags_(Extension::NO_FLAGS) {
15 ExtensionBuilder::~ExtensionBuilder() {}
17 scoped_refptr<Extension> ExtensionBuilder::Build() {
18 std::string error;
19 scoped_refptr<Extension> extension = Extension::Create(
20 path_,
21 location_,
22 *manifest_,
23 flags_,
24 id_,
25 &error);
26 CHECK_EQ("", error);
27 return extension;
30 ExtensionBuilder& ExtensionBuilder::SetPath(const base::FilePath& path) {
31 path_ = path;
32 return *this;
35 ExtensionBuilder& ExtensionBuilder::SetLocation(Manifest::Location location) {
36 location_ = location;
37 return *this;
40 ExtensionBuilder& ExtensionBuilder::SetManifest(
41 scoped_ptr<base::DictionaryValue> manifest) {
42 manifest_ = manifest.Pass();
43 return *this;
46 ExtensionBuilder& ExtensionBuilder::MergeManifest(DictionaryBuilder& builder) {
47 manifest_->MergeDictionary(builder.Build().get());
48 return *this;
51 ExtensionBuilder& ExtensionBuilder::AddFlags(int init_from_value_flags) {
52 flags_ |= init_from_value_flags;
53 return *this;
56 ExtensionBuilder& ExtensionBuilder::SetID(const std::string& id) {
57 id_ = id;
58 return *this;
61 } // namespace extensions