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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.h

Issue 9968097: Browser Plugin: Renderer-side changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated after merging with ToT 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_PLACEHOLDER_H_ 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_PLACEHOLDER_H_ 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/process.h" 9 #include "base/process.h"
10 #include "content/renderer/render_view_impl.h"
10 #include "ipc/ipc_channel_handle.h" 11 #include "ipc/ipc_channel_handle.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
13 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
14 #include "webkit/plugins/webview_plugin.h" 15 #include "webkit/plugins/webview_plugin.h"
15 16
16 namespace content { 17 namespace content {
17 class RenderView; 18 class RenderView;
18 } 19 }
19 20
20 namespace WebKit { 21 namespace WebKit {
21 class WebPlugin; 22 class WebPlugin;
22 } 23 }
23 24
24 // A browser plugin is a plugin container that hosts an out-of-process "guest" 25 // A browser plugin is a plugin container that hosts an out-of-process "guest"
25 // RenderView. Loading up a new process, creating a new RenderView, navigating 26 // RenderView. Loading up a new process, creating a new RenderView, navigating
26 // to a given URL, and establishing a guest-to-host channel can take hundreds 27 // to a given URL, and establishing a guest-to-host channel can take hundreds
27 // of milliseconds. Furthermore, a RenderView's associated browser-side 28 // of milliseconds. Furthermore, a RenderView's associated browser-side
28 // WebContents, RenderViewHost, and SiteInstance must be created and accessed on 29 // WebContents, RenderViewHost, and SiteInstance must be created and accessed on
29 // the UI thread of the browser process. 30 // the UI thread of the browser process.
30 // 31 //
31 // To avoid blocking the host RenderView and to avoid introducing the potential 32 // To avoid blocking the host RenderView and to avoid introducing the potential
32 // for deadlock, the BrowserPluginPlaceholder takes place of the guest 33 // for deadlock, the BrowserPlugin takes place of the guest
33 // RenderView until the guest has established a connection with its host 34 // RenderView until the guest has established a connection with its host
34 // RenderView. This permits loading the guest to happen asynchronously, while 35 // RenderView. This permits loading the guest to happen asynchronously, while
35 // the host RenderView is permitted to continue to receive and process events. 36 // the host RenderView is permitted to continue to receive and process events.
36 class BrowserPluginPlaceholder: public webkit::WebViewPlugin::Delegate { 37 //
38 // Furthermore, embedder-initiated navigations can point to a new guest
39 // RenderView on an entirely different process. BrowserPlugin is the consistent
40 // facade that the embedder talks to regardless of what process it's
41 // actually communicating with.
42 class BrowserPlugin {
37 public: 43 public:
38 // Creates a new WebViewPlugin with a BrowserPluginPlaceholder as a delegate. 44 // Creates a new WebViewPlugin with a BrowserPlugin as a delegate.
39 static webkit::WebViewPlugin* Create( 45 static WebKit::WebPlugin* Create(
40 content::RenderView* render_view, 46 RenderViewImpl* render_view,
41 WebKit::WebFrame* frame, 47 WebKit::WebFrame* frame,
42 const WebKit::WebPluginParams& params); 48 const WebKit::WebPluginParams& params);
43 49
44 static BrowserPluginPlaceholder* FromID(int id); 50 static BrowserPlugin* FromID(int id);
45 51
46 void RegisterPlaceholder(int id, BrowserPluginPlaceholder* placeholder); 52 static void Register(int id, BrowserPlugin* placeholder);
jam 2012/05/16 02:22:40 these are only called from browser_plugin.cc from
Fady Samuel 2012/05/16 04:43:54 Done.
47 void UnregisterPlaceholder(int id); 53 static void Unregister(int id);
48 54
49 int GetID() { return id_; } 55 int GetID() { return id_; }
jam 2012/05/16 02:22:40 nit: should be int id() const { return id_; } ac
Fady Samuel 2012/05/16 04:43:54 Removed.
50 56
51 webkit::WebViewPlugin* plugin() { return plugin_; } 57 webkit::WebViewPlugin* plugin_placeholder() { return placeholder_; }
jam 2012/05/16 02:22:40 nit: placeholder()
Fady Samuel 2012/05/16 04:43:54 Done.
58
59 webkit::ppapi::WebPluginImpl* plugin() { return plugin_; }
52 60
53 const WebKit::WebPluginParams& plugin_params() const; 61 const WebKit::WebPluginParams& plugin_params() const;
jam 2012/05/16 02:22:40 if the definition is in the cc file, this can't be
Fady Samuel 2012/05/16 04:43:54 Moved it to here.
54 62
55 void GuestReady(base::ProcessHandle process_handle, 63 void LoadGuest(int guest_process_id,
56 const IPC::ChannelHandle& channel_handle); 64 const IPC::ChannelHandle& channel_handle);
57 65
58 content::RenderView* render_view() { return render_view_; } 66 RenderViewImpl* render_view() { return render_view_; }
59 67
60 private: 68 private:
61 BrowserPluginPlaceholder(content::RenderView* render_view, 69 BrowserPlugin(RenderViewImpl* render_view,
62 WebKit::WebFrame* frame, 70 WebKit::WebFrame* frame,
jam 2012/05/16 02:22:40 nit: tabbing
Fady Samuel 2012/05/16 04:43:54 Done.
63 const WebKit::WebPluginParams& params, 71 const WebKit::WebPluginParams& params,
64 const std::string& html_data); 72 const std::string& html_data);
65 virtual ~BrowserPluginPlaceholder(); 73 virtual ~BrowserPlugin();
66 74
67 // Grabs the width, height, and source URL of the browser plugin 75 // Grabs the width, height, and source URL of the browser plugin
68 // from the element's attributes. If not found, it uses the defaults 76 // from the element's attributes. If not found, it uses the defaults
69 // specified here as parameters. 77 // specified here as parameters.
70 void GetPluginParameters(int default_width, int default_height, 78 void GetPluginParameters(int default_width, int default_height,
71 const std::string& default_src); 79 const std::string& default_src);
72 // Replace this placeholder with the real browser plugin. 80 // Replace the current guest with a new guest.
73 void LoadGuest(WebKit::WebPlugin* new_plugin); 81 void Replace(webkit::ppapi::WebPluginImpl* new_plugin);
74 82
75 virtual void BindWebFrame(WebKit::WebFrame* frame) OVERRIDE { } 83 RenderViewImpl* render_view_;
76 virtual void WillDestroyPlugin() OVERRIDE;
77 virtual void ShowContextMenu(const WebKit::WebMouseEvent&) OVERRIDE { }
78
79 content::RenderView* render_view_;
80 WebKit::WebPluginParams plugin_params_; 84 WebKit::WebPluginParams plugin_params_;
81 webkit::WebViewPlugin* plugin_; 85 webkit::WebViewPlugin* placeholder_;
86 webkit::ppapi::WebPluginImpl* plugin_;
82 int id_; 87 int id_;
83 gfx::Size size_; 88 gfx::Size size_;
84 std::string src_; 89 std::string src_;
85 90
86 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPlaceholder); 91 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
87 }; 92 };
88 93
89 #endif // CONTNET_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_PLACEHOLDER_H_ 94 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698