summaryrefslogtreecommitdiff
path: root/chromium/extensions/common/extension_builder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/extensions/common/extension_builder.cc')
-rw-r--r--chromium/extensions/common/extension_builder.cc80
1 files changed, 80 insertions, 0 deletions
diff --git a/chromium/extensions/common/extension_builder.cc b/chromium/extensions/common/extension_builder.cc
new file mode 100644
index 00000000000..905ba6b2dfa
--- /dev/null
+++ b/chromium/extensions/common/extension_builder.cc
@@ -0,0 +1,80 @@
+// 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 <utility>
+
+#include "extensions/common/extension.h"
+
+namespace extensions {
+
+ExtensionBuilder::ExtensionBuilder()
+ : location_(Manifest::UNPACKED),
+ flags_(Extension::NO_FLAGS) {
+}
+ExtensionBuilder::~ExtensionBuilder() {}
+
+ExtensionBuilder::ExtensionBuilder(ExtensionBuilder&& other)
+ : path_(std::move(other.path_)),
+ location_(other.location_),
+ manifest_(std::move(other.manifest_)),
+ flags_(other.flags_),
+ id_(std::move(other.id_)) {}
+
+ExtensionBuilder& ExtensionBuilder::operator=(ExtensionBuilder&& other) {
+ path_ = std::move(other.path_);
+ location_ = other.location_;
+ manifest_ = std::move(other.manifest_);
+ flags_ = other.flags_;
+ id_ = std::move(other.id_);
+ return *this;
+}
+
+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_ = std::move(manifest);
+ return *this;
+}
+
+ExtensionBuilder& ExtensionBuilder::MergeManifest(
+ scoped_ptr<base::DictionaryValue> manifest) {
+ manifest_->MergeDictionary(manifest.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