Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_content_script_manager.h

Issue 959413003: Implement <webview>.addContentScript/removeContentScript API [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <set>
10 #include <string>
11 #include <vector>
12
13 #include "base/supports_user_data.h"
14
15 struct HostID;
16
17 namespace content {
18 class BrowserContext;
19 }
20
21 namespace extensions {
22 class UserScript;
23
24 // WebViewContentScriptManager manages the content scripts that each webview
25 // guest adds and removes programmatically.
26 class WebViewContentScriptManager : public base::SupportsUserData::Data {
Devlin 2015/04/08 17:50:56 Do we really need this class? Couldn't adding/rem
Xi Han 2015/04/08 22:10:36 It is better to have this class to keep other clas
Devlin 2015/04/10 16:04:31 I'm still not entirely convinced of the usefulness
Fady Samuel 2015/04/10 16:44:28 Devlin, the content scripts are tied to the lifeti
Devlin 2015/04/10 17:38:57 Ah, interesting. So a WebViewInfo is removed when
Xi Han 2015/04/10 18:27:06 WebViewInfo contains the routing info for a guest
Devlin 2015/04/10 18:31:36 But that routing info is still valid for the next
27 public:
28 explicit WebViewContentScriptManager(
29 content::BrowserContext* browser_context);
30 ~WebViewContentScriptManager() override;
31
32 static WebViewContentScriptManager* Get(
33 content::BrowserContext* browser_context);
34
35 // Adds content scripts for the guest specified by the |embedder_process_id,
36 // view_instance_id|.
37 // The name of each content sccript is its key in |user_scripts| map.
38 void AddContentScripts(int embedder_process_id,
39 int view_instance_id,
40 const HostID& host_id,
41 const std::map<std::string, UserScript>& user_scripts);
42
43 // Removes contents scipts whose names are in the |script_name_list| for the
44 // guest specified by |embedder_process_id, view_instance_id|.
45 // If the |script_name_list| is empty, removes all the content scripts added
46 // for this guest.
47 void RemoveContentScripts(int embedder_process_id,
48 int view_instance_id,
49 const HostID& host_id,
50 const std::vector<std::string>& script_name_list);
51
52 // Returns whether the content script with |script_id| belonges to the guest
53 // specified by |embedder_process_id, view_instance_id|.
54 bool OwnsUserScript(int embedder_process_id,
55 int view_instance_id,
56 int script_id);
57
58 // Returns the content script IDs added by the guest specified by
59 // |embedder_process_id, view_instance_id|.
60 std::set<int> GetContentScriptIDSet(int embedder_process_id,
61 int view_instance_id);
62
63 private:
64 using GuestMapKey = std::pair<int, int>;
65 using ContentScriptMap = std::map<std::string, extensions::UserScript>;
66 using GuestContentScriptMap = std::map<GuestMapKey, ContentScriptMap>;
67
68 GuestContentScriptMap guest_content_script_map_;
69
70 content::BrowserContext* browser_context_;
71 };
72
73 } // namespace extensions
74
75 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGE R_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698