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

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: nits. 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/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "extensions/browser/user_script_loader.h"
12
13 class WebUIURLFetcher;
14
15 namespace content {
16 class BrowserContext;
17 }
18
19 // UserScriptLoader for WebUI.
20 class WebUIUserScriptLoader : public extensions::UserScriptLoader {
21 public:
22 WebUIUserScriptLoader(content::BrowserContext* browser_context,
23 const HostID& host_id);
24 ~WebUIUserScriptLoader() override;
25
26 private:
27 struct UserScriptRenderInfo;
28 using UserScriptRenderInfoMap = std::map<int, UserScriptRenderInfo>;
29
30 // UserScriptLoader:
31 void AddScripts(const std::set<extensions::UserScript>& scripts,
32 int render_process_id,
33 int render_view_id) override;
34 void LoadScripts(scoped_ptr<extensions::UserScriptList> user_scripts,
35 const std::set<HostID>& changed_hosts,
36 const std::set<int>& added_script_ids,
37 LoadScriptsCallback callback) override;
38
39 // Called at the end of each fetch, tracking whether all fetches are done.
40 void OnSingleWebUIURLFetchComplete(extensions::UserScript::File* script_file,
41 bool success,
42 const std::string& data);
43
44 // Called when the loads of the user scripts are done.
45 void OnWebUIURLFetchComplete();
46
47 // Creates WebUiURLFetchers for the given |script_files|.
48 void CreateWebUIURLFetchers(extensions::UserScript::FileList* script_files,
49 int render_process_id,
50 int render_view_id);
51
52 // Caches the render info of script from WebUI when AddScripts is called.
53 // When starting to load the script, we look up this map to retrieve the
54 // render info. It is used for the script from WebUI only, since the fetch
55 // of script content requires the info of associated render.
56 UserScriptRenderInfoMap script_render_info_map_;
57
58 // The number of complete fetchs.
59 size_t complete_fetchers_;
60
61 // Caches |user_scripts_| from UserScriptLoader when loading.
62 scoped_ptr<extensions::UserScriptList> user_scripts_cache_;
63
64 LoadScriptsCallback scripts_loaded_callback_;
65
66 ScopedVector<WebUIURLFetcher> fetchers_;
67
68 DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader);
69 };
70
71 #endif // EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
OLDNEW
« no previous file with comments | « extensions/browser/user_script_loader.cc ('k') | extensions/browser/web_ui_user_script_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698