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_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | |
7 #pragma once | |
8 | |
9 #include "base/process.h" | |
10 #include "content/renderer/render_view_impl.h" | |
11 #include "ipc/ipc_channel_handle.h" | |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | |
14 #include "ui/gfx/size.h" | |
15 #include "webkit/plugins/webview_plugin.h" | |
16 | |
17 namespace content { | |
18 class RenderView; | |
19 } | |
20 | |
21 namespace WebKit { | |
22 class WebPlugin; | |
23 } | |
24 | |
25 // A browser plugin is a plugin container that hosts an out-of-process "guest" | |
26 // RenderView. Loading up a new process, creating a new RenderView, navigating | |
27 // to a given URL, and establishing a guest-to-embedder channel can take | |
28 // hundreds of milliseconds. Furthermore, a RenderView's associated browser-side | |
29 // WebContents, RenderViewHost, and SiteInstance must be created and accessed on | |
30 // the UI thread of the browser process. | |
31 // | |
32 // To avoid blocking the embedder RenderView and to avoid introducing the | |
33 // potential for deadlock, BrowserPlugin attaches a placeholder that takes | |
34 // place of the guest RenderView until the guest has established a connection | |
35 // with its embedder RenderView. This permits asynchronously loading of the | |
36 // guest while the embedder RenderView is permitted to continue to receive and | |
37 // process events. | |
38 // | |
39 // Furthermore, certain navigations can swap to a new guest RenderView on an | |
40 // different process. BrowserPlugin is the consistent facade that the embedder's | |
41 // WebKit instance talks to regardless of which process it's communicating with. | |
42 class BrowserPlugin { | |
43 public: | |
44 // Creates a new WebViewPlugin with a BrowserPlugin as a delegate. | |
45 static WebKit::WebPlugin* Create( | |
46 RenderViewImpl* render_view, | |
47 WebKit::WebFrame* frame, | |
48 const WebKit::WebPluginParams& params); | |
49 | |
50 static BrowserPlugin* FromID(int id); | |
51 | |
52 webkit::WebViewPlugin* placeholder() { return placeholder_; } | |
53 | |
54 webkit::ppapi::WebPluginImpl* plugin() { return plugin_; } | |
55 | |
56 const WebKit::WebPluginParams& plugin_params() const { | |
57 return plugin_params_; | |
58 } | |
59 | |
60 void LoadGuest(int guest_process_id, | |
61 const IPC::ChannelHandle& channel_handle); | |
62 | |
63 void AdvanceFocus(bool reverse); | |
64 | |
65 RenderViewImpl* render_view() { return render_view_; } | |
66 | |
67 private: | |
68 BrowserPlugin(RenderViewImpl* render_view, | |
69 WebKit::WebFrame* frame, | |
70 const WebKit::WebPluginParams& params, | |
71 const std::string& html_data); | |
72 virtual ~BrowserPlugin(); | |
73 | |
74 // Parses the source URL of the browser plugin from the element's attributes | |
75 // and outputs them. If not found, it outputs the defaults specified here as | |
76 // parameters. | |
77 void ParseSrcAttribute(const std::string& default_src, std::string* src); | |
78 // Replace the current guest with a new guest. | |
79 void Replace(webkit::ppapi::WebPluginImpl* new_plugin); | |
80 | |
81 RenderViewImpl* render_view_; | |
82 WebKit::WebPluginParams plugin_params_; | |
83 webkit::WebViewPlugin* placeholder_; | |
84 webkit::ppapi::WebPluginImpl* plugin_; | |
85 int id_; | |
86 | |
87 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | |
88 }; | |
89 | |
90 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | |
OLD | NEW |