OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 | 15 |
16 class WebViewGuest; | 16 class WebViewGuest; |
17 | 17 |
| 18 namespace content { |
| 19 class ResourceRequestInfo; |
| 20 } |
| 21 |
18 // This class keeps track of renderer state for use on the IO thread. All | 22 // This class keeps track of renderer state for use on the IO thread. All |
19 // methods should be called on the IO thread except for Init and Shutdown. | 23 // methods should be called on the IO thread except for Init and Shutdown. |
20 class ExtensionRendererState { | 24 class ExtensionRendererState { |
21 public: | 25 public: |
22 struct WebViewInfo { | 26 struct WebViewInfo { |
23 int embedder_process_id; | 27 int embedder_process_id; |
24 int instance_id; | 28 int instance_id; |
25 std::string partition_id; | 29 std::string partition_id; |
26 std::string extension_id; | 30 std::string extension_id; |
27 bool allow_chrome_extension_urls; | 31 bool allow_chrome_extension_urls; |
28 }; | 32 }; |
29 | 33 |
30 static ExtensionRendererState* GetInstance(); | 34 static ExtensionRendererState* GetInstance(); |
31 | 35 |
32 // These are called on the UI thread to start and stop listening to tab | 36 // These are called on the UI thread to start and stop listening to tab |
33 // notifications. | 37 // notifications. |
34 void Init(); | 38 void Init(); |
35 void Shutdown(); | 39 void Shutdown(); |
36 | 40 |
37 // Looks up the information for the embedder <webview> for a given render | 41 // Looks up the information for the embedder <webview> for a given render |
38 // view, if one exists. Called on the IO thread. | 42 // view, if one exists. Called on the IO thread. |
39 bool GetWebViewInfo(int guest_process_id, int guest_routing_id, | 43 bool GetWebViewInfo(int guest_process_id, int guest_routing_id, |
40 WebViewInfo* webview_info); | 44 WebViewInfo* webview_info); |
41 | 45 |
42 // Looks up the tab and window ID for a given render view. Returns true | 46 // Looks up the tab and window ID for a given request. Returns true if we have |
43 // if we have the IDs in our map. Called on the IO thread. | 47 // the IDs in our map. Called on the IO thread. |
44 bool GetTabAndWindowId( | 48 bool GetTabAndWindowId( |
45 int render_process_host_id, int routing_id, int* tab_id, int* window_id); | 49 const content::ResourceRequestInfo* info, int* tab_id, int* window_id); |
46 | 50 |
47 // Returns true if the given renderer is used by webviews. | 51 // Returns true if the given renderer is used by webviews. |
48 bool IsWebViewRenderer(int render_process_id); | 52 bool IsWebViewRenderer(int render_process_id); |
49 | 53 |
50 private: | 54 private: |
51 class RenderViewHostObserver; | 55 class RenderViewHostObserver; |
52 class TabObserver; | 56 class TabObserver; |
53 friend class TabObserver; | 57 friend class TabObserver; |
54 friend class WebViewGuest; | 58 friend class WebViewGuest; |
55 friend struct DefaultSingletonTraits<ExtensionRendererState>; | 59 friend struct DefaultSingletonTraits<ExtensionRendererState>; |
(...skipping 18 matching lines...) Expand all Loading... |
74 void RemoveWebView(int render_process_host_id, int routing_id); | 78 void RemoveWebView(int render_process_host_id, int routing_id); |
75 | 79 |
76 TabObserver* observer_; | 80 TabObserver* observer_; |
77 TabAndWindowIdMap map_; | 81 TabAndWindowIdMap map_; |
78 WebViewInfoMap webview_info_map_; | 82 WebViewInfoMap webview_info_map_; |
79 | 83 |
80 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState); | 84 DISALLOW_COPY_AND_ASSIGN(ExtensionRendererState); |
81 }; | 85 }; |
82 | 86 |
83 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ | 87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_RENDERER_STATE_H_ |
OLD | NEW |