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 "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_ |
OLD | NEW |