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

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

Issue 299753011: Move allocate instance id to chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: HasPermission function moved Created 6 years, 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_H_ 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
7 7
8 #include "third_party/WebKit/public/web/WebPlugin.h" 8 #include "third_party/WebKit/public/web/WebPlugin.h"
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/sequenced_task_runner_helpers.h" 12 #include "base/sequenced_task_runner_helpers.h"
13 #include "base/values.h"
14 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" 13 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
15 #include "content/renderer/mouse_lock_dispatcher.h" 14 #include "content/renderer/mouse_lock_dispatcher.h"
16 #include "content/renderer/render_view_impl.h" 15 #include "content/renderer/render_view_impl.h"
17 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 16 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
18 #include "third_party/WebKit/public/web/WebDragStatus.h" 17 #include "third_party/WebKit/public/web/WebDragStatus.h"
19 #include "third_party/WebKit/public/web/WebWidget.h" 18 #include "third_party/WebKit/public/web/WebWidget.h"
20 19
21 struct BrowserPluginHostMsg_AutoSize_Params; 20 struct BrowserPluginHostMsg_AutoSize_Params;
22 struct BrowserPluginHostMsg_ResizeGuest_Params; 21 struct BrowserPluginHostMsg_ResizeGuest_Params;
23 struct BrowserPluginMsg_Attach_ACK_Params;
24 struct BrowserPluginMsg_UpdateRect_Params; 22 struct BrowserPluginMsg_UpdateRect_Params;
25 struct FrameMsg_BuffersSwapped_Params; 23 struct FrameMsg_BuffersSwapped_Params;
26 24
27 namespace content { 25 namespace content {
28 26
29 class ChildFrameCompositingHelper; 27 class ChildFrameCompositingHelper;
30 class BrowserPluginManager; 28 class BrowserPluginManager;
31 class MockBrowserPlugin; 29 class MockBrowserPlugin;
32 30
33 class CONTENT_EXPORT BrowserPlugin : 31 class CONTENT_EXPORT BrowserPlugin :
(...skipping 19 matching lines...) Expand all
53 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. 51 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value.
54 std::string GetDOMAttributeValue(const std::string& attribute_name) const; 52 std::string GetDOMAttributeValue(const std::string& attribute_name) const;
55 // Checks if the attribute |attribute_name| exists in the DOM. 53 // Checks if the attribute |attribute_name| exists in the DOM.
56 bool HasDOMAttribute(const std::string& attribute_name) const; 54 bool HasDOMAttribute(const std::string& attribute_name) const;
57 55
58 // Get the allowtransparency attribute value. 56 // Get the allowtransparency attribute value.
59 bool GetAllowTransparencyAttribute() const; 57 bool GetAllowTransparencyAttribute() const;
60 // Parse the allowtransparency attribute and adjust transparency of 58 // Parse the allowtransparency attribute and adjust transparency of
61 // BrowserPlugin accordingly. 59 // BrowserPlugin accordingly.
62 void ParseAllowTransparencyAttribute(); 60 void ParseAllowTransparencyAttribute();
63 // Get the src attribute value of the BrowserPlugin instance.
64 std::string GetSrcAttribute() const;
65 // Parse the src attribute value of the BrowserPlugin instance.
66 bool ParseSrcAttribute(std::string* error_message);
67 // Get the autosize attribute value. 61 // Get the autosize attribute value.
68 bool GetAutoSizeAttribute() const; 62 bool GetAutoSizeAttribute() const;
69 // Parses the autosize attribute value. 63 // Parses the autosize attribute value.
70 void ParseAutoSizeAttribute(); 64 void ParseAutoSizeAttribute();
71 // Get the maxheight attribute value. 65 // Get the maxheight attribute value.
72 int GetMaxHeightAttribute() const; 66 int GetMaxHeightAttribute() const;
73 // Get the maxwidth attribute value. 67 // Get the maxwidth attribute value.
74 int GetMaxWidthAttribute() const; 68 int GetMaxWidthAttribute() const;
75 // Get the minheight attribute value. 69 // Get the minheight attribute value.
76 int GetMinHeightAttribute() const; 70 int GetMinHeightAttribute() const;
77 // Get the minwidth attribute value. 71 // Get the minwidth attribute value.
78 int GetMinWidthAttribute() const; 72 int GetMinWidthAttribute() const;
79 // Parse the minwidth, maxwidth, minheight, and maxheight attribute values. 73 // Parse the minwidth, maxwidth, minheight, and maxheight attribute values.
80 void ParseSizeContraintsChanged(); 74 void ParseSizeContraintsChanged();
81 // The partition identifier string is stored as UTF-8.
82 std::string GetPartitionAttribute() const;
83 // This method can be successfully called only before the first navigation for
84 // this instance of BrowserPlugin. If an error occurs, the |error_message| is
85 // set appropriately to indicate the failure reason.
86 bool ParsePartitionAttribute(std::string* error_message);
87 // True if the partition attribute can be removed.
88 bool CanRemovePartitionAttribute(std::string* error_message);
89 75
90 bool InAutoSizeBounds(const gfx::Size& size) const; 76 bool InAutoSizeBounds(const gfx::Size& size) const;
91 77
92 // Get the guest's DOMWindow proxy. 78 // Get the guest's DOMWindow proxy.
93 NPObject* GetContentWindow() const; 79 NPObject* GetContentWindow() const;
94 80
95 // Returns whether the guest process has crashed. 81 // Returns whether the guest process has crashed.
96 bool guest_crashed() const { return guest_crashed_; } 82 bool guest_crashed() const { return guest_crashed_; }
97 // Returns whether this BrowserPlugin has requested an instance ID.
98 bool HasNavigated() const;
99 // Returns whether this BrowserPlugin has allocated an instance ID. 83 // Returns whether this BrowserPlugin has allocated an instance ID.
100 bool HasGuestInstanceID() const; 84 bool HasGuestInstanceID() const;
101 85
102 // Informs the guest of an updated focus state. 86 // Informs the guest of an updated focus state.
103 void UpdateGuestFocusState(); 87 void UpdateGuestFocusState();
104 // Indicates whether the guest should be focused. 88 // Indicates whether the guest should be focused.
105 bool ShouldGuestBeFocused() const; 89 bool ShouldGuestBeFocused() const;
106 90
107 // Embedder's device scale factor changed, we need to update the guest 91 // Embedder's device scale factor changed, we need to update the guest
108 // renderer. 92 // renderer.
109 void UpdateDeviceScaleFactor(float device_scale_factor); 93 void UpdateDeviceScaleFactor(float device_scale_factor);
110 94
111 // A request to enable hardware compositing. 95 // A request to enable hardware compositing.
112 void EnableCompositing(bool enable); 96 void EnableCompositing(bool enable);
113 97
114 // Called when a guest instance ID has been allocated by the browser process.
115 void OnInstanceIDAllocated(int guest_instance_id);
116 // Provided that a guest instance ID has been allocated, this method attaches 98 // Provided that a guest instance ID has been allocated, this method attaches
117 // this BrowserPlugin instance to that guest. |extra_params| are parameters 99 // this BrowserPlugin instance to that guest. |extra_params| are parameters
118 // passed in by the content embedder to the browser process. 100 // passed in by the content embedder to the browser process.
119 void Attach(int guest_instance_id, 101 void Attach(int guest_instance_id,
120 scoped_ptr<base::DictionaryValue> extra_params); 102 scoped_ptr<base::DictionaryValue> extra_params);
121 103
122 // Notify the plugin about a compositor commit so that frame ACKs could be 104 // Notify the plugin about a compositor commit so that frame ACKs could be
123 // sent, if needed. 105 // sent, if needed.
124 void DidCommitCompositorFrame(); 106 void DidCommitCompositorFrame();
125 107
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Gets the Min Height value used for auto size. 198 // Gets the Min Height value used for auto size.
217 int GetAdjustedMinHeight() const; 199 int GetAdjustedMinHeight() const;
218 // Gets the Min Width value used for auto size. 200 // Gets the Min Width value used for auto size.
219 int GetAdjustedMinWidth() const; 201 int GetAdjustedMinWidth() const;
220 202
221 // Virtual to allow for mocking in tests. 203 // Virtual to allow for mocking in tests.
222 virtual float GetDeviceScaleFactor() const; 204 virtual float GetDeviceScaleFactor() const;
223 205
224 void ShowSadGraphic(); 206 void ShowSadGraphic();
225 207
226 // Parses the attributes of the browser plugin from the element's attributes
227 // and sets them appropriately.
228 void ParseAttributes();
229
230 // Triggers the event-listeners for |event_name|. Note that the function 208 // Triggers the event-listeners for |event_name|. Note that the function
231 // frees all the values in |props|. 209 // frees all the values in |props|.
232 void TriggerEvent(const std::string& event_name, 210 void TriggerEvent(const std::string& event_name,
233 std::map<std::string, base::Value*>* props); 211 std::map<std::string, base::Value*>* props);
234 212
235 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state. 213 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state.
236 void PopulateResizeGuestParameters( 214 void PopulateResizeGuestParameters(
237 BrowserPluginHostMsg_ResizeGuest_Params* params, 215 BrowserPluginHostMsg_ResizeGuest_Params* params,
238 const gfx::Rect& view_size, 216 const gfx::Rect& view_size,
239 bool needs_repaint); 217 bool needs_repaint);
240 218
241 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. 219 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state.
242 void PopulateAutoSizeParameters( 220 void PopulateAutoSizeParameters(
243 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled); 221 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled);
244 222
245 // Populates both AutoSize and ResizeGuest parameters based on the current 223 // Populates both AutoSize and ResizeGuest parameters based on the current
246 // autosize state. 224 // autosize state.
247 void GetSizeParams( 225 void GetSizeParams(
248 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, 226 BrowserPluginHostMsg_AutoSize_Params* auto_size_params,
249 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, 227 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params,
250 bool needs_repaint); 228 bool needs_repaint);
251 229
252 // Informs the guest of an updated autosize state. 230 // Informs the guest of an updated autosize state.
253 void UpdateGuestAutoSizeState(bool auto_size_enabled); 231 void UpdateGuestAutoSizeState(bool auto_size_enabled);
254 232
255 233
256 // IPC message handlers. 234 // IPC message handlers.
257 // Please keep in alphabetical order. 235 // Please keep in alphabetical order.
258 void OnAdvanceFocus(int instance_id, bool reverse); 236 void OnAdvanceFocus(int instance_id, bool reverse);
259 void OnAttachACK(int instance_id, 237 void OnAttachACK(int instance_id);
260 const BrowserPluginMsg_Attach_ACK_Params& ack_params);
261 void OnBuffersSwapped(int instance_id, 238 void OnBuffersSwapped(int instance_id,
262 const FrameMsg_BuffersSwapped_Params& params); 239 const FrameMsg_BuffersSwapped_Params& params);
263 void OnCompositorFrameSwapped(const IPC::Message& message); 240 void OnCompositorFrameSwapped(const IPC::Message& message);
264 void OnCopyFromCompositingSurface(int instance_id, 241 void OnCopyFromCompositingSurface(int instance_id,
265 int request_id, 242 int request_id,
266 gfx::Rect source_rect, 243 gfx::Rect source_rect,
267 gfx::Size dest_size); 244 gfx::Size dest_size);
268 void OnGuestContentWindowReady(int instance_id, 245 void OnGuestContentWindowReady(int instance_id,
269 int content_window_routing_id); 246 int content_window_routing_id);
270 void OnGuestGone(int instance_id); 247 void OnGuestGone(int instance_id);
(...skipping 19 matching lines...) Expand all
290 bool paint_ack_received_; 267 bool paint_ack_received_;
291 gfx::Rect plugin_rect_; 268 gfx::Rect plugin_rect_;
292 float last_device_scale_factor_; 269 float last_device_scale_factor_;
293 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. 270 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer.
294 SkBitmap* sad_guest_; 271 SkBitmap* sad_guest_;
295 bool guest_crashed_; 272 bool guest_crashed_;
296 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; 273 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_;
297 bool is_auto_size_state_dirty_; 274 bool is_auto_size_state_dirty_;
298 // Maximum size constraint for autosize. 275 // Maximum size constraint for autosize.
299 gfx::Size max_auto_size_; 276 gfx::Size max_auto_size_;
300 std::string storage_partition_id_;
301 bool persist_storage_;
302 bool valid_partition_id_;
303 int content_window_routing_id_; 277 int content_window_routing_id_;
304 bool plugin_focused_; 278 bool plugin_focused_;
305 // Tracks the visibility of the browser plugin regardless of the whole 279 // Tracks the visibility of the browser plugin regardless of the whole
306 // embedder RenderView's visibility. 280 // embedder RenderView's visibility.
307 bool visible_; 281 bool visible_;
308 282
309 const bool auto_navigate_; 283 const bool auto_navigate_;
310 std::string html_string_; 284 std::string html_string_;
311 285
312 WebCursor cursor_; 286 WebCursor cursor_;
313 287
314 gfx::Size last_view_size_; 288 gfx::Size last_view_size_;
315 bool before_first_navigation_;
316 bool mouse_locked_; 289 bool mouse_locked_;
317 290
318 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to 291 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to
319 // store the BrowserPlugin's BrowserPluginManager in a member variable to 292 // store the BrowserPlugin's BrowserPluginManager in a member variable to
320 // avoid accessing the RenderViewImpl. 293 // avoid accessing the RenderViewImpl.
321 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; 294 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
322 295
323 // Used for HW compositing. 296 // Used for HW compositing.
324 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; 297 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_;
325 298
326 // Used to identify the plugin to WebBindings. 299 // Used to identify the plugin to WebBindings.
327 scoped_ptr<struct _NPP> npp_; 300 scoped_ptr<struct _NPP> npp_;
328 301
329 // URL for the embedder frame. 302 // URL for the embedder frame.
330 const GURL embedder_frame_url_; 303 const GURL embedder_frame_url_;
331 304
332 std::vector<EditCommand> edit_commands_; 305 std::vector<EditCommand> edit_commands_;
333 306
334 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might 307 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might
335 // get called after BrowserPlugin has been destroyed. 308 // get called after BrowserPlugin has been destroyed.
336 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; 309 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_;
337 310
338 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); 311 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin);
339 }; 312 };
340 313
341 } // namespace content 314 } // namespace content
342 315
343 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ 316 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_
OLDNEW
« no previous file with comments | « content/public/browser/browser_plugin_guest_manager.cc ('k') | content/renderer/browser_plugin/browser_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698