| 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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "content/public/common/url_constants.h" | 8 #include "content/public/common/url_constants.h" |
| 9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
| 10 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 int extension_group, | 38 int extension_group, |
| 39 int world_id) { | 39 int world_id) { |
| 40 const Extension* extension = | 40 const Extension* extension = |
| 41 GetExtensionFromFrameAndWorld(frame, world_id, false); | 41 GetExtensionFromFrameAndWorld(frame, world_id, false); |
| 42 const Extension* effective_extension = | 42 const Extension* effective_extension = |
| 43 GetExtensionFromFrameAndWorld(frame, world_id, true); | 43 GetExtensionFromFrameAndWorld(frame, world_id, true); |
| 44 | 44 |
| 45 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); | 45 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); |
| 46 Feature::Context context_type = | 46 Feature::Context context_type = |
| 47 ClassifyJavaScriptContext(extension, extension_group, frame_url, | 47 ClassifyJavaScriptContext(extension, extension_group, frame_url, |
| 48 frame->document().securityOrigin()); | 48 frame->document().getSecurityOrigin()); |
| 49 Feature::Context effective_context_type = ClassifyJavaScriptContext( | 49 Feature::Context effective_context_type = ClassifyJavaScriptContext( |
| 50 effective_extension, extension_group, | 50 effective_extension, extension_group, |
| 51 ScriptContext::GetEffectiveDocumentURL(frame, frame_url, true), | 51 ScriptContext::GetEffectiveDocumentURL(frame, frame_url, true), |
| 52 frame->document().securityOrigin()); | 52 frame->document().getSecurityOrigin()); |
| 53 | 53 |
| 54 ScriptContext* context = | 54 ScriptContext* context = |
| 55 new ScriptContext(v8_context, frame, extension, context_type, | 55 new ScriptContext(v8_context, frame, extension, context_type, |
| 56 effective_extension, effective_context_type); | 56 effective_extension, effective_context_type); |
| 57 contexts_.insert(context); // takes ownership | 57 contexts_.insert(context); // takes ownership |
| 58 return context; | 58 return context; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ScriptContextSet::Remove(ScriptContext* context) { | 61 void ScriptContextSet::Remove(ScriptContext* context) { |
| 62 if (contexts_.erase(context)) { | 62 if (contexts_.erase(context)) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return Feature::WEB_PAGE_CONTEXT; | 209 return Feature::WEB_PAGE_CONTEXT; |
| 210 } | 210 } |
| 211 | 211 |
| 212 void ScriptContextSet::RecordAndRemove(std::set<ScriptContext*>* removed, | 212 void ScriptContextSet::RecordAndRemove(std::set<ScriptContext*>* removed, |
| 213 ScriptContext* context) { | 213 ScriptContext* context) { |
| 214 removed->insert(context); | 214 removed->insert(context); |
| 215 Remove(context); // Note: context deletion is deferred to the message loop. | 215 Remove(context); // Note: context deletion is deferred to the message loop. |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace extensions | 218 } // namespace extensions |
| OLD | NEW |