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

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

Issue 11312179: C++ readability review for lazyboy@ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and reupload smaller subset for readability review. Created 7 years, 1 month 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 // A BrowserPluginGuest is the browser side of a browser <--> embedder 5 // A BrowserPluginGuest is the browser side of a browser <--> embedder
6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder 6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder
7 // renderer side of browser <--> embedder renderer communication. 7 // renderer side of browser <--> embedder renderer communication.
8 // 8 //
9 // BrowserPluginGuest lives on the UI thread of the browser process. Any 9 // BrowserPluginGuest lives on the UI thread of the browser process. Any
10 // messages about the guest render process that the embedder might be interested 10 // messages about the guest render process that the embedder might be interested
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 // The WebContents passed into the factory method here has not been 90 // The WebContents passed into the factory method here has not been
91 // initialized yet and so it does not yet hold a SiteInstance. 91 // initialized yet and so it does not yet hold a SiteInstance.
92 // BrowserPluginGuest must be constructed and installed into a WebContents 92 // BrowserPluginGuest must be constructed and installed into a WebContents
93 // prior to its initialization because WebContents needs to determine what 93 // prior to its initialization because WebContents needs to determine what
94 // type of WebContentsView to construct on initialization. The content 94 // type of WebContentsView to construct on initialization. The content
95 // embedder needs to be aware of |guest_site_instance| on the guest's 95 // embedder needs to be aware of |guest_site_instance| on the guest's
96 // construction and so we pass it in here. 96 // construction and so we pass it in here.
97 static BrowserPluginGuest* Create( 97 static BrowserPluginGuest* Create(
98 int instance_id, 98 int instance_id,
99 SiteInstance* guest_site_instance, 99 SiteInstance* guest_site_instance,
smo 2013/11/12 21:25:02 In general, when passing pointers add comments abo
lazyboy 2013/11/13 01:18:16 (Here and below), since this is a static method, t
100 WebContentsImpl* web_contents, 100 WebContentsImpl* web_contents,
101 scoped_ptr<base::DictionaryValue> extra_params); 101 scoped_ptr<base::DictionaryValue> extra_params);
smo 2013/11/12 21:25:02 Had to read up on this* since having scoped_ptr's
lazyboy 2013/11/13 01:18:16 Yes, no unique_ptr in chromium codebase.
102 102
103 static BrowserPluginGuest* CreateWithOpener( 103 static BrowserPluginGuest* CreateWithOpener(
smo 2013/11/12 21:25:02 Same comment re: pointer ownership as before.
lazyboy 2013/11/13 01:18:16 ditto.
104 int instance_id, 104 int instance_id,
105 WebContentsImpl* web_contents, 105 WebContentsImpl* web_contents,
smo 2013/11/12 21:25:02 If appropriate, have the pointer arguments come la
lazyboy 2013/11/13 01:18:16 I've moved non virtual method's pointer/output arg
Charlie Reis 2013/11/13 19:04:28 smo: Can you elaborate on this? The |web_contents
106 BrowserPluginGuest* opener, 106 BrowserPluginGuest* opener,
107 bool has_render_view); 107 bool has_render_view);
108 108
109 // Called when the embedder WebContents is destroyed to give the 109 // Called when the embedder WebContents is destroyed to give the
110 // BrowserPluginGuest an opportunity to clean up after itself. 110 // BrowserPluginGuest an opportunity to clean up after itself.
111 void EmbedderDestroyed(); 111 void EmbedderDestroyed();
112 112
113 // Called when the embedder WebContents changes visibility. 113 // Called when the embedder WebContents changes visibility.
114 void EmbedderVisibilityChanged(bool visible); 114 void EmbedderVisibilityChanged(bool visible);
115 115
116 // Destroys the guest WebContents and all its associated state, including 116 // Destroys the guest WebContents and all its associated state, including
117 // this BrowserPluginGuest, and its new unattached windows. 117 // this BrowserPluginGuest, and its new unattached windows.
118 void Destroy(); 118 void Destroy();
119 119
120 // Returns the identifier that uniquely identifies a browser plugin guest 120 // Returns the identifier that uniquely identifies a browser plugin guest
121 // within an embedder. 121 // within an embedder.
122 int instance_id() const { return instance_id_; } 122 int instance_id() const { return instance_id_; }
123 123
124 // Overrides factory for testing. Default (NULL) value indicates regular 124 // Overrides factory for testing. Default (NULL) value indicates regular
125 // (non-test) environment. 125 // (non-test) environment.
126 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { 126 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
smo 2013/11/12 21:25:02 I would place all the _testing methods in their ow
lazyboy 2013/11/13 01:18:16 Cool, Yes, TestBrowserPluginGuest was added for th
127 BrowserPluginGuest::factory_ = factory; 127 BrowserPluginGuest::factory_ = factory;
128 } 128 }
129 129
130 bool OnMessageReceivedFromEmbedder(const IPC::Message& message); 130 bool OnMessageReceivedFromEmbedder(const IPC::Message& message);
131 131
132 void Initialize(WebContentsImpl* embedder_web_contents, 132 void Initialize(WebContentsImpl* embedder_web_contents,
133 const BrowserPluginHostMsg_Attach_Params& params); 133 const BrowserPluginHostMsg_Attach_Params& params);
134 134
135 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) { 135 void set_guest_hang_timeout_for_testing(const base::TimeDelta& timeout) {
136 guest_hang_timeout_ = timeout; 136 guest_hang_timeout_ = timeout;
(...skipping 18 matching lines...) Expand all
155 void UpdateVisibility(); 155 void UpdateVisibility();
156 156
157 // WebContentsObserver implementation. 157 // WebContentsObserver implementation.
158 virtual void DidCommitProvisionalLoadForFrame( 158 virtual void DidCommitProvisionalLoadForFrame(
159 int64 frame_id, 159 int64 frame_id,
160 const string16& frame_unique_name, 160 const string16& frame_unique_name,
161 bool is_main_frame, 161 bool is_main_frame,
162 const GURL& url, 162 const GURL& url,
163 PageTransition transition_type, 163 PageTransition transition_type,
164 RenderViewHost* render_view_host) OVERRIDE; 164 RenderViewHost* render_view_host) OVERRIDE;
165 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; 165 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE;
smo 2013/11/12 21:25:02 Is the "override" keyword allowed now? Should that
lazyboy 2013/11/13 01:18:16 Chromium's style is to use OVERRIDE instead of ove
166 166
167 virtual void RenderViewReady() OVERRIDE; 167 virtual void RenderViewReady() OVERRIDE;
168 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; 168 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
169 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 169 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
170 170
171 // WebContentsDelegate implementation. 171 // WebContentsDelegate implementation.
172 virtual bool AddMessageToConsole(WebContents* source, 172 virtual bool AddMessageToConsole(WebContents* source,
173 int32 level, 173 int32 level,
174 const string16& message, 174 const string16& message,
175 int32 line_no, 175 int32 line_no,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; 244 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
245 245
246 // Helper to send messages to embedder. This methods fills the message with 246 // Helper to send messages to embedder. This methods fills the message with
247 // the correct routing id. 247 // the correct routing id.
248 // Overridden in test implementation since we want to intercept certain 248 // Overridden in test implementation since we want to intercept certain
249 // messages for testing. 249 // messages for testing.
250 virtual void SendMessageToEmbedder(IPC::Message* msg); 250 virtual void SendMessageToEmbedder(IPC::Message* msg);
251 251
252 // Returns whether the guest is attached to an embedder. 252 // Returns whether the guest is attached to an embedder.
253 bool attached() const { return !!embedder_web_contents_; } 253 bool attached() const { return !!embedder_web_contents_; }
smo 2013/11/12 21:25:02 (optional change) "!!" may not be commonly known
lazyboy 2013/11/13 01:18:16 Since I can't use nullptr, changed it to "return e
254 254
255 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| 255 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents|
256 // and initializes the guest with the provided |params|. Attaching a guest 256 // and initializes the guest with the provided |params|. Attaching a guest
257 // to an embedder implies that this guest's lifetime is no longer managed 257 // to an embedder implies that this guest's lifetime is no longer managed
258 // by its opener, and it can begin loading resources. |extra_params| are 258 // by its opener, and it can begin loading resources. |extra_params| are
259 // parameters passed into BrowserPlugin from JavaScript to be forwarded to 259 // parameters passed into BrowserPlugin from JavaScript to be forwarded to
260 // the content embedder. 260 // the content embedder.
261 void Attach(WebContentsImpl* embedder_web_contents, 261 void Attach(WebContentsImpl* embedder_web_contents,
262 BrowserPluginHostMsg_Attach_Params params, 262 BrowserPluginHostMsg_Attach_Params params,
263 const base::DictionaryValue& extra_params); 263 const base::DictionaryValue& extra_params);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 PageTransition transition_type); 325 PageTransition transition_type);
326 326
327 // Bridge IDs correspond to a geolocation request. This method will remove 327 // Bridge IDs correspond to a geolocation request. This method will remove
328 // the bookkeeping for a particular geolocation request associated with the 328 // the bookkeeping for a particular geolocation request associated with the
329 // provided |bridge_id|. It returns the request ID of the geolocation request. 329 // provided |bridge_id|. It returns the request ID of the geolocation request.
330 int RemoveBridgeID(int bridge_id); 330 int RemoveBridgeID(int bridge_id);
331 331
332 // Returns the |request_id| generated for the |request| provided. 332 // Returns the |request_id| generated for the |request| provided.
333 int RequestPermission( 333 int RequestPermission(
334 BrowserPluginPermissionType permission_type, 334 BrowserPluginPermissionType permission_type,
335 scoped_refptr<BrowserPluginGuest::PermissionRequest> request, 335 scoped_refptr<BrowserPluginGuest::PermissionRequest> request,
smo 2013/11/12 21:25:02 Not familiar with scoped_refptr (is this like link
lazyboy 2013/11/13 01:18:16 There's no unique_ptr usage in chromium codebase,
336 const base::DictionaryValue& request_info); 336 const base::DictionaryValue& request_info);
337 337
338 // Creates a new guest window, and BrowserPluginGuest that is owned by this 338 // Creates a new guest window, and BrowserPluginGuest that is owned by this
339 // BrowserPluginGuest. 339 // BrowserPluginGuest.
340 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params); 340 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params);
341 341
342 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } 342 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); }
343 const gfx::Size& damage_view_size() const { return damage_view_size_; } 343 const gfx::Size& damage_view_size() const { return damage_view_size_; }
344 float damage_buffer_scale_factor() const { 344 float damage_buffer_scale_factor() const {
345 return damage_buffer_scale_factor_; 345 return damage_buffer_scale_factor_;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 bool embedder_visible_; 502 bool embedder_visible_;
503 std::string name_; 503 std::string name_;
504 bool auto_size_enabled_; 504 bool auto_size_enabled_;
505 gfx::Size max_auto_size_; 505 gfx::Size max_auto_size_;
506 gfx::Size min_auto_size_; 506 gfx::Size min_auto_size_;
507 507
508 // Tracks the name, and target URL of the new window and whether or not it has 508 // Tracks the name, and target URL of the new window and whether or not it has
509 // changed since the WebContents has been created and before the new window 509 // changed since the WebContents has been created and before the new window
510 // has been attached to a BrowserPlugin. Once the first navigation commits, we 510 // has been attached to a BrowserPlugin. Once the first navigation commits, we
511 // no longer track this information. 511 // no longer track this information.
512 struct NewWindowInfo { 512 struct NewWindowInfo {
smo 2013/11/12 21:25:02 Follow standard declaration order unless there's a
lazyboy 2013/11/13 01:18:16 Done for the struct. typedef is supposed to be clo
513 bool changed; 513 bool changed;
514 GURL url; 514 GURL url;
515 std::string name; 515 std::string name;
516 NewWindowInfo(const GURL& url, const std::string& name) : 516 NewWindowInfo(const GURL& url, const std::string& name) :
517 changed(false), 517 changed(false),
518 url(url), 518 url(url),
519 name(name) {} 519 name(name) {}
520 }; 520 };
521 typedef std::map<BrowserPluginGuest*, NewWindowInfo> PendingWindowMap; 521 typedef std::map<BrowserPluginGuest*, NewWindowInfo> PendingWindowMap;
522 PendingWindowMap pending_new_windows_; 522 PendingWindowMap pending_new_windows_;
523 base::WeakPtr<BrowserPluginGuest> opener_; 523 base::WeakPtr<BrowserPluginGuest> opener_;
524 // A counter to generate a unique request id for a permission request. 524 // A counter to generate a unique request id for a permission request.
525 // We only need the ids to be unique for a given BrowserPluginGuest. 525 // We only need the ids to be unique for a given BrowserPluginGuest.
526 int next_permission_request_id_; 526 int next_permission_request_id_;
527 527
528 // A map to store relevant info for a request keyed by the request's id. 528 // A map to store relevant info for a request keyed by the request's id.
529 typedef std::map<int, scoped_refptr<PermissionRequest> > RequestMap; 529 typedef std::map<int, scoped_refptr<PermissionRequest> > RequestMap;
smo 2013/11/12 21:25:02 Not sure how this code is compiled, but ">>" is un
lazyboy 2013/11/13 01:18:16 It compiles on my compilers (ubuntu and win), but
530 RequestMap permission_request_map_; 530 RequestMap permission_request_map_;
531 531
532 // Indicates that this BrowserPluginGuest has associated renderer-side state. 532 // Indicates that this BrowserPluginGuest has associated renderer-side state.
533 // This is used to determine whether or not to create a new RenderView when 533 // This is used to determine whether or not to create a new RenderView when
534 // this guest is attached. 534 // this guest is attached.
535 bool has_render_view_; 535 bool has_render_view_;
536 536
537 // Last seen size of guest contents (by OnUpdateRect). 537 // Last seen size of guest contents (by OnUpdateRect).
538 gfx::Size last_seen_view_size_; 538 gfx::Size last_seen_view_size_;
539 // Last seen autosize attribute state (by OnUpdateRect). 539 // Last seen autosize attribute state (by OnUpdateRect).
540 bool last_seen_auto_size_enabled_; 540 bool last_seen_auto_size_enabled_;
541 541
542 bool is_in_destruction_; 542 bool is_in_destruction_;
543 543
544 // This is a queue of messages that are destined to be sent to the embedder 544 // This is a queue of messages that are destined to be sent to the embedder
545 // once the guest is attached to a particular embedder. 545 // once the guest is attached to a particular embedder.
546 std::queue<IPC::Message*> pending_messages_; 546 std::queue<IPC::Message*> pending_messages_;
547 547
548 scoped_ptr<BrowserPluginGuestDelegate> delegate_; 548 scoped_ptr<BrowserPluginGuestDelegate> delegate_;
549 549
550 // These are parameters passed from JavaScript on attachment to the content 550 // These are parameters passed from JavaScript on attachment to the content
551 // embedder. 551 // embedder.
552 scoped_ptr<base::DictionaryValue> extra_attach_params_; 552 scoped_ptr<base::DictionaryValue> extra_attach_params_;
553 553
554 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 554 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
555 }; 555 };
556 556
557 } // namespace content 557 } // namespace content
558 558
559
559 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 560 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698