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

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

Issue 2228743002: Rework some UserScriptLoader logic in preparation to removing UserScript copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @tott Created 4 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_CONTENT_SCRIPT_MANAGER_H 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 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGER_H
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 37
38 static WebViewContentScriptManager* Get( 38 static WebViewContentScriptManager* Get(
39 content::BrowserContext* browser_context); 39 content::BrowserContext* browser_context);
40 40
41 // Adds content scripts for the WebView specified by 41 // Adds content scripts for the WebView specified by
42 // |embedder_process_id| and |view_instance_id|. 42 // |embedder_process_id| and |view_instance_id|.
43 void AddContentScripts(int embedder_process_id, 43 void AddContentScripts(int embedder_process_id,
44 content::RenderFrameHost* render_frame_host, 44 content::RenderFrameHost* render_frame_host,
45 int view_instance_id, 45 int view_instance_id,
46 const HostID& host_id, 46 const HostID& host_id,
47 const std::set<UserScript>& user_scripts); 47 const UserScriptList& user_scripts);
48 48
49 // Removes all content scripts for the WebView identified by 49 // Removes all content scripts for the WebView identified by
50 // |embedder_process_id| and |view_instance_id|. 50 // |embedder_process_id| and |view_instance_id|.
51 void RemoveAllContentScriptsForWebView(int embedder_process_id, 51 void RemoveAllContentScriptsForWebView(int embedder_process_id,
52 int view_instance_id); 52 int view_instance_id);
53 53
54 // Removes contents scipts whose names are in the |script_name_list| for the 54 // Removes contents scipts whose names are in the |script_name_list| for the
55 // WebView specified by |embedder_process_id| and |view_instance_id|. 55 // WebView specified by |embedder_process_id| and |view_instance_id|.
56 // If the |script_name_list| is empty, removes all the content scripts added 56 // If the |script_name_list| is empty, removes all the content scripts added
57 // for this WebView. 57 // for this WebView.
58 void RemoveContentScripts(int embedder_process_id, 58 void RemoveContentScripts(int embedder_process_id,
59 int view_instance_id, 59 int view_instance_id,
60 const HostID& host_id, 60 const HostID& host_id,
61 const std::vector<std::string>& script_name_list); 61 const std::vector<std::string>& script_name_list);
62 62
63 // Returns the content script IDs added by the WebView specified by 63 // Returns the content script IDs added by the WebView specified by
64 // |embedder_process_id| and |view_instance_id|. 64 // |embedder_process_id| and |view_instance_id|.
65 std::set<int> GetContentScriptIDSet(int embedder_process_id, 65 std::set<int> GetContentScriptIDSet(int embedder_process_id,
66 int view_instance_id); 66 int view_instance_id);
67 67
68 // Checks if there is any pending content scripts to load. 68 // Checks if there is any pending content scripts to load.
69 // If no, run |callback| immediately; otherwise caches the |callback|, and 69 // If no, run |callback| immediately; otherwise caches the |callback|, and
70 // the |callback| will be called after all the pending content scripts are 70 // the |callback| will be called after all the pending content scripts are
71 // loaded. 71 // loaded.
72 void SignalOnScriptsLoaded(const base::Closure& callback); 72 void SignalOnScriptsLoaded(const base::Closure& callback);
73 73
74 private: 74 private:
75 using GuestMapKey = std::pair<int, int>; 75 using GuestMapKey = std::pair<int, int>;
76 using ContentScriptMap = std::map<std::string, extensions::UserScript>; 76 using ContentScriptMap = std::map<std::string, UserScriptIDPair>;
77 using GuestContentScriptMap = std::map<GuestMapKey, ContentScriptMap>; 77 using GuestContentScriptMap = std::map<GuestMapKey, ContentScriptMap>;
78 78
79 // UserScriptLoader::Observer implementation: 79 // UserScriptLoader::Observer implementation:
80 void OnScriptsLoaded(UserScriptLoader* loader) override; 80 void OnScriptsLoaded(UserScriptLoader* loader) override;
81 void OnUserScriptLoaderDestroyed(UserScriptLoader* loader) override; 81 void OnUserScriptLoaderDestroyed(UserScriptLoader* loader) override;
82 82
83 // If |user_script_loader_observer_| doesn't observe any source, we will run 83 // If |user_script_loader_observer_| doesn't observe any source, we will run
84 // all the remaining callbacks in |pending_scripts_loading_callbacks_|. 84 // all the remaining callbacks in |pending_scripts_loading_callbacks_|.
85 void RunCallbacksIfReady(); 85 void RunCallbacksIfReady();
86 86
(...skipping 14 matching lines...) Expand all
101 std::vector<base::Closure> pending_scripts_loading_callbacks_; 101 std::vector<base::Closure> pending_scripts_loading_callbacks_;
102 102
103 content::BrowserContext* browser_context_; 103 content::BrowserContext* browser_context_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(WebViewContentScriptManager); 105 DISALLOW_COPY_AND_ASSIGN(WebViewContentScriptManager);
106 }; 106 };
107 107
108 } // namespace extensions 108 } // namespace extensions
109 109
110 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGE R_H 110 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_CONTENT_SCRIPT_MANAGE R_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698