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.h" | 5 #include "extensions/renderer/user_script_set.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "content/public/common/url_constants.h" | 8 #include "content/public/common/url_constants.h" |
9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 iter != scripts_.end(); | 75 iter != scripts_.end(); |
76 ++iter) { | 76 ++iter) { |
77 scoped_ptr<ScriptInjection> injection = GetInjectionForScript( | 77 scoped_ptr<ScriptInjection> injection = GetInjectionForScript( |
78 *iter, | 78 *iter, |
79 web_frame, | 79 web_frame, |
80 tab_id, | 80 tab_id, |
81 run_location, | 81 run_location, |
82 document_url, | 82 document_url, |
83 false /* is_declarative */); | 83 false /* is_declarative */); |
84 if (injection.get()) | 84 if (injection.get()) |
85 injections->push_back(injection.release()); | 85 injections->push_back(injection.Pass()); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 bool UserScriptSet::UpdateUserScripts(base::SharedMemoryHandle shared_memory, | 89 bool UserScriptSet::UpdateUserScripts(base::SharedMemoryHandle shared_memory, |
90 const std::set<HostID>& changed_hosts, | 90 const std::set<HostID>& changed_hosts, |
91 bool whitelisted_only) { | 91 bool whitelisted_only) { |
92 bool only_inject_incognito = | 92 bool only_inject_incognito = |
93 ExtensionsRendererClient::Get()->IsIncognitoProcess(); | 93 ExtensionsRendererClient::Get()->IsIncognitoProcess(); |
94 | 94 |
95 // Create the shared memory object (read only). | 95 // Create the shared memory object (read only). |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if (only_inject_incognito && !script->is_incognito_enabled()) | 142 if (only_inject_incognito && !script->is_incognito_enabled()) |
143 continue; // This script shouldn't run in an incognito tab. | 143 continue; // This script shouldn't run in an incognito tab. |
144 | 144 |
145 const Extension* extension = extensions_->GetByID(script->extension_id()); | 145 const Extension* extension = extensions_->GetByID(script->extension_id()); |
146 if (whitelisted_only && | 146 if (whitelisted_only && |
147 (!extension || | 147 (!extension || |
148 !PermissionsData::CanExecuteScriptEverywhere(extension))) { | 148 !PermissionsData::CanExecuteScriptEverywhere(extension))) { |
149 continue; | 149 continue; |
150 } | 150 } |
151 | 151 |
152 scripts_.push_back(script.release()); | 152 scripts_.push_back(script.Pass()); |
153 } | 153 } |
154 | 154 |
155 FOR_EACH_OBSERVER(Observer, | 155 FOR_EACH_OBSERVER(Observer, |
156 observers_, | 156 observers_, |
157 OnUserScriptsUpdated(changed_hosts, scripts_.get())); | 157 OnUserScriptsUpdated(changed_hosts, scripts_.get())); |
158 return true; | 158 return true; |
159 } | 159 } |
160 | 160 |
161 scoped_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection( | 161 scoped_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection( |
162 int script_id, | 162 int script_id, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 injector.Pass(), | 238 injector.Pass(), |
239 web_frame->toWebLocalFrame(), | 239 web_frame->toWebLocalFrame(), |
240 injection_host.Pass(), | 240 injection_host.Pass(), |
241 run_location, | 241 run_location, |
242 tab_id)); | 242 tab_id)); |
243 } | 243 } |
244 return injection.Pass(); | 244 return injection.Pass(); |
245 } | 245 } |
246 | 246 |
247 } // namespace extensions | 247 } // namespace extensions |
OLD | NEW |