| 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 30 matching lines...) Expand all Loading... |
| 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( |
| 60 v8::Handle<v8::Context> context) const; | 61 v8::Handle<v8::Context> context) const; |
| 61 | 62 |
| 62 // Calls chromeHidden.<methodName> in each context for <extension_id>. If | 63 // Re-entrantly runs |callback| with each ChromeV8Context that belongs to |
| 63 // render_view is non-NULL, only call the function in contexts belonging to | 64 // |extension_id| in |render_view|. |
| 64 // that view. The called javascript function should not return a value other | 65 // |
| 65 // than v8::Undefined(). A DCHECK is setup to break if it is otherwise. | 66 // |extension_id| may be "" to match all extensions. |
| 66 void DispatchChromeHiddenMethod(const std::string& extension_id, | 67 // |render_view| may be NULL to match all render views. |
| 67 const std::string& method_name, | 68 void ForEach(const std::string& extension_id, |
| 68 const base::ListValue& arguments, | 69 content::RenderView* render_view, |
| 69 content::RenderView* render_view) const; | 70 const base::Callback<void(ChromeV8Context*)>& callback) const; |
| 70 | 71 |
| 71 // Cleans up contexts belonging to an unloaded extension. | 72 // Cleans up contexts belonging to an unloaded extension. |
| 72 // | 73 // |
| 73 // Returns the set of ChromeV8Contexts that were removed as a result. These | 74 // 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 | 75 // are safe to interact with until the end of the current event loop, since |
| 75 // they're deleted asynchronously. | 76 // they're deleted asynchronously. |
| 76 ContextSet OnExtensionUnloaded(const std::string& extension_id); | 77 ContextSet OnExtensionUnloaded(const std::string& extension_id); |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 ContextSet contexts_; | 80 ContextSet contexts_; |
| 80 | 81 |
| 81 DISALLOW_COPY_AND_ASSIGN(ChromeV8ContextSet); | 82 DISALLOW_COPY_AND_ASSIGN(ChromeV8ContextSet); |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 } // namespace extensions | 85 } // namespace extensions |
| 85 | 86 |
| 86 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ | 87 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_SET_H_ |
| OLD | NEW |