blob: f993e9467ac89758efc2c1e50f0fe50c82d2d4a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension.h"
namespace extensions {
ExtensionBuilder::ExtensionBuilder()
: location_(Manifest::UNPACKED),
flags_(Extension::NO_FLAGS) {
}
ExtensionBuilder::~ExtensionBuilder() {}
scoped_refptr<Extension> ExtensionBuilder::Build() {
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
path_,
location_,
*manifest_,
flags_,
id_,
&error);
CHECK_EQ("", error);
return extension;
}
ExtensionBuilder& ExtensionBuilder::SetPath(const base::FilePath& path) {
path_ = path;
return *this;
}
ExtensionBuilder& ExtensionBuilder::SetLocation(Manifest::Location location) {
location_ = location;
return *this;
}
ExtensionBuilder& ExtensionBuilder::SetManifest(
scoped_ptr<base::DictionaryValue> manifest) {
manifest_ = manifest.Pass();
return *this;
}
ExtensionBuilder& ExtensionBuilder::MergeManifest(DictionaryBuilder& builder) {
manifest_->MergeDictionary(builder.Build().get());
return *this;
}
ExtensionBuilder& ExtensionBuilder::AddFlags(int init_from_value_flags) {
flags_ |= init_from_value_flags;
return *this;
}
ExtensionBuilder& ExtensionBuilder::SetID(const std::string& id) {
id_ = id;
return *this;
}
} // namespace extensions
|