Chromium Code Reviews| 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 namespace content { | |
| 17 | |
| 18 class BrowserPluginWebContentsObserver: public WebContentsObserver, | |
| 19 public NotificationObserver { | |
| 20 public: | |
| 21 typedef std::set<WebContents*> GuestSet; | |
|
jam
2012/04/04 00:54:45
nit: don't see this used anywhere
Fady Samuel
2012/04/04 16:45:40
Moved to BrowserPluginWebContentsObserver::DidComm
| |
| 22 typedef std::map<WebContents*, int64> GuestMap; | |
|
jam
2012/04/04 00:54:45
nit: this is only used in the private section, so
Fady Samuel
2012/04/04 16:45:40
Done.
| |
| 23 | |
| 24 virtual ~BrowserPluginWebContentsObserver(); | |
| 25 | |
| 26 static BrowserPluginWebContentsObserver* Get( | |
| 27 WebContents* web_contents); | |
|
jam
2012/04/04 00:54:45
for this file, please use TabContents (the concret
Fady Samuel
2012/04/04 16:45:40
Done.
| |
| 28 | |
| 29 // A Host BrowserPluginWebContentsObserver keeps track of | |
| 30 // its guests so that if it navigates away, its associated RenderView | |
| 31 // crashes or it is hidden, it takes appropriate action on the guest. | |
| 32 void AddGuest(WebContents* guest, int64 frame_id); | |
| 33 | |
| 34 void RemoveGuest(WebContents* guest); | |
| 35 | |
| 36 WebContents* host() const { return host_; } | |
| 37 | |
| 38 void set_host(WebContents* host) { host_ = host; } | |
| 39 | |
| 40 int instance_id() const { return instance_id_; } | |
| 41 | |
| 42 void set_instance_id(int instance_id) { instance_id_ = instance_id; } | |
| 43 | |
| 44 // WebContentObserver implementation. | |
| 45 | |
| 46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 47 | |
| 48 virtual void DidCommitProvisionalLoadForFrame( | |
| 49 int64 frame_id, | |
| 50 bool is_main_frame, | |
| 51 const GURL& url, | |
| 52 PageTransition transition_type) OVERRIDE; | |
| 53 | |
| 54 virtual void RenderViewDeleted( | |
| 55 RenderViewHost* render_view_host) OVERRIDE; | |
| 56 | |
| 57 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
| 58 | |
| 59 virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE; | |
| 60 | |
| 61 private: | |
| 62 BrowserPluginWebContentsObserver( | |
|
jam
2012/04/04 00:54:45
nit: this can fit on one line
Fady Samuel
2012/04/04 16:45:40
Done.
| |
| 63 WebContents* web_contents); | |
| 64 | |
| 65 void OnOpenChannelToBrowserPlugin(int32 instance_id, | |
| 66 long long frame_id, | |
| 67 const std::string& src, | |
| 68 const gfx::Size& size); | |
| 69 | |
| 70 void OnMsgGuestReady(); | |
| 71 | |
| 72 void OnMsgResizeGuest(int width, int height); | |
| 73 | |
| 74 void OnRendererPluginChannelCreated(const IPC::ChannelHandle& handle); | |
| 75 | |
| 76 void DestroyGuests(); | |
| 77 | |
| 78 // NotificationObserver method override. | |
| 79 virtual void Observe(int type, | |
| 80 const NotificationSource& source, | |
| 81 const NotificationDetails& details) OVERRIDE; | |
| 82 | |
| 83 // A scoped container for notification registries. | |
| 84 NotificationRegistrar registrar_; | |
| 85 | |
| 86 WebContents* host_; | |
| 87 | |
| 88 // An identifier that uniquely identifies a browser plugin container | |
| 89 // within a house. | |
| 90 int instance_id_; | |
| 91 | |
| 92 GuestMap guests_; | |
| 93 }; | |
| 94 | |
| 95 } // namespace content | |
| 96 | |
| 97 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_WEB_CONTENTS_OBSERVER_H _ | |
| OLD | NEW |