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

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: Another round of comments. 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(scoped_ptr<extensions::UserScriptList> user_scripts,
32 const std::set<HostID>& changed_hosts,
33 const std::set<int>& added_script_ids) override;
34
35 // Called when every single URL fetch is done. It also traces whether all the
36 // URL fetches are done. If yes, will call OnWebUIURLFetchComplete().
37 void OnSingleWebUIURLFetchComplete(extensions::UserScript::File* script_file,
38 bool success,
39 const std::string& data);
40
41 // Called when the loads of the user scripts are done.
42 void OnWebUIURLFetchComplete();
43
44 // Caches the render info of script from WebUI when AddScripts is called.
45 // When starting to load the script, we look up this map to retrieve the
46 // render info. It is used for the script from WebUI only, since the fetch
47 // of script content requires the info of associated render.
48 UserScriptRenderInfoMap script_render_info_map_;
49
50 // The number of complete fetchs.
51 size_t complete_fetchers_;
52
53 // Caches |user_scripts_| from UserScriptLoader when loading.
54 scoped_ptr<extensions::UserScriptList> user_scripts_cache_;
55
56 ScopedVector<WebUIURLFetcher> fetchers_;
57
58 base::WeakPtrFactory<WebUIUserScriptLoader> weak_factory_;
59
60 DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader);
61 };
62
63 #endif // EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698