Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_renderer_state.h
bloba47c5b503af629183e056ae54c26b9d9c12beb68
1 // Copyright (c) 2013 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <utility>
13 #include "base/basictypes.h"
14 #include "base/memory/singleton.h"
16 class WebViewGuest;
18 namespace content {
19 class ResourceRequestInfo;
22 // This class keeps track of renderer state for use on the IO thread. All
23 // methods should be called on the IO thread except for Init and Shutdown.
24 class ExtensionRendererState {
25 public:
26 struct WebViewInfo {
27 int embedder_process_id;
28 int instance_id;
29 std::string partition_id;
30 std::string extension_id;
31 bool allow_chrome_extension_urls;
34 static ExtensionRendererState* GetInstance();
36 // These are called on the UI thread to start and stop listening to tab
37 // notifications.
38 void Init();
39 void Shutdown();
41 // Looks up the information for the embedder <webview> for a given render
42 // view, if one exists. Called on the IO thread.
43 bool GetWebViewInfo(int guest_process_id, int guest_routing_id,
44 WebViewInfo* webview_info);
46 // Looks up the tab and window ID for a given request. Returns true if we have
47 // the IDs in our map. Called on the IO thread.
48 bool GetTabAndWindowId(
49 const content::ResourceRequestInfo* info, int* tab_id, int* window_id);
51 // Returns true if the given renderer is used by webviews.
52 bool IsWebViewRenderer(int render_process_id);
54 private:
55 class RenderViewHostObserver;
56 class TabObserver;
57 friend class TabObserver;
58 friend class WebViewGuest;
59 friend struct DefaultSingletonTraits<ExtensionRendererState>;
61 typedef std::pair<int, int> RenderId;
62 typedef std::pair<int, int> TabAndWindowId;
63 typedef std::map<RenderId, TabAndWindowId> TabAndWindowIdMap;
64 typedef std::map<RenderId, WebViewInfo> WebViewInfoMap;
66 ExtensionRendererState();
67 ~ExtensionRendererState();
69 // Adds or removes a render view from our map.
70 void SetTabAndWindowId(
71 int render_process_host_id, int routing_id, int tab_id, int window_id);
72 void ClearTabAndWindowId(
73 int render_process_host_id, int routing_id);
75 // Adds or removes a <webview> guest render process from the set.
76 void AddWebView(int render_process_host_id, int routing_id,
77 const WebViewInfo& webview_info);
78 void RemoveWebView(int render_process_host_id, int routing_id);
80 TabObserver* observer_;
81 TabAndWindowIdMap map_;
82 WebViewInfoMap webview_info_map_;
84 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState);
87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_