| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ | 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_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <utility> | 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 13 | 14 |
| 14 namespace extensions { | 15 namespace extensions { |
| 15 | 16 |
| 16 class WebViewGuest; | 17 class WebViewGuest; |
| 17 | 18 |
| 18 // This class keeps track of <webview> renderer state for use on the IO thread. | 19 // 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 // All methods should be called on the IO thread. |
| 20 class WebViewRendererState { | 21 class WebViewRendererState { |
| 21 public: | 22 public: |
| 22 struct WebViewInfo { | 23 struct WebViewInfo { |
| 23 int embedder_process_id; | 24 int embedder_process_id; |
| 24 int instance_id; | 25 int instance_id; |
| 25 int rules_registry_id; | 26 int rules_registry_id; |
| 26 std::string partition_id; | 27 std::string partition_id; |
| 27 std::string owner_extension_id; | 28 std::string owner_extension_id; |
| 29 std::set<int> content_script_ids; |
| 30 |
| 31 WebViewInfo(); |
| 32 ~WebViewInfo(); |
| 28 }; | 33 }; |
| 29 | 34 |
| 30 static WebViewRendererState* GetInstance(); | 35 static WebViewRendererState* GetInstance(); |
| 31 | 36 |
| 32 // Looks up the information for the embedder <webview> for a given render | 37 // Looks up the information for the embedder <webview> for a given render |
| 33 // view, if one exists. Called on the IO thread. | 38 // view, if one exists. Called on the IO thread. |
| 34 bool GetInfo(int guest_process_id, int guest_routing_id, | 39 bool GetInfo(int guest_process_id, int guest_routing_id, |
| 35 WebViewInfo* web_view_info); | 40 WebViewInfo* web_view_info); |
| 36 | 41 |
| 37 // Looks up the information for the owner for a given guest process in a | 42 // Looks up the information for the owner for a given guest process in a |
| 38 // <webview>. Called on the IO thread. | 43 // <webview>. Called on the IO thread. |
| 39 bool GetOwnerInfo(int guest_process_id, | 44 bool GetOwnerInfo(int guest_process_id, |
| 40 int* owner_process_id, | 45 int* owner_process_id, |
| 41 std::string* owner_extension_id) const; | 46 std::string* owner_extension_id) const; |
| 42 | 47 |
| 43 // Looks up the partition info for the embedder <webview> for a given guest | 48 // Looks up the partition info for the embedder <webview> for a given guest |
| 44 // process. Called on the IO thread. | 49 // process. Called on the IO thread. |
| 45 bool GetPartitionID(int guest_process_id, std::string* partition_id); | 50 bool GetPartitionID(int guest_process_id, std::string* partition_id); |
| 46 | 51 |
| 47 // Returns true if the given renderer is used by webviews. | 52 // Returns true if the given renderer is used by webviews. |
| 48 bool IsGuest(int render_process_id); | 53 bool IsGuest(int render_process_id); |
| 49 | 54 |
| 55 void AddContentScriptIDs(int embedder_process_id, |
| 56 int view_instance_id, |
| 57 const std::set<int>& script_ids); |
| 58 void RemoveContentScriptIDs(int embedder_process_id, |
| 59 int view_instance_id, |
| 60 const std::set<int>& script_ids); |
| 61 |
| 50 private: | 62 private: |
| 51 friend class WebViewGuest; | 63 friend class WebViewGuest; |
| 52 friend struct DefaultSingletonTraits<WebViewRendererState>; | 64 friend struct DefaultSingletonTraits<WebViewRendererState>; |
| 53 | 65 |
| 54 using RenderId = std::pair<int, int>; | 66 using RenderId = std::pair<int, int>; |
| 55 using WebViewInfoMap = std::map<RenderId, WebViewInfo>; | 67 using WebViewInfoMap = std::map<RenderId, WebViewInfo>; |
| 56 | 68 |
| 57 struct WebViewPartitionInfo { | 69 struct WebViewPartitionInfo { |
| 58 int web_view_count; | 70 int web_view_count; |
| 59 std::string partition_id; | 71 std::string partition_id; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 75 | 87 |
| 76 WebViewInfoMap web_view_info_map_; | 88 WebViewInfoMap web_view_info_map_; |
| 77 WebViewPartitionIDMap web_view_partition_id_map_; | 89 WebViewPartitionIDMap web_view_partition_id_map_; |
| 78 | 90 |
| 79 DISALLOW_COPY_AND_ASSIGN(WebViewRendererState); | 91 DISALLOW_COPY_AND_ASSIGN(WebViewRendererState); |
| 80 }; | 92 }; |
| 81 | 93 |
| 82 } // namespace extensions | 94 } // namespace extensions |
| 83 | 95 |
| 84 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ | 96 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ |
| OLD | NEW |