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

Side by Side Diff: extensions/browser/web_ui_user_script_loader.h

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_ 5 #ifndef EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
6 #define EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_ 6 #define EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "extensions/browser/user_script_loader.h" 15 #include "extensions/browser/user_script_loader.h"
16 16
17 class WebUIURLFetcher; 17 class WebUIURLFetcher;
18 18
19 namespace content { 19 namespace content {
20 class BrowserContext; 20 class BrowserContext;
21 } 21 }
22 22
23 // UserScriptLoader for WebUI. 23 // UserScriptLoader for WebUI.
24 class WebUIUserScriptLoader : public extensions::UserScriptLoader { 24 class WebUIUserScriptLoader : public extensions::UserScriptLoader {
25 public: 25 public:
26 WebUIUserScriptLoader(content::BrowserContext* browser_context, 26 WebUIUserScriptLoader(content::BrowserContext* browser_context,
27 const HostID& host_id); 27 const HostID& host_id);
28 ~WebUIUserScriptLoader() override; 28 ~WebUIUserScriptLoader() override;
29 29
30 private: 30 private:
31 struct UserScriptRenderInfo; 31 struct UserScriptRenderInfo;
32 using UserScriptRenderInfoMap = std::map<int, UserScriptRenderInfo>; 32 using UserScriptRenderInfoMap = std::map<int, UserScriptRenderInfo>;
33 33
34 // UserScriptLoader: 34 // UserScriptLoader:
35 void AddScripts(const std::set<extensions::UserScript>& scripts, 35 void AddScripts(const std::set<extensions::UserScript>& scripts,
36 int render_process_id, 36 int render_process_id,
37 int render_view_id) override; 37 int render_view_id) override;
38 void LoadScripts(scoped_ptr<extensions::UserScriptList> user_scripts, 38 void LoadScripts(std::unique_ptr<extensions::UserScriptList> user_scripts,
39 const std::set<HostID>& changed_hosts, 39 const std::set<HostID>& changed_hosts,
40 const std::set<int>& added_script_ids, 40 const std::set<int>& added_script_ids,
41 LoadScriptsCallback callback) override; 41 LoadScriptsCallback callback) override;
42 42
43 // Called at the end of each fetch, tracking whether all fetches are done. 43 // Called at the end of each fetch, tracking whether all fetches are done.
44 void OnSingleWebUIURLFetchComplete(extensions::UserScript::File* script_file, 44 void OnSingleWebUIURLFetchComplete(extensions::UserScript::File* script_file,
45 bool success, 45 bool success,
46 const std::string& data); 46 const std::string& data);
47 47
48 // Called when the loads of the user scripts are done. 48 // Called when the loads of the user scripts are done.
49 void OnWebUIURLFetchComplete(); 49 void OnWebUIURLFetchComplete();
50 50
51 // Creates WebUiURLFetchers for the given |script_files|. 51 // Creates WebUiURLFetchers for the given |script_files|.
52 void CreateWebUIURLFetchers(extensions::UserScript::FileList* script_files, 52 void CreateWebUIURLFetchers(extensions::UserScript::FileList* script_files,
53 content::BrowserContext* browser_context, 53 content::BrowserContext* browser_context,
54 int render_process_id, 54 int render_process_id,
55 int render_view_id); 55 int render_view_id);
56 56
57 // Caches the render info of script from WebUI when AddScripts is called. 57 // Caches the render info of script from WebUI when AddScripts is called.
58 // When starting to load the script, we look up this map to retrieve the 58 // When starting to load the script, we look up this map to retrieve the
59 // render info. It is used for the script from WebUI only, since the fetch 59 // render info. It is used for the script from WebUI only, since the fetch
60 // of script content requires the info of associated render. 60 // of script content requires the info of associated render.
61 UserScriptRenderInfoMap script_render_info_map_; 61 UserScriptRenderInfoMap script_render_info_map_;
62 62
63 // The number of complete fetchs. 63 // The number of complete fetchs.
64 size_t complete_fetchers_; 64 size_t complete_fetchers_;
65 65
66 // Caches |user_scripts_| from UserScriptLoader when loading. 66 // Caches |user_scripts_| from UserScriptLoader when loading.
67 scoped_ptr<extensions::UserScriptList> user_scripts_cache_; 67 std::unique_ptr<extensions::UserScriptList> user_scripts_cache_;
68 68
69 LoadScriptsCallback scripts_loaded_callback_; 69 LoadScriptsCallback scripts_loaded_callback_;
70 70
71 std::vector<scoped_ptr<WebUIURLFetcher>> fetchers_; 71 std::vector<std::unique_ptr<WebUIURLFetcher>> fetchers_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader); 73 DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader);
74 }; 74 };
75 75
76 #endif // EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_ 76 #endif // EXTENSIONS_BROWSER_WEB_UI_USER_SCRIPT_LOADER_H_
OLDNEW
« no previous file with comments | « extensions/browser/verified_contents.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