1// Copyright 2017 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 EXTENSIONS_COMMON_HASHED_EXTENSION_ID_H_
6#define EXTENSIONS_COMMON_HASHED_EXTENSION_ID_H_
7
8#include <string>
9
10#include "extensions/common/extension_id.h"
11
12namespace extensions {
13
14// A wrapper around a hex-encoded SHA1 hash of an extension ID. This struct is
15// primarily to enforce type-safety, but also offers handy construction. The
16// hashed ID of an extension is used to determine feature availability.
17class HashedExtensionId {
18 public:
19 // Default constructor to initialize with an empty value. It'd be nice to get
20 // rid of this, but certain objects (like Manifest) don't have a valid ID at
21 // construction.
22 HashedExtensionId();
23
24 // Initialize a HashedExtensionId, given the original.
25 explicit HashedExtensionId(const ExtensionId& original_id);
26
27 HashedExtensionId(HashedExtensionId&& other);
28 HashedExtensionId(const HashedExtensionId& other);
29 HashedExtensionId& operator=(HashedExtensionId&& other);
30 HashedExtensionId& operator=(const HashedExtensionId& other);
31
32 const std::string& value() const { return value_; }
33
34 private:
35 // Not const to allow for assignment.
36 std::string value_;
37};
38
39} // namespace extensions
40
41#endif // EXTENSIONS_COMMON_HASHED_EXTENSION_ID_H_
42