OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/user_script_set_manager.h" | 5 #include "extensions/renderer/user_script_set_manager.h" |
6 | 6 |
7 #include "components/crx_file/id_util.h" | 7 #include "components/crx_file/id_util.h" |
8 #include "content/public/renderer/render_thread.h" | 8 #include "content/public/renderer/render_thread.h" |
9 #include "extensions/common/extension_messages.h" | 9 #include "extensions/common/extension_messages.h" |
10 #include "extensions/renderer/dispatcher.h" | 10 #include "extensions/renderer/dispatcher.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 UserScriptSet* UserScriptSetManager::GetProgrammaticScriptsByHostID( | 90 UserScriptSet* UserScriptSetManager::GetProgrammaticScriptsByHostID( |
91 const HostID& host_id) { | 91 const HostID& host_id) { |
92 UserScriptSetMap::const_iterator it = programmatic_scripts_.find(host_id); | 92 UserScriptSetMap::const_iterator it = programmatic_scripts_.find(host_id); |
93 return it != programmatic_scripts_.end() ? it->second.get() : NULL; | 93 return it != programmatic_scripts_.end() ? it->second.get() : NULL; |
94 } | 94 } |
95 | 95 |
96 void UserScriptSetManager::OnUpdateUserScripts( | 96 void UserScriptSetManager::OnUpdateUserScripts( |
97 base::SharedMemoryHandle shared_memory, | 97 base::SharedMemoryHandle shared_memory, |
98 const HostID& host_id, | 98 const HostID& host_id, |
99 const std::set<HostID>& changed_hosts) { | 99 const std::set<HostID>& changed_hosts, |
| 100 bool whitelisted_only) { |
100 if (!base::SharedMemory::IsHandleValid(shared_memory)) { | 101 if (!base::SharedMemory::IsHandleValid(shared_memory)) { |
101 NOTREACHED() << "Bad scripts handle"; | 102 NOTREACHED() << "Bad scripts handle"; |
102 return; | 103 return; |
103 } | 104 } |
104 | 105 |
105 for (const HostID& host_id : changed_hosts) { | 106 for (const HostID& host_id : changed_hosts) { |
106 if (host_id.type() == HostID::EXTENSIONS && | 107 if (host_id.type() == HostID::EXTENSIONS && |
107 !crx_file::id_util::IdIsValid(host_id.id())) { | 108 !crx_file::id_util::IdIsValid(host_id.id())) { |
108 NOTREACHED() << "Invalid extension id: " << host_id.id(); | 109 NOTREACHED() << "Invalid extension id: " << host_id.id(); |
109 return; | 110 return; |
(...skipping 30 matching lines...) Expand all Loading... |
140 if (host_id.id().empty()) { | 141 if (host_id.id().empty()) { |
141 std::set<std::string> extension_ids = extensions_->GetIDs(); | 142 std::set<std::string> extension_ids = extensions_->GetIDs(); |
142 for (const std::string& extension_id : extension_ids) | 143 for (const std::string& extension_id : extension_ids) |
143 all_hosts.insert(HostID(HostID::EXTENSIONS, extension_id)); | 144 all_hosts.insert(HostID(HostID::EXTENSIONS, extension_id)); |
144 } else { | 145 } else { |
145 all_hosts.insert(host_id); | 146 all_hosts.insert(host_id); |
146 } | 147 } |
147 effective_hosts = &all_hosts; | 148 effective_hosts = &all_hosts; |
148 } | 149 } |
149 | 150 |
150 if (scripts->UpdateUserScripts(shared_memory, *effective_hosts)) { | 151 if (scripts->UpdateUserScripts(shared_memory, |
| 152 *effective_hosts, |
| 153 whitelisted_only)) { |
151 FOR_EACH_OBSERVER( | 154 FOR_EACH_OBSERVER( |
152 Observer, | 155 Observer, |
153 observers_, | 156 observers_, |
154 OnUserScriptsUpdated(*effective_hosts, scripts->scripts())); | 157 OnUserScriptsUpdated(*effective_hosts, scripts->scripts())); |
155 } | 158 } |
156 } | 159 } |
157 | 160 |
158 } // namespace extensions | 161 } // namespace extensions |
OLD | NEW |