| 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_RENDER_FRAME_OBSERVER_NATIVES_H_ | 5 #ifndef EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ |
| 6 #define EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ | 6 #define EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 9 #include "extensions/renderer/object_backed_native_handler.h" | 10 #include "extensions/renderer/object_backed_native_handler.h" |
| 10 | 11 |
| 11 namespace extensions { | 12 namespace extensions { |
| 12 class ScriptContext; | 13 class ScriptContext; |
| 13 | 14 |
| 14 // Native functions for JS to run callbacks upon RenderFrame events. | 15 // Native functions for JS to run callbacks upon RenderFrame events. |
| 15 class RenderFrameObserverNatives : public ObjectBackedNativeHandler { | 16 class RenderFrameObserverNatives : public ObjectBackedNativeHandler { |
| 16 public: | 17 public: |
| 17 explicit RenderFrameObserverNatives(ScriptContext* context); | 18 explicit RenderFrameObserverNatives(ScriptContext* context); |
| 19 ~RenderFrameObserverNatives() override; |
| 18 | 20 |
| 19 private: | 21 private: |
| 22 void Invalidate() override; |
| 23 |
| 20 // Runs a callback upon creation of new document element inside a render frame | 24 // Runs a callback upon creation of new document element inside a render frame |
| 21 // (document.documentElement). | 25 // (document.documentElement). |
| 22 void OnDocumentElementCreated( | 26 void OnDocumentElementCreated( |
| 23 const v8::FunctionCallbackInfo<v8::Value>& args); | 27 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 24 | 28 |
| 29 void InvokeCallback(v8::Global<v8::Function> callback, bool succeeded); |
| 30 |
| 31 base::WeakPtrFactory<RenderFrameObserverNatives> weak_ptr_factory_; |
| 32 |
| 25 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverNatives); | 33 DISALLOW_COPY_AND_ASSIGN(RenderFrameObserverNatives); |
| 26 }; | 34 }; |
| 27 | 35 |
| 28 } // namespace extensions | 36 } // namespace extensions |
| 29 | 37 |
| 30 #endif // EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ | 38 #endif // EXTENSIONS_RENDERER_RENDER_FRAME_OBSERVER_NATIVES_H_ |
| OLD | NEW |