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

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: 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 "base/memory/scoped_vector.h"
9 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h"
10 #include "extensions/browser/user_script_loader.h"
11
12 namespace content {
13 class BrowserContext;
14 }
15
16 // UserScriptLoader for WebUI.
17 class WebUIUserScriptLoader : public extensions::UserScriptLoader {
18 public:
19 WebUIUserScriptLoader(content::BrowserContext* browser_context,
20 const HostID& host_id);
21 ~WebUIUserScriptLoader() override;
22
23 private:
24 struct UserScriptRenderInfo;
25 using UserScriptRenderInfoMap = std::map<int, UserScriptRenderInfo>;
26
27 // UserScriptLoader:
28 void AddScripts(const std::set<extensions::UserScript>& scripts,
29 int render_process_id,
30 int render_view_id) override;
31 void LoadScripts(const std::set<HostID>& changed_hosts,
32 const std::set<int>& added_script_ids) override;
33
34 // Called when every single URL fetch is done. It also traces whether all the
35 // URL fetches are done. If yes, will call OnWebUIURLFetchComplete().
36 void OnSingleWebUIURLFetchComplete(extensions::UserScript::File* script_file,
37 bool success,
38 const std::string& data);
39
40 // Called when the loads of the user scripts are done.
41 void OnWebUIURLFetchComplete();
42
43 // Caches the render info of script from WebUI when AddScripts is called.
44 // When starting to load the script, we look up this map to retrieve the
45 // render info. It is used for the script from WebUI only, since the fetch
46 // of script content requires the info of associated render.
47 UserScriptRenderInfoMap script_render_info_map_;
48
49 // The number of complete fetchs.
50 int complete_fetchers_;
51 int total_fetchers_;
52
53 ScopedVector<WebUIURLFetcher> fetchers_;
54
55 base::WeakPtrFactory<WebUIUserScriptLoader> weak_factory_;
56
57 DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader);
58 };
59
60 #endif // EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698