hashed_extension_id.h 1.3 KB

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