OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_BROWSER_PLUGIN_BROWSER_PLUGIN_WEB_CONTENTS_OBSERVER_H__ | |
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_WEB_CONTENTS_OBSERVER_H__ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 | |
11 #include "content/public/browser/notification_registrar.h" | |
12 #include "content/public/browser/notification_observer.h" | |
13 #include "content/public/browser/web_contents_observer.h" | |
14 #include "ui/gfx/size.h" | |
15 | |
16 class WebContentsImpl; | |
17 | |
18 namespace content { | |
19 | |
20 class BrowserPluginWebContentsObserver: public WebContentsObserver, | |
21 public NotificationObserver { | |
22 public: | |
23 BrowserPluginWebContentsObserver(WebContentsImpl* web_contents); | |
24 | |
25 virtual ~BrowserPluginWebContentsObserver(); | |
26 | |
27 // A Host BrowserPluginWebContentsObserver keeps track of | |
28 // its guests so that if it navigates away, its associated RenderView | |
29 // crashes or it is hidden, it takes appropriate action on the guest. | |
30 void AddGuest(WebContentsImpl* guest, int64 frame_id); | |
31 | |
32 void RemoveGuest(WebContentsImpl* guest); | |
33 | |
34 WebContentsImpl* host() const { return host_; } | |
35 | |
36 void set_host(WebContentsImpl* host) { host_ = host; } | |
37 | |
38 int instance_id() const { return instance_id_; } | |
39 | |
40 void set_instance_id(int instance_id) { instance_id_ = instance_id; } | |
41 | |
42 // WebContentObserver implementation. | |
43 | |
44 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
45 | |
46 virtual void DidCommitProvisionalLoadForFrame( | |
47 int64 frame_id, | |
48 bool is_main_frame, | |
49 const GURL& url, | |
50 PageTransition transition_type) OVERRIDE; | |
51 | |
52 virtual void RenderViewDeleted( | |
53 RenderViewHost* render_view_host) OVERRIDE; | |
54 | |
55 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
56 | |
57 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | |
58 | |
59 private: | |
60 typedef std::map<WebContentsImpl*, int64> GuestMap; | |
61 | |
62 void OnOpenChannelToBrowserPlugin(int32 instance_id, | |
63 long long frame_id, | |
64 const std::string& src, | |
65 const gfx::Size& size); | |
66 | |
67 void OnGuestReady(); | |
68 | |
69 void OnResizeGuest(int width, int height); | |
70 | |
71 void OnRendererPluginChannelCreated(const IPC::ChannelHandle& handle); | |
72 | |
73 void DestroyGuests(); | |
74 | |
75 // NotificationObserver method override. | |
76 virtual void Observe(int type, | |
77 const NotificationSource& source, | |
78 const NotificationDetails& details) OVERRIDE; | |
79 | |
80 // A scoped container for notification registries. | |
81 NotificationRegistrar registrar_; | |
82 | |
83 WebContentsImpl* host_; | |
84 | |
85 // An identifier that uniquely identifies a browser plugin container | |
86 // within a host. | |
87 int instance_id_; | |
88 | |
89 GuestMap guests_; | |
90 }; | |
91 | |
92 } // namespace content | |
93 | |
94 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_WEB_CONTENTS_OBSERVER_H
_ | |
OLD | NEW |