Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: extensions/common/consumer.h

Issue 822453002: Introduce HostID and de-couple Extensions from "script injection System" [browser side] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // The type of a host who contains regular tabs or <webview>s.
13 enum HostType { EXTENSIONS, WEBUI };
Fady Samuel 2015/01/06 13:55:11 Do we support enum classes in chromium?
Xi Han 2015/01/07 18:57:04 Good point, I think there is example about enum cl
14
15 enum InstanceType { TAB, WEBVIEW };
16
17 // IDs of API consumers who own user scripts.
18 // For example: an extension, a <webview> created by an extension,
19 // a <webview> created by WebUI, ...
20 struct ConsumerID {
21 // Default instance ID of a consumer who owns staticlly-defined user scripts.
22 static const int kDefaultInstanceID;
23
24 ConsumerID();
25 ConsumerID(HostType host_type,
Fady Samuel 2015/01/06 13:55:11 Once we create a ConsumerID, do its fields ever ch
Xi Han 2015/01/07 18:57:04 As discussed offline, declare ConsumerID as a clas
26 const std::string& host_id,
27 InstanceType instance_type,
28 int instance_id);
29
30 bool operator<(const ConsumerID& id) const;
31
32 // Extension, or WebUI, ...
33 HostType host_type;
34
35 // Similar to extension_id, host_id is a uniquely indentifier for a host,
36 // e.g., an Extension or WebUI.
37 std::string host_id;
38
39 // A tab or a <webiew>
Fady Samuel 2015/01/06 13:55:11 period at the end of the comment.
Xi Han 2015/01/07 18:57:04 Done.
40 InstanceType instance_type;
41
42 // For a consumer who owns staticlly-defined user scripts, the
Fady Samuel 2015/01/06 13:55:11 For a consumer that owns statically defined user s
Xi Han 2015/01/07 18:57:04 Done.
43 // |instance_id| = 0;
44 // For a consumer who owns declarative user scripts, the |instance_id|
Fady Samuel 2015/01/06 13:55:11 change who to that.
Xi Han 2015/01/07 18:57:06 Done.
45 // is assigned by DeclarativeUserScriptManager when the consumer requests a
46 // master object.
47 int instance_id;
48 };
49
50 // Represents an API consumer.
51 class Consumer {
52 public:
53 Consumer();
54 virtual ~Consumer();
55
56 void set_id(const ConsumerID& id) { id_ = id; }
Fady Samuel 2015/01/06 13:55:11 Why is the ConsumerID not in the constructor?
Xi Han 2015/01/07 18:57:06 Think about it again, I remove the member variable
57 const ConsumerID& id() const { return id_; }
58
59 private:
60 ConsumerID id_;
61
62 DISALLOW_COPY_AND_ASSIGN(Consumer);
63 };
64
65 #endif // EXTENSIONS_COMMON_CONSUMER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698