| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 web_frame, | 78 web_frame, |
| 79 tab_id, | 79 tab_id, |
| 80 run_location, | 80 run_location, |
| 81 document_url, | 81 document_url, |
| 82 false /* is_declarative */); | 82 false /* is_declarative */); |
| 83 if (injection.get()) | 83 if (injection.get()) |
| 84 injections->push_back(injection.release()); | 84 injections->push_back(injection.release()); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool UserScriptSet::UpdateUserScripts( | 88 bool UserScriptSet::UpdateUserScripts(base::SharedMemoryHandle shared_memory, |
| 89 base::SharedMemoryHandle shared_memory, | 89 const std::set<HostID>& changed_hosts) { |
| 90 const std::set<std::string>& changed_extensions) { | |
| 91 bool only_inject_incognito = | 90 bool only_inject_incognito = |
| 92 ExtensionsRendererClient::Get()->IsIncognitoProcess(); | 91 ExtensionsRendererClient::Get()->IsIncognitoProcess(); |
| 93 | 92 |
| 94 // Create the shared memory object (read only). | 93 // Create the shared memory object (read only). |
| 95 shared_memory_.reset(new base::SharedMemory(shared_memory, true)); | 94 shared_memory_.reset(new base::SharedMemory(shared_memory, true)); |
| 96 if (!shared_memory_.get()) | 95 if (!shared_memory_.get()) |
| 97 return false; | 96 return false; |
| 98 | 97 |
| 99 // First get the size of the memory block. | 98 // First get the size of the memory block. |
| 100 if (!shared_memory_->Map(sizeof(Pickle::Header))) | 99 if (!shared_memory_->Map(sizeof(Pickle::Header))) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 138 } |
| 140 | 139 |
| 141 if (only_inject_incognito && !script->is_incognito_enabled()) | 140 if (only_inject_incognito && !script->is_incognito_enabled()) |
| 142 continue; // This script shouldn't run in an incognito tab. | 141 continue; // This script shouldn't run in an incognito tab. |
| 143 | 142 |
| 144 scripts_.push_back(script.release()); | 143 scripts_.push_back(script.release()); |
| 145 } | 144 } |
| 146 | 145 |
| 147 FOR_EACH_OBSERVER(Observer, | 146 FOR_EACH_OBSERVER(Observer, |
| 148 observers_, | 147 observers_, |
| 149 OnUserScriptsUpdated(changed_extensions, scripts_.get())); | 148 OnUserScriptsUpdated(changed_hosts, scripts_.get())); |
| 150 return true; | 149 return true; |
| 151 } | 150 } |
| 152 | 151 |
| 153 scoped_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection( | 152 scoped_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection( |
| 154 int script_id, | 153 int script_id, |
| 155 blink::WebFrame* web_frame, | 154 blink::WebFrame* web_frame, |
| 156 int tab_id, | 155 int tab_id, |
| 157 UserScript::RunLocation run_location, | 156 UserScript::RunLocation run_location, |
| 158 const GURL& document_url) { | 157 const GURL& document_url) { |
| 159 for (ScopedVector<UserScript>::const_iterator it = scripts_.begin(); | 158 for (ScopedVector<UserScript>::const_iterator it = scripts_.begin(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 injector.Pass(), | 222 injector.Pass(), |
| 224 web_frame->toWebLocalFrame(), | 223 web_frame->toWebLocalFrame(), |
| 225 injection_host.Pass(), | 224 injection_host.Pass(), |
| 226 run_location, | 225 run_location, |
| 227 tab_id)); | 226 tab_id)); |
| 228 } | 227 } |
| 229 return injection.Pass(); | 228 return injection.Pass(); |
| 230 } | 229 } |
| 231 | 230 |
| 232 } // namespace extensions | 231 } // namespace extensions |
| OLD | NEW |