Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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_CONSUMER_H_ | |
| 6 #define EXTENSIONS_COMMON_CONSUMER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 | |
| 12 // IDs of API consumers who own user scripts. | |
| 13 // For example: an extension, a <webview> created by an extension, | |
| 14 // a <webview> created by WebUI, ... | |
| 15 class ConsumerID { | |
| 16 public: | |
| 17 // The type of a host who contains regular tabs or <webview>s. | |
| 18 enum HostType { EXTENSIONS, WEBUI }; | |
| 19 | |
| 20 enum InstanceType { TAB, WEBVIEW }; | |
| 21 | |
| 22 // Default instance ID of a consumer who owns staticlly-defined user scripts. | |
| 23 static const int kDefaultInstanceID; | |
| 24 | |
| 25 ConsumerID(); | |
|
Fady Samuel
2015/01/07 19:19:40
Is this necessary?
Xi Han
2015/01/07 20:28:42
Yes, the ConsumerID() creates an empty ID for exte
| |
| 26 explicit ConsumerID(const ConsumerID& other); | |
| 27 ConsumerID(HostType host_type, | |
| 28 const std::string& host_id, | |
| 29 InstanceType instance_type, | |
| 30 int instance_id); | |
| 31 ~ConsumerID(); | |
| 32 | |
| 33 bool operator<(const ConsumerID& id) const; | |
| 34 | |
| 35 HostType host_type() const { return host_type_; } | |
| 36 const std::string& host_id() const { return host_id_; } | |
| 37 InstanceType instance_type() const { return instance_type_; } | |
| 38 int instance_id() const { return instance_id_; } | |
| 39 | |
| 40 private: | |
| 41 // Extension, or WebUI, ... | |
| 42 HostType host_type_; | |
|
Fady Samuel
2015/01/07 19:19:40
Mark as const HostType host_type_.
This tells dev
Xi Han
2015/01/07 20:28:42
I tried the "const" keyword, but a "const" member
| |
| 43 | |
| 44 // Similar to extension_id, host_id is a uniquely indentifier for a host, | |
| 45 // e.g., an Extension or WebUI. | |
| 46 std::string host_id_; | |
|
Fady Samuel
2015/01/07 19:19:40
Mark as const.
Xi Han
2015/01/07 20:28:42
Same as HostType.
| |
| 47 | |
| 48 // A tab or a <webiew>. | |
| 49 InstanceType instance_type_; | |
|
Fady Samuel
2015/01/07 19:19:40
Mark as const.
Xi Han
2015/01/07 20:28:42
Same as HostType.
| |
| 50 | |
| 51 // For a consumer that owns staticlly defined user scripts, the | |
| 52 // |instance_id| is 0; | |
| 53 // For a consumer that owns declarative user scripts, the |instance_id| | |
| 54 // is assigned by DeclarativeUserScriptManager when the consumer requests a | |
| 55 // master object. | |
| 56 int instance_id_; | |
|
Fady Samuel
2015/01/07 19:19:40
Mark as const.
Xi Han
2015/01/07 20:28:42
Same as HostType.
| |
| 57 }; | |
| 58 | |
| 59 // Represents an API consumer. | |
| 60 class Consumer { | |
| 61 public: | |
| 62 Consumer(); | |
| 63 virtual ~Consumer(); | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(Consumer); | |
| 66 }; | |
| 67 | |
| 68 #endif // EXTENSIONS_COMMON_CONSUMER_H_ | |
| OLD | NEW |