| 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/script_context_set.h" | 5 #include "extensions/renderer/script_context_set.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void ScriptContextSet::OnExtensionUnloaded(const std::string& extension_id) { | 124 void ScriptContextSet::OnExtensionUnloaded(const std::string& extension_id) { |
| 125 ForEach(extension_id, | 125 ForEach(extension_id, |
| 126 base::Bind(&ScriptContextSet::Remove, base::Unretained(this))); | 126 base::Bind(&ScriptContextSet::Remove, base::Unretained(this))); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void ScriptContextSet::AddForTesting(std::unique_ptr<ScriptContext> context) { | 129 void ScriptContextSet::AddForTesting(std::unique_ptr<ScriptContext> context) { |
| 130 contexts_.insert(context.release()); // Takes ownership | 130 contexts_.insert(context.release()); // Takes ownership |
| 131 } | 131 } |
| 132 | 132 |
| 133 const Extension* ScriptContextSet::GetExtensionFromFrameAndWorld( | 133 const Extension* ScriptContextSet::GetExtensionFromFrameAndWorld( |
| 134 const blink::WebLocalFrame* frame, | 134 blink::WebLocalFrame* frame, |
| 135 int world_id, | 135 int world_id, |
| 136 bool use_effective_url) { | 136 bool use_effective_url) { |
| 137 std::string extension_id; | 137 std::string extension_id; |
| 138 if (world_id != 0) { | 138 if (world_id != 0) { |
| 139 // Isolated worlds (content script). | 139 // Isolated worlds (content script). |
| 140 extension_id = ScriptInjection::GetHostIdForIsolatedWorld(world_id); | 140 extension_id = ScriptInjection::GetHostIdForIsolatedWorld(world_id); |
| 141 } else { | 141 } else { |
| 142 // For looking up the extension associated with this frame, we either want | 142 // For looking up the extension associated with this frame, we either want |
| 143 // to use the current url or possibly the data source url (which this frame | 143 // to use the current url or possibly the data source url (which this frame |
| 144 // may be navigating to shortly), depending on the security origin of the | 144 // may be navigating to shortly), depending on the security origin of the |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if (!url.is_valid()) | 221 if (!url.is_valid()) |
| 222 return Feature::UNSPECIFIED_CONTEXT; | 222 return Feature::UNSPECIFIED_CONTEXT; |
| 223 | 223 |
| 224 if (url.SchemeIs(content::kChromeUIScheme)) | 224 if (url.SchemeIs(content::kChromeUIScheme)) |
| 225 return Feature::WEBUI_CONTEXT; | 225 return Feature::WEBUI_CONTEXT; |
| 226 | 226 |
| 227 return Feature::WEB_PAGE_CONTEXT; | 227 return Feature::WEB_PAGE_CONTEXT; |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace extensions | 230 } // namespace extensions |
| OLD | NEW |