| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" |
| 12 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
| 13 | 14 |
| 14 class GURL; | 15 class GURL; |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class ListValue; | 18 class ListValue; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class RenderView; | 22 class RenderView; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 49 // Returns a copy to protect against changes. | 50 // Returns a copy to protect against changes. |
| 50 typedef std::set<ChromeV8Context*> ContextSet; | 51 typedef std::set<ChromeV8Context*> ContextSet; |
| 51 ContextSet GetAll() const; | 52 ContextSet GetAll() const; |
| 52 | 53 |
| 53 // Gets the ChromeV8Context corresponding to the v8::Context that is | 54 // Gets the ChromeV8Context corresponding to the v8::Context that is |
| 54 // on the top of the stack, or NULL if no such context exists. | 55 // on the top of the stack, or NULL if no such context exists. |
| 55 ChromeV8Context* GetCurrent() const; | 56 ChromeV8Context* GetCurrent() const; |
| 56 | 57 |
| 57 // Gets the ChromeV8Context corresponding to the specified | 58 // Gets the ChromeV8Context corresponding to the specified |
| 58 // v8::Context or NULL if no such context exists. | 59 // v8::Context or NULL if no such context exists. |
| 59 ChromeV8Context* GetByV8Context( | 60 ChromeV8Context* GetByV8Context(v8::Handle<v8::Context> context) const; |
| 60 v8::Handle<v8::Context> context) const; | |
| 61 | 61 |
| 62 // Calls chromeHidden.<methodName> in each context for <extension_id>. If | 62 // Synchronously runs |callback| with each ChromeV8Context that belongs to |
| 63 // render_view is non-NULL, only call the function in contexts belonging to | 63 // |extension_id| in |render_view|. |
| 64 // that view. The called javascript function should not return a value other | 64 // |
| 65 // than v8::Undefined(). A DCHECK is setup to break if it is otherwise. | 65 // |extension_id| may be "" to match all extensions. |
| 66 void DispatchChromeHiddenMethod(const std::string& extension_id, | 66 // |render_view| may be NULL to match all render views. |
| 67 const std::string& method_name, | 67 void ForEach(const std::string& extension_id, |
| 68 const base::ListValue& arguments, | 68 content::RenderView* render_view, |
| 69 content::RenderView* render_view) const; | 69 const base::Callback<void(ChromeV8Context*)>& callback) const; |
| 70 | 70 |
| 71 // Cleans up contexts belonging to an unloaded extension. | 71 // Cleans up contexts belonging to an unloaded extension. |
| 72 // | 72 // |
| 73 // Returns the set of ChromeV8Contexts that were removed as a result. These | 73 // Returns the set of ChromeV8Contexts that were removed as a result. These |
| 74 // are safe to interact with until the end of the current event loop, since | 74 // are safe to interact with until the end of the current event loop, since |
| 75 // they're deleted asynchronously. | 75 // they're deleted asynchronously. |
| 76 ContextSet OnExtensionUnloaded(const std::string& extension_id); | 76 ContextSet OnExtensionUnloaded(const std::string& extension_id); |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 ContextSet contexts_; | 79 ContextSet contexts_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(ChromeV8ContextSet); | 81 DISALLOW_COPY_AND_ASSIGN(ChromeV8ContextSet); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace extensions | 84 } // namespace extensions |
| 85 | 85 |
| 86 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ | 86 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ |
| OLD | NEW |