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

Side by Side Diff: extensions/browser/web_ui_user_script_loader.h

Issue 1056533002: Implement <webview>.addContentScript/removeContentScript API [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webview_addremove_contentscripts_2
Patch Set: Refactoring in UserScriptLoader and etc. 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_WEB_UI_USER_SCRIPT_LOADER_H_
6 #define EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
7
8 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group .h"
9 #include "extensions/browser/user_script_loader.h"
10
11 namespace content {
12 class BrowserContext;
13 }
14
15 // UserScriptLoader for WebUI.
16 class WebUIUserScriptLoader : public extensions::UserScriptLoader {
17 public:
18 WebUIUserScriptLoader(content::BrowserContext* browser_context,
19 const HostID& host_id);
20 ~WebUIUserScriptLoader() override;
21
22 private:
23 struct UserScriptRenderInfo;
24 using UserScriptRenderInfoMap = std::map<int, UserScriptRenderInfo>;
25
26 // UserScriptLoader:
27 void AddScripts(const std::set<extensions::UserScript>& scripts,
28 int render_process_id,
29 int render_view_id) override;
30 void LoadScripts(const std::set<HostID>& changed_hosts,
31 const std::set<int>& added_script_ids) override;
32
33 // Called when the loads of the user scripts are done.
34 void OnWebUIURLFetchComplete(
35 scoped_ptr<extensions::UserScriptList> user_scripts);
36
37 // Caches the render info of script from WebUI when AddScripts is called.
38 // When starting to load the script, we look up this map to retrieve the
39 // render info. It is used for the script from WebUI only, since the fetch
40 // of script content requires the info of associated render.
41 UserScriptRenderInfoMap script_render_info_map_;
42
43 std::set<WebUIURLFetcherGroup*> fetcher_groups_;
44 base::WeakPtrFactory<WebUIUserScriptLoader> weak_factory_;
45
46 DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader);
47 };
48
49 #endif // EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698