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

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 base::WeakPtr<WebContentsInterfaceRegistry> GetWeakPtr() override;
30 void SetCurrentTargetFrameForTesting(
31 RenderFrameHost* render_frame_host) override;
32
33 private:
34 // WebContentsObserver:
35 void RenderFrameCreated(RenderFrameHost* render_frame_host) override;
36 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
37 void WebContentsDestroyed() override;
38
39 // WebContentsInterfaceRegistry:
40 void AddFrameInterface(const std::string& name,
41 std::unique_ptr<FrameInterfaceBase> iface) override;
42 void RemoveFrameInterface(const std::string& name) override;
43 void WillDispatchForFrame(RenderFrameHost* render_frame_host) override;
44
45 void AddInterfacesToFrame(RenderFrameHost* render_frame_host);
46 void RemoveInterfacesFromFrame(RenderFrameHost* render_frame_host);
47
48 static void AddInterfaceToFrame(const std::string& name,
49 FrameInterfaceBase* iface,
50 RenderFrameHost* render_frame_host);
51
52 RenderFrameHost* current_target_frame_host_ = nullptr;
53
54 // A map of all interfaces managed by this registry. All frames belonging to
55 // web_contents() have corresponding routed interfaces attached to them as
56 // long as they and |this| are alive.
57 std::map<std::string, std::unique_ptr<FrameInterfaceBase>> frame_interfaces_;
58
59 // The set of all RenderFrameHost's currently affected by this registry.
60 std::unordered_set<RenderFrameHost*> frames_;
61
62 base::WeakPtrFactory<WebContentsInterfaceRegistryImpl> weak_factory_;
63
64 DISALLOW_COPY_AND_ASSIGN(WebContentsInterfaceRegistryImpl);
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_INTERFACE_REGISTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698