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

Side by Side Diff: extensions/browser/extension_user_script_loader.cc

Issue 2197513002: [UserScript] Do not create SubstitutionMap if not necessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "extensions/browser/extension_user_script_loader.h" 5 #include "extensions/browser/extension_user_script_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 iter->second.first, host_id.id(), iter->second.second); 124 iter->second.first, host_id.id(), iter->second.second);
125 } 125 }
126 126
127 void LoadUserScripts(UserScriptList* user_scripts, 127 void LoadUserScripts(UserScriptList* user_scripts,
128 const ExtensionUserScriptLoader::HostsInfo& hosts_info, 128 const ExtensionUserScriptLoader::HostsInfo& hosts_info,
129 const std::set<int>& added_script_ids, 129 const std::set<int>& added_script_ids,
130 const scoped_refptr<ContentVerifier>& verifier) { 130 const scoped_refptr<ContentVerifier>& verifier) {
131 for (UserScript& script : *user_scripts) { 131 for (UserScript& script : *user_scripts) {
132 if (added_script_ids.count(script.id()) == 0) 132 if (added_script_ids.count(script.id()) == 0)
133 continue; 133 continue;
134 std::unique_ptr<SubstitutionMap> localization_messages(
135 GetLocalizationMessages(hosts_info, script.host_id()));
136 for (UserScript::File& script_file : script.js_scripts()) { 134 for (UserScript::File& script_file : script.js_scripts()) {
137 if (script_file.GetContent().empty()) 135 if (script_file.GetContent().empty())
138 LoadScriptContent(script.host_id(), &script_file, nullptr, verifier); 136 LoadScriptContent(script.host_id(), &script_file, nullptr, verifier);
139 } 137 }
140 for (UserScript::File& script_file : script.css_scripts()) { 138 if (script.css_scripts().size() > 0) {
141 if (script_file.GetContent().empty()) 139 std::unique_ptr<SubstitutionMap> localization_messages(
142 LoadScriptContent(script.host_id(), &script_file, 140 GetLocalizationMessages(hosts_info, script.host_id()));
143 localization_messages.get(), verifier); 141 for (UserScript::File& script_file : script.css_scripts()) {
142 if (script_file.GetContent().empty()) {
143 LoadScriptContent(script.host_id(), &script_file,
144 localization_messages.get(), verifier);
145 }
146 }
144 } 147 }
145 } 148 }
146 } 149 }
147 150
148 void LoadScriptsOnFileThread( 151 void LoadScriptsOnFileThread(
149 std::unique_ptr<UserScriptList> user_scripts, 152 std::unique_ptr<UserScriptList> user_scripts,
150 const ExtensionUserScriptLoader::HostsInfo& hosts_info, 153 const ExtensionUserScriptLoader::HostsInfo& hosts_info,
151 const std::set<int>& added_script_ids, 154 const std::set<int>& added_script_ids,
152 const scoped_refptr<ContentVerifier>& verifier, 155 const scoped_refptr<ContentVerifier>& verifier,
153 UserScriptLoader::LoadScriptsCallback callback) { 156 UserScriptLoader::LoadScriptsCallback callback) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 const Extension* extension, 235 const Extension* extension,
233 UnloadedExtensionInfo::Reason reason) { 236 UnloadedExtensionInfo::Reason reason) {
234 hosts_info_.erase(HostID(HostID::EXTENSIONS, extension->id())); 237 hosts_info_.erase(HostID(HostID::EXTENSIONS, extension->id()));
235 } 238 }
236 239
237 void ExtensionUserScriptLoader::OnExtensionSystemReady() { 240 void ExtensionUserScriptLoader::OnExtensionSystemReady() {
238 SetReady(true); 241 SetReady(true);
239 } 242 }
240 243
241 } // namespace extensions 244 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698