kozyatinskiy | c8bc9a58 | 2015-03-06 09:33:41 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef EXTENSIONS_RENDERER_SCRIPT_INJECTION_CALLBACK_H_ |
| 6 | #define EXTENSIONS_RENDERER_SCRIPT_INJECTION_CALLBACK_H_ |
| 7 | |
rdevlin.cronin | 3e11c986 | 2015-06-04 19:54:25 | [diff] [blame] | 8 | #include "base/callback.h" |
kozyatinskiy | c8bc9a58 | 2015-03-06 09:33:41 | [diff] [blame] | 9 | #include "base/macros.h" |
| 10 | #include "third_party/WebKit/public/web/WebScriptExecutionCallback.h" |
| 11 | #include "v8/include/v8.h" |
| 12 | |
| 13 | namespace blink { |
kozyatinskiy | c8bc9a58 | 2015-03-06 09:33:41 | [diff] [blame] | 14 | template<typename T> class WebVector; |
| 15 | } |
| 16 | |
| 17 | namespace extensions { |
kozyatinskiy | c8bc9a58 | 2015-03-06 09:33:41 | [diff] [blame] | 18 | |
| 19 | // A wrapper around a callback to notify a script injection when injection |
| 20 | // completes. |
| 21 | // This class manages its own lifetime. |
| 22 | class ScriptInjectionCallback : public blink::WebScriptExecutionCallback { |
| 23 | public: |
rdevlin.cronin | 3e11c986 | 2015-06-04 19:54:25 | [diff] [blame] | 24 | using CompleteCallback = |
| 25 | base::Callback<void( |
| 26 | const blink::WebVector<v8::Local<v8::Value>>& result)>; |
| 27 | |
| 28 | ScriptInjectionCallback(const CompleteCallback& injection_completed_callback); |
kozyatinskiy | c8bc9a58 | 2015-03-06 09:33:41 | [diff] [blame] | 29 | ~ScriptInjectionCallback() override; |
| 30 | |
| 31 | void completed( |
| 32 | const blink::WebVector<v8::Local<v8::Value> >& result) override; |
| 33 | |
| 34 | private: |
rdevlin.cronin | 3e11c986 | 2015-06-04 19:54:25 | [diff] [blame] | 35 | CompleteCallback injection_completed_callback_; |
kozyatinskiy | c8bc9a58 | 2015-03-06 09:33:41 | [diff] [blame] | 36 | |
| 37 | DISALLOW_COPY_AND_ASSIGN(ScriptInjectionCallback); |
| 38 | }; |
| 39 | |
| 40 | } // namespace extensions |
| 41 | |
| 42 | #endif // EXTENSIONS_RENDERER_SCRIPT_INJECTION_CALLBACK_H_ |