Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: content/browser/web_contents/web_contents_interface_registry_impl.h

Issue 2310563002: Adds routed interface support between RenderFrameHost and RenderFrame (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_INTERFACE_REGISTRY_IMPL_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_INTERFACE_REGISTRY_IMPL_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <unordered_set>
12
13 #include "base/macros.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/web_contents_interface_registry.h"
16 #include "content/public/browser/web_contents_observer.h"
17
18 namespace content {
19
20 class CONTENT_EXPORT WebContentsInterfaceRegistryImpl
21 : public WebContentsInterfaceRegistry,
22 public WebContentsObserver {
23 public:
24 explicit WebContentsInterfaceRegistryImpl(WebContents* web_contents);
25 ~WebContentsInterfaceRegistryImpl() override;
26
27 // WebContentsInterfaceRegistry:
28 RenderFrameHost* GetCurrentTargetFrame() override;
29 void SetCurrentTargetFrameForTesting(
30 RenderFrameHost* render_frame_host) override;
31
32 private:
33 // WebContentsObserver:
34 void RenderFrameCreated(RenderFrameHost* render_frame_host) override;
35 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
36
37 // WebContentsInterfaceRegistry:
38 void AddFrameInterface(const std::string& name,
39 std::unique_ptr<FrameInterfaceBase> iface) override;
40 void WillDispatchForFrame(RenderFrameHost* render_frame_host) override;
41
42 void AddInterfacesToFrame(RenderFrameHost* render_frame_host);
43 void RemoveInterfacesFromFrame(RenderFrameHost* render_frame_host);
44
45 static void AddInterfaceToFrame(const std::string& name,
46 FrameInterfaceBase* iface,
47 RenderFrameHost* render_frame_host);
48
49 RenderFrameHost* current_target_frame_host_ = nullptr;
50
51 // A map of all interfaces managed by this registry. All frames belonging to
52 // web_contents() have corresponding routed interfaces attached to them as
53 // long as they and |this| are alive.
54 std::map<std::string, std::unique_ptr<FrameInterfaceBase>> frame_interfaces_;
55
56 // The set of all RenderFrameHost's currently affected by this registry.
57 std::unordered_set<RenderFrameHost*> frames_;
58
59 DISALLOW_COPY_AND_ASSIGN(WebContentsInterfaceRegistryImpl);
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_INTERFACE_REGISTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698