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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host.h

Issue 10377170: Browser Plugin: browser process side changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated to not expose GetPendingRenderViewHost Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
(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_HOST_H__
6 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H__
7 #pragma once
8
9 #include <map>
10 #include <set>
11
12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "googleurl/src/gurl.h"
16 #include "ppapi/c/pp_instance.h"
17 #include "ui/gfx/size.h"
18
19 class WebContentsImpl;
20
21 namespace content {
22
23 // The primary purpose of BrowserPluginHost is to allow an embedder
24 // to manage the lifetime of its guests. It cleans up its guests
25 // on navigation, crashes, and 'hides" guests when it hides.
Charlie Reis 2012/05/17 21:24:05 nit: 'hides" -> "hides" DRAFT: Should that be swap
Fady Samuel 2012/05/18 17:37:52 Fixed. That will make tabbing back to the embedder
Charlie Reis 2012/05/18 20:35:24 Ah, sorry about the draft comment. I was going to
26 // For the guest, BrowserPluginHost keeps track of its embedder,
27 // its BrowserPlugin instance ID, and some initialization state
28 // such as initial size and URL.
29 class BrowserPluginHost: public WebContentsObserver,
30 public NotificationObserver {
31 public:
32 BrowserPluginHost(WebContentsImpl* web_contents);
33
34 virtual ~BrowserPluginHost();
35
36 // Get a guest BrowserPluginHost by its container ID specified
37 // in BrowserPlugin.
38 BrowserPluginHost* GetGuestByContainerID(int container_id);
39
40 // Associate a guest by its container ID.
Charlie Reis 2012/05/17 21:24:05 nit: by -> with
Fady Samuel 2012/05/18 17:37:52 Done.
41 void RegisterContainerInstance(
42 int container_id,
43 BrowserPluginHost* observer);
44
45 // An embedder BrowserPluginHost keeps track of
46 // its guests so that if it navigates away, its associated RenderView
47 // crashes or it is hidden, it takes appropriate action on the guest.
48 void AddGuest(WebContentsImpl* guest, int64 frame_id);
49
50 // This removes a guest from an embedder's guest list.
51 // TODO(fsamuel): Use this when deleting guest after they crash.
52 // ToT plugin crash handling seems to be broken in this case and so I can't
53 // test this scenario at the moment. Delete this comment once fixed.
54 void RemoveGuest(WebContentsImpl* guest);
55
56 WebContentsImpl* embedder() const { return embedder_; }
57 void set_embedder(WebContentsImpl* embedder) { embedder_ = embedder; }
58 int instance_id() const { return instance_id_; }
59 void set_instance_id(int instance_id) { instance_id_ = instance_id; }
60 const GURL& url() const { return url_; }
61 void set_url(const GURL& url) { url_ = url; }
Charlie Reis 2012/05/17 21:24:05 This makes me nervous. Why does the BrowserPlugin
62 const gfx::Size& initial_size() const { return initial_size_; }
63 void set_initial_size(const gfx::Size& size) { initial_size_ = size; }
64 RenderViewHost* pending_render_view_host() const {
65 return pending_render_view_host_;
66 }
67
68 void OnCrossProcessNavigation(RenderViewHost* dest_rvh);
Charlie Reis 2012/05/17 21:24:05 This naming is unclear: is it when the navigation
69
70 // WebContentObserver implementation.
71 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
72 virtual void DidCommitProvisionalLoadForFrame(
73 int64 frame_id,
74 bool is_main_frame,
75 const GURL& url,
76 PageTransition transition_type) OVERRIDE;
77 virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE;
78 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
79 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
80
81 private:
82 typedef std::map<WebContentsImpl*, int64> GuestMap;
83 typedef std::map<int, BrowserPluginHost*> ContainerInstanceMap;
84
85 void OnNavigateFromEmbedder(int32 instance_id,
86 long long frame_id,
87 const std::string& src,
88 const gfx::Size& size);
89
90 void OnNavigateFromGuest(PP_Instance instance,
91 const std::string& src);
92
93 void OnMapInstance(int routing_id, PP_Instance instance);
94
95 void OnResizeGuest(int width, int height);
96
97 void OnConnectToChannel(const IPC::ChannelHandle& handle);
98
99 void DestroyGuests();
100
101 // NotificationObserver method override.
102 virtual void Observe(int type,
103 const NotificationSource& source,
104 const NotificationDetails& details) OVERRIDE;
105
106 // A scoped container for notification registries.
107 NotificationRegistrar registrar_;
108 WebContentsImpl* embedder_;
109 // An identifier that uniquely identifies a browser plugin container
110 // within an embedder.
111 int instance_id_;
112 GURL url_;
113 gfx::Size initial_size_;
114 GuestMap guests_;
115 ContainerInstanceMap guests_by_container_id_;
116 RenderViewHost* pending_render_view_host_;
Charlie Reis 2012/05/17 21:24:05 I'm still not a fan of keeping track of this outsi
117 };
118
119 } // namespace content
120
121 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698