webview/plugins: Allow manifest-listed resources to be loaded in plugins.
[chromium-blink-merge.git] / extensions / browser / guest_view / web_view / web_view_renderer_state.h
blob11af76d1c14dd9ae77022063d59aca9af8a1f5ab
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.
5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_
8 #include <map>
9 #include <string>
10 #include <utility>
12 #include "base/memory/singleton.h"
14 namespace extensions {
16 class WebViewGuest;
18 // This class keeps track of <webview> renderer state for use on the IO thread.
19 // All methods should be called on the IO thread.
20 class WebViewRendererState {
21 public:
22 struct WebViewInfo {
23 int embedder_process_id;
24 int instance_id;
25 int rules_registry_id;
26 std::string partition_id;
27 std::string owner_extension_id;
30 static WebViewRendererState* GetInstance();
32 // Looks up the information for the embedder <webview> for a given render
33 // view, if one exists. Called on the IO thread.
34 bool GetInfo(int guest_process_id, int guest_routing_id,
35 WebViewInfo* webview_info);
37 // Looks up the information for the owner for a given guest process in a
38 // <webview>. Called on the IO thread.
39 bool GetOwnerInfo(int guest_process_id,
40 int* owner_process_id,
41 std::string* owner_extension_id) const;
43 // Looks up the partition info for the embedder <webview> for a given guest
44 // process. Called on the IO thread.
45 bool GetPartitionID(int guest_process_id, std::string* partition_id);
47 // Returns true if the given renderer is used by webviews.
48 bool IsGuest(int render_process_id);
50 private:
51 friend class WebViewGuest;
52 friend struct DefaultSingletonTraits<WebViewRendererState>;
54 typedef std::pair<int, int> RenderId;
55 typedef std::map<RenderId, WebViewInfo> WebViewInfoMap;
57 struct WebViewPartitionInfo {
58 int web_view_count;
59 std::string partition_id;
60 WebViewPartitionInfo() {}
61 WebViewPartitionInfo(int count, std::string partition):
62 web_view_count(count),
63 partition_id(partition) {}
66 typedef std::map<int, WebViewPartitionInfo> WebViewPartitionIDMap;
68 WebViewRendererState();
69 ~WebViewRendererState();
71 // Adds or removes a <webview> guest render process from the set.
72 void AddGuest(int render_process_host_id, int routing_id,
73 const WebViewInfo& webview_info);
74 void RemoveGuest(int render_process_host_id, int routing_id);
76 WebViewInfoMap webview_info_map_;
77 WebViewPartitionIDMap webview_partition_id_map_;
79 DISALLOW_COPY_AND_ASSIGN(WebViewRendererState);
82 } // namespace extensions
84 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_