hanxi | c0503d7 | 2015-02-05 14:27:32 | [diff] [blame] | 1 | // Copyright 2015 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_HOST_ID_H_ |
| 6 | #define EXTENSIONS_COMMON_HOST_ID_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | // IDs of hosts who own user scripts. |
| 11 | // A HostID is immutable after creation. |
| 12 | struct HostID { |
hanxi | 79f7a57 | 2015-03-09 20:46:59 | [diff] [blame] | 13 | enum HostType { EXTENSIONS, WEBUI, HOST_TYPE_LAST = WEBUI }; |
hanxi | c0503d7 | 2015-02-05 14:27:32 | [diff] [blame] | 14 | |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 15 | HostID(); |
| 16 | HostID(HostType type, const std::string& id); |
| 17 | HostID(const HostID& host_id); |
| 18 | ~HostID(); |
hanxi | c0503d7 | 2015-02-05 14:27:32 | [diff] [blame] | 19 | |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 20 | bool operator<(const HostID& host_id) const; |
| 21 | bool operator==(const HostID& host_id) const; |
hanxi | c0503d7 | 2015-02-05 14:27:32 | [diff] [blame] | 22 | |
| 23 | HostType type() const { return type_; } |
| 24 | const std::string& id() const { return id_; } |
| 25 | |
| 26 | private: |
| 27 | // The type of the host. |
| 28 | HostType type_; |
| 29 | |
| 30 | // Similar to extension_id, host_id is a unique indentifier for a host, |
| 31 | // e.g., an Extension or WebUI. |
| 32 | std::string id_; |
| 33 | }; |
| 34 | |
| 35 | #endif // EXTENSIONS_COMMON_HOST_ID_H_ |