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

Side by Side Diff: content/plugin/webplugin_proxy.h

Issue 1852593004: Remove content/plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_npapi_test_plugin
Patch Set: . Created 4 years, 8 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
« no previous file with comments | « content/plugin/webplugin_delegate_stub.cc ('k') | content/plugin/webplugin_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PLUGIN_WEBPLUGIN_PROXY_H_
6 #define CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_
7
8 #include <stdint.h>
9
10 #include <string>
11
12 #include "base/containers/hash_tables.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "build/build_config.h"
17 #include "content/child/npapi/webplugin.h"
18 #include "ipc/ipc_message.h"
19 #include "ipc/ipc_sender.h"
20 #include "skia/ext/refptr.h"
21 #include "third_party/skia/include/core/SkCanvas.h"
22 #include "ui/gl/gpu_preference.h"
23 #include "ui/surface/transport_dib.h"
24 #include "url/gurl.h"
25
26 #if defined(OS_MACOSX)
27 #include <ApplicationServices/ApplicationServices.h>
28
29 #include "base/mac/scoped_cftyperef.h"
30 #endif
31
32 namespace content {
33 class PluginChannel;
34 class WebPluginDelegateImpl;
35
36 #if defined(OS_MACOSX)
37 class WebPluginAcceleratedSurfaceProxy;
38 #endif
39
40 // This is an implementation of WebPlugin that proxies all calls to the
41 // renderer.
42 class WebPluginProxy : public WebPlugin,
43 public IPC::Sender {
44 public:
45 // Creates a new proxy for WebPlugin, using the given sender to send the
46 // marshalled WebPlugin calls.
47 WebPluginProxy(PluginChannel* channel,
48 int route_id,
49 const GURL& page_url,
50 int host_render_view_routing_id);
51 ~WebPluginProxy() override;
52
53 void set_delegate(WebPluginDelegateImpl* d) { delegate_ = d; }
54
55 // WebPlugin overrides
56 void Invalidate() override;
57 void InvalidateRect(const gfx::Rect& rect) override;
58 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) override;
59 void SetCookie(const GURL& url,
60 const GURL& first_party_for_cookies,
61 const std::string& cookie) override;
62 std::string GetCookies(const GURL& url,
63 const GURL& first_party_for_cookies) override;
64 void UpdateGeometry(const gfx::Rect& window_rect,
65 const gfx::Rect& clip_rect,
66 const TransportDIB::Handle& windowless_buffer0,
67 const TransportDIB::Handle& windowless_buffer1,
68 int windowless_buffer_index);
69 void CancelDocumentLoad() override;
70 void DidStartLoading() override;
71 void DidStopLoading() override;
72 bool IsOffTheRecord() override;
73 #if defined(OS_MACOSX)
74 void FocusChanged(bool focused) override;
75 void StartIme() override;
76 WebPluginAcceleratedSurface* GetAcceleratedSurface(
77 gfx::GpuPreference gpu_preference) override;
78 void AcceleratedPluginEnabledRendering() override;
79 void AcceleratedPluginAllocatedIOSurface(int32_t width,
80 int32_t height,
81 uint32_t surface_id) override;
82 void AcceleratedPluginSwappedIOSurface() override;
83 #endif
84
85 // IPC::Sender implementation.
86 bool Send(IPC::Message* msg) override;
87
88 // class-specific methods
89
90 // Returns the id of the renderer that contains this plugin.
91 int GetRendererId();
92
93 // Returns the id of the associated render view.
94 int host_render_view_routing_id() const {
95 return host_render_view_routing_id_;
96 }
97
98 // For windowless plugins, paints the given rectangle into the local buffer.
99 void Paint(const gfx::Rect& rect);
100
101 // Callback from the renderer to let us know that a paint occurred.
102 void DidPaint();
103
104 private:
105 class SharedTransportDIB : public base::RefCounted<SharedTransportDIB> {
106 public:
107 explicit SharedTransportDIB(TransportDIB* dib);
108 TransportDIB* dib() { return dib_.get(); }
109 private:
110 friend class base::RefCounted<SharedTransportDIB>;
111 ~SharedTransportDIB();
112
113 scoped_ptr<TransportDIB> dib_;
114 };
115
116 // Handler for sending over the paint event to the plugin.
117 void OnPaint(const gfx::Rect& damaged_rect);
118
119 #if defined(OS_WIN)
120 void CreateCanvasFromHandle(const TransportDIB::Handle& dib_handle,
121 const gfx::Rect& window_rect,
122 skia::RefPtr<SkCanvas>* canvas);
123 #elif defined(OS_MACOSX)
124 static void CreateDIBAndCGContextFromHandle(
125 const TransportDIB::Handle& dib_handle,
126 const gfx::Rect& window_rect,
127 scoped_ptr<TransportDIB>* dib_out,
128 base::ScopedCFTypeRef<CGContextRef>* cg_context_out);
129 #endif
130
131 // Updates the shared memory sections where windowless plugins paint.
132 void SetWindowlessBuffers(const TransportDIB::Handle& windowless_buffer0,
133 const TransportDIB::Handle& windowless_buffer1,
134 const gfx::Rect& window_rect);
135
136 #if defined(OS_MACOSX)
137 CGContextRef windowless_context() const {
138 return windowless_contexts_[windowless_buffer_index_].get();
139 }
140 #else
141 skia::RefPtr<SkCanvas> windowless_canvas() const {
142 return windowless_canvases_[windowless_buffer_index_];
143 }
144 #endif
145
146 scoped_refptr<PluginChannel> channel_;
147 int route_id_;
148 WebPluginDelegateImpl* delegate_;
149 gfx::Rect damaged_rect_;
150 bool waiting_for_paint_;
151 // The url of the main frame hosting the plugin.
152 GURL page_url_;
153
154 // Variables used for desynchronized windowless plugin painting. See note in
155 // webplugin_delegate_proxy.h for how this works. The two sets of windowless_*
156 // fields are for the front-buffer and back-buffer of a buffer flipping system
157 // and windowless_buffer_index_ identifies which set we are using as the
158 // back-buffer at any given time.
159 int windowless_buffer_index_;
160 #if defined(OS_MACOSX)
161 scoped_ptr<TransportDIB> windowless_dibs_[2];
162 base::ScopedCFTypeRef<CGContextRef> windowless_contexts_[2];
163 scoped_ptr<WebPluginAcceleratedSurfaceProxy> accelerated_surface_;
164 #else
165 skia::RefPtr<SkCanvas> windowless_canvases_[2];
166 #endif
167
168 // Contains the routing id of the host render view.
169 int host_render_view_routing_id_;
170
171 base::WeakPtrFactory<WebPluginProxy> weak_factory_;
172 };
173
174 } // namespace content
175
176 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_
OLDNEW
« no previous file with comments | « content/plugin/webplugin_delegate_stub.cc ('k') | content/plugin/webplugin_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698