Guarantee CleanUpAfterPage gets run even if CloseConnection fails.
[chromium-blink-merge.git] / extensions / renderer / extension_frame_helper.h
blob7210f2e0b942e203e04aa620ee3fac2dd10bfa41
1 // Copyright 2013 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.
5 #ifndef EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_
6 #define EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_
8 #include "content/public/common/console_message_level.h"
9 #include "content/public/renderer/render_frame_observer.h"
10 #include "content/public/renderer/render_frame_observer_tracker.h"
12 struct ExtensionMsg_ExternalConnectionInfo;
13 struct ExtensionMsg_TabConnectionInfo;
15 namespace extensions {
17 class Dispatcher;
18 struct Message;
20 // RenderFrame-level plumbing for extension features.
21 class ExtensionFrameHelper
22 : public content::RenderFrameObserver,
23 public content::RenderFrameObserverTracker<ExtensionFrameHelper> {
24 public:
25 ExtensionFrameHelper(content::RenderFrame* render_frame,
26 Dispatcher* extension_dispatcher);
27 ~ExtensionFrameHelper() override;
29 private:
30 // RenderFrameObserver implementation.
31 void DidCreateScriptContext(v8::Handle<v8::Context>,
32 int extension_group,
33 int world_id) override;
34 void WillReleaseScriptContext(v8::Handle<v8::Context>, int world_id) override;
35 bool OnMessageReceived(const IPC::Message& message) override;
37 // IPC handlers.
38 void OnAddMessageToConsole(content::ConsoleMessageLevel level,
39 const std::string& message);
40 void OnExtensionDispatchOnConnect(
41 int target_port_id,
42 const std::string& channel_name,
43 const ExtensionMsg_TabConnectionInfo& source,
44 const ExtensionMsg_ExternalConnectionInfo& info,
45 const std::string& tls_channel_id);
46 void OnExtensionDeliverMessage(int target_port_id,
47 const Message& message);
48 void OnExtensionDispatchOnDisconnect(int port_id,
49 const std::string& error_message);
51 Dispatcher* extension_dispatcher_;
53 DISALLOW_COPY_AND_ASSIGN(ExtensionFrameHelper);
56 } // namespace extensions
58 #endif // EXTENSIONS_RENDERER_EXTENSION_FRAME_HELPER_H_