Chromium Code Reviews| OLD | NEW |
|---|---|
| (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" | |
|
Devlin
2015/04/23 16:34:38
Forward declaration.
Xi Han
2015/04/23 17:50:40
Done.
| |
| 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, | |
| 34 LoadScriptsCallback callback) override; | |
| 35 | |
| 36 // Called when every single URL fetch is done. It also traces whether all the | |
|
Devlin
2015/04/23 16:34:38
"when every single URL fetch is done" is ambiguous
Xi Han
2015/04/23 17:50:40
Sounds good:)
| |
| 37 // URL fetches are done. If yes, will call OnWebUIURLFetchComplete(). | |
| 38 void OnSingleWebUIURLFetchComplete(extensions::UserScript::File* script_file, | |
| 39 bool success, | |
| 40 const std::string& data); | |
| 41 | |
| 42 // Called when the loads of the user scripts are done. | |
| 43 void OnWebUIURLFetchComplete(); | |
| 44 | |
| 45 // Creates WebUiURLFetchers for the given |script_files|. | |
| 46 void CreateWebUIURLFetchers(extensions::UserScript::FileList* script_files, | |
| 47 int render_process_id, | |
| 48 int render_view_id); | |
| 49 | |
| 50 // Caches the render info of script from WebUI when AddScripts is called. | |
| 51 // When starting to load the script, we look up this map to retrieve the | |
| 52 // render info. It is used for the script from WebUI only, since the fetch | |
| 53 // of script content requires the info of associated render. | |
| 54 UserScriptRenderInfoMap script_render_info_map_; | |
| 55 | |
| 56 // The number of complete fetchs. | |
| 57 size_t complete_fetchers_; | |
| 58 | |
| 59 // Caches |user_scripts_| from UserScriptLoader when loading. | |
| 60 scoped_ptr<extensions::UserScriptList> user_scripts_cache_; | |
| 61 | |
| 62 LoadScriptsCallback callback_; | |
|
Devlin
2015/04/23 16:34:38
Let's call this scripts_loaded_callback_.
Xi Han
2015/04/23 17:50:40
Done.
| |
| 63 | |
| 64 ScopedVector<WebUIURLFetcher> fetchers_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader); | |
| 67 }; | |
| 68 | |
| 69 #endif // EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_ | |
| OLD | NEW |