Index: extensions/browser/guest_view/web_view/web_view_content_script_manager.h |
diff --git a/extensions/browser/guest_view/web_view/web_view_content_script_manager.h b/extensions/browser/guest_view/web_view/web_view_content_script_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..68f02bb2f822151a4b70a154e1ce1c1525b3e78c |
--- /dev/null |
+++ b/extensions/browser/guest_view/web_view/web_view_content_script_manager.h |
@@ -0,0 +1,75 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGER_H |
+#define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGER_H |
+ |
+#include <map> |
+#include <set> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/supports_user_data.h" |
+ |
+struct HostID; |
+ |
+namespace content { |
+class BrowserContext; |
+} |
+ |
+namespace extensions { |
+class UserScript; |
+ |
+// WebViewContentScriptManager manages the content scripts that each webview |
+// guest adds and removes programmatically. |
+class WebViewContentScriptManager : public base::SupportsUserData::Data { |
+ public: |
+ explicit WebViewContentScriptManager( |
+ content::BrowserContext* browser_context); |
+ ~WebViewContentScriptManager() override; |
+ |
+ static WebViewContentScriptManager* Get( |
+ content::BrowserContext* browser_context); |
+ |
+ // Adds content scripts for the guest specified by the |embedder_process_id, |
+ // guest_view_instance_id|. |
+ // The name of each content sccript is its key in |user_scripts| map. |
+ void AddContentScripts(int embedder_process_id, |
+ int guest_view_instance_id, |
Fady Samuel
2015/03/31 23:40:12
nit: view_instnace_id
Xi Han
2015/04/01 22:14:41
Done.
|
+ const HostID& host_id, |
+ const std::map<std::string, UserScript>& user_scripts); |
+ |
+ // Removes contents scipts whose names are in the |script_name_list| for the |
+ // guest specified by |embedder_process_id, guest_view_instance_id|. |
+ // If the |script_name_list| is empty, removes all the content scripts added |
+ // for this guest. |
+ void RemoveContentScripts(int embedder_process_id, |
+ int guest_view_instance_id, |
+ const HostID& host_id, |
+ std::vector<std::string>* script_name_list); |
Fady Samuel
2015/03/31 23:40:12
const std::vector<std::string>& instead since this
Xi Han
2015/04/01 22:14:41
Done.
|
+ |
+ // Returns whether the content script with |script_id| belonges to the guest |
+ // specified by |embedder_process_id, guest_view_instance_id|. |
+ bool OwnsUserScript(int embedder_process_id, |
+ int guest_view_instance_id, |
Fady Samuel
2015/03/31 23:40:12
nit: view_instance_id
Xi Han
2015/04/01 22:14:41
Done.
|
+ int script_id); |
+ |
+ // Returns the content script IDs added by the guest specified by |
+ // |embedder_process_id, guest_view_instance_id|. |
+ std::set<int> GetContentScriptIdSet(int embedder_process_id, |
+ int guest_view_instance_id); |
+ |
+ private: |
+ using GuestMapKey = std::pair<int, int>; |
+ using ContentScriptMap = std::map<std::string, extensions::UserScript>; |
+ using GuestContentScriptMap = std::map<GuestMapKey, ContentScriptMap>; |
+ |
+ GuestContentScriptMap guest_content_script_map_; |
+ |
+ content::BrowserContext* browser_context_; |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGER_H |