| Index: extensions/common/consumer.h
|
| diff --git a/extensions/common/consumer.h b/extensions/common/consumer.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9e66e10270e43fcdd4bec38698d70db1d0680739
|
| --- /dev/null
|
| +++ b/extensions/common/consumer.h
|
| @@ -0,0 +1,68 @@
|
| +// Copyright 2014 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.
|
| +
|
| +#ifndef EXTENSIONS_COMMON_CONSUMER_H_
|
| +#define EXTENSIONS_COMMON_CONSUMER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/macros.h"
|
| +
|
| +// IDs of API consumers who own user scripts.
|
| +// For example: an extension, a <webview> created by an extension,
|
| +// a <webview> created by WebUI, ...
|
| +class ConsumerID {
|
| + public:
|
| + // The type of a host who contains regular tabs or <webview>s.
|
| + enum HostType { EXTENSIONS, WEBUI };
|
| +
|
| + enum InstanceType { TAB, WEBVIEW };
|
| +
|
| + // Default instance ID of a consumer who owns staticlly-defined user scripts.
|
| + static const int kDefaultInstanceID;
|
| +
|
| + ConsumerID();
|
| + explicit ConsumerID(const ConsumerID& other);
|
| + ConsumerID(HostType host_type,
|
| + const std::string& host_id,
|
| + InstanceType instance_type,
|
| + int instance_id);
|
| + ~ConsumerID();
|
| +
|
| + bool operator<(const ConsumerID& id) const;
|
| +
|
| + HostType host_type() const { return host_type_; }
|
| + const std::string& host_id() const { return host_id_; }
|
| + InstanceType instance_type() const { return instance_type_; }
|
| + int instance_id() const { return instance_id_; }
|
| +
|
| + private:
|
| + // Extension, or WebUI, ...
|
| + const HostType host_type_;
|
| +
|
| + // Similar to extension_id, host_id is a uniquely indentifier for a host,
|
| + // e.g., an Extension or WebUI.
|
| + const std::string host_id_;
|
| +
|
| + // A tab or a <webiew>.
|
| + const InstanceType instance_type_;
|
| +
|
| + // For a consumer that owns staticlly defined user scripts, the
|
| + // |instance_id| is 0;
|
| + // For a consumer that owns declarative user scripts, the |instance_id|
|
| + // is assigned by DeclarativeUserScriptManager when the consumer requests a
|
| + // master object.
|
| + const int instance_id_;
|
| +};
|
| +
|
| +// Represents an API consumer.
|
| +class Consumer {
|
| + public:
|
| + Consumer();
|
| + virtual ~Consumer();
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(Consumer);
|
| +};
|
| +
|
| +#endif // EXTENSIONS_COMMON_CONSUMER_H_
|
|
|