| 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 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ | 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ |
| 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ | 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/extension_set.h" | |
| 15 #include "extensions/common/features/feature.h" | 14 #include "extensions/common/features/feature.h" |
| 15 #include "extensions/renderer/renderer_extension_registry.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 #include "v8/include/v8.h" | 17 #include "v8/include/v8.h" |
| 18 | 18 |
| 19 class GURL; | 19 class GURL; |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class ListValue; | 22 class ListValue; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace blink { | 25 namespace blink { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 // A container of ScriptContexts, responsible for both creating and managing | 37 // A container of ScriptContexts, responsible for both creating and managing |
| 38 // them. | 38 // them. |
| 39 // | 39 // |
| 40 // Since calling JavaScript within a context can cause any number of contexts | 40 // Since calling JavaScript within a context can cause any number of contexts |
| 41 // to be created or destroyed, this has additional smarts to help with the set | 41 // to be created or destroyed, this has additional smarts to help with the set |
| 42 // changing underneath callers. | 42 // changing underneath callers. |
| 43 class ScriptContextSet { | 43 class ScriptContextSet { |
| 44 public: | 44 public: |
| 45 ScriptContextSet( | 45 ScriptContextSet( |
| 46 ExtensionSet* extensions, | |
| 47 // Set of the IDs of extensions that are active in this process. | 46 // Set of the IDs of extensions that are active in this process. |
| 48 // Must outlive this. TODO(kalman): Combine this and |extensions|. | 47 // Must outlive this. TODO(kalman): Combine this and |extensions|. |
| 49 ExtensionIdSet* active_extension_ids); | 48 ExtensionIdSet* active_extension_ids); |
| 50 | 49 |
| 51 ~ScriptContextSet(); | 50 ~ScriptContextSet(); |
| 52 | 51 |
| 53 // Returns the number of contexts being tracked by this set. | 52 // Returns the number of contexts being tracked by this set. |
| 54 // This may also include invalid contexts. TODO(kalman): Useful? | 53 // This may also include invalid contexts. TODO(kalman): Useful? |
| 55 size_t size() const { return contexts_.size(); } | 54 size_t size() const { return contexts_.size(); } |
| 56 | 55 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 const Extension* extension, | 122 const Extension* extension, |
| 124 int extension_group, | 123 int extension_group, |
| 125 const GURL& url, | 124 const GURL& url, |
| 126 const blink::WebSecurityOrigin& origin); | 125 const blink::WebSecurityOrigin& origin); |
| 127 | 126 |
| 128 // Calls Remove on |context| then appends |context| to |out|. | 127 // Calls Remove on |context| then appends |context| to |out|. |
| 129 // This is a helper designed to be used by OnExtensionUnloaded with ForEach. | 128 // This is a helper designed to be used by OnExtensionUnloaded with ForEach. |
| 130 void DispatchOnUnloadEventAndRemove(std::set<ScriptContext*>* out, | 129 void DispatchOnUnloadEventAndRemove(std::set<ScriptContext*>* out, |
| 131 ScriptContext* context); | 130 ScriptContext* context); |
| 132 | 131 |
| 133 // Weak reference to all installed Extensions. | |
| 134 ExtensionSet* extensions_; | |
| 135 | |
| 136 // Weak reference to all installed Extensions that are also active in this | 132 // Weak reference to all installed Extensions that are also active in this |
| 137 // process. | 133 // process. |
| 138 ExtensionIdSet* active_extension_ids_; | 134 ExtensionIdSet* active_extension_ids_; |
| 139 | 135 |
| 140 // The set of all ScriptContexts we own. | 136 // The set of all ScriptContexts we own. |
| 141 std::set<ScriptContext*> contexts_; | 137 std::set<ScriptContext*> contexts_; |
| 142 | 138 |
| 143 DISALLOW_COPY_AND_ASSIGN(ScriptContextSet); | 139 DISALLOW_COPY_AND_ASSIGN(ScriptContextSet); |
| 144 }; | 140 }; |
| 145 | 141 |
| 146 } // namespace extensions | 142 } // namespace extensions |
| 147 | 143 |
| 148 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ | 144 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_SET_H_ |
| OLD | NEW |