OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGER_H |
| 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGER_H |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/supports_user_data.h" |
| 13 |
| 14 struct HostID; |
| 15 |
| 16 namespace content { |
| 17 class BrowserContext; |
| 18 } |
| 19 |
| 20 namespace extensions { |
| 21 class UserScript; |
| 22 |
| 23 // WebViewContentScriptManager manages the content scripts that each webview |
| 24 // guest adds and removes programmatically. |
| 25 class WebViewContentScriptManager : public base::SupportsUserData::Data { |
| 26 public: |
| 27 explicit WebViewContentScriptManager( |
| 28 content::BrowserContext* browser_context); |
| 29 ~WebViewContentScriptManager() override; |
| 30 |
| 31 static WebViewContentScriptManager* Get( |
| 32 content::BrowserContext* browser_context); |
| 33 |
| 34 // Adds content scripts for the guest specified by the |embedder_process_id, |
| 35 // guest_view_instance_id|. |
| 36 // The name of each content sccript is its key in |user_scripts| map. |
| 37 void AddContentScripts(int embedder_process_id, |
| 38 int guest_view_instance_id, |
| 39 const HostID& host_id, |
| 40 const std::map<std::string, UserScript>& user_scripts); |
| 41 |
| 42 // Removes contents scipts whose names are in the |script_name_list| for the |
| 43 // guest specified by |embedder_process_id, guest_view_instance_id|. |
| 44 // If the |script_name_list| is empty, removes all the content scripts added |
| 45 // for this guest. |
| 46 void RemoveContentScripts(int embedder_process_id, |
| 47 int guest_view_instance_id, |
| 48 const HostID& host_id, |
| 49 std::vector<std::string>* script_name_list); |
| 50 |
| 51 // Returns whether the content script with |script_id| belonges to the guest |
| 52 // specified by |embedder_process_id, guest_view_instance_id|. |
| 53 bool OwnsUserScript(int embedder_process_id, |
| 54 int guest_view_instance_id, |
| 55 int script_id); |
| 56 |
| 57 private: |
| 58 content::BrowserContext* browser_context_; |
| 59 }; |
| 60 |
| 61 } // namespace extensions |
| 62 |
| 63 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGE
R_H |
OLD | NEW |