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

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

Issue 95693002: <webview>: Expose transparency API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment Created 7 years 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 #include "content/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 paint_ack_received_(true), 79 paint_ack_received_(true),
80 last_device_scale_factor_(1.0f), 80 last_device_scale_factor_(1.0f),
81 sad_guest_(NULL), 81 sad_guest_(NULL),
82 guest_crashed_(false), 82 guest_crashed_(false),
83 is_auto_size_state_dirty_(false), 83 is_auto_size_state_dirty_(false),
84 persist_storage_(false), 84 persist_storage_(false),
85 valid_partition_id_(true), 85 valid_partition_id_(true),
86 content_window_routing_id_(MSG_ROUTING_NONE), 86 content_window_routing_id_(MSG_ROUTING_NONE),
87 plugin_focused_(false), 87 plugin_focused_(false),
88 visible_(true), 88 visible_(true),
89 opaque_(true),
90 before_first_navigation_(true), 89 before_first_navigation_(true),
91 mouse_locked_(false), 90 mouse_locked_(false),
92 browser_plugin_manager_(render_view->GetBrowserPluginManager()), 91 browser_plugin_manager_(render_view->GetBrowserPluginManager()),
93 compositing_enabled_(false), 92 compositing_enabled_(false),
94 embedder_frame_url_(frame->document().url()), 93 embedder_frame_url_(frame->document().url()),
95 weak_ptr_factory_(this) { 94 weak_ptr_factory_(this) {
96 } 95 }
97 96
98 BrowserPlugin::~BrowserPlugin() { 97 BrowserPlugin::~BrowserPlugin() {
99 // If the BrowserPlugin has never navigated then the browser process and 98 // If the BrowserPlugin has never navigated then the browser process and
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return false; 174 return false;
176 175
177 return container()->element().hasAttribute( 176 return container()->element().hasAttribute(
178 blink::WebString::fromUTF8(attribute_name)); 177 blink::WebString::fromUTF8(attribute_name));
179 } 178 }
180 179
181 std::string BrowserPlugin::GetNameAttribute() const { 180 std::string BrowserPlugin::GetNameAttribute() const {
182 return GetDOMAttributeValue(browser_plugin::kAttributeName); 181 return GetDOMAttributeValue(browser_plugin::kAttributeName);
183 } 182 }
184 183
184 bool BrowserPlugin::GetAllowTransparencyAttribute() const {
185 return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency);
186 }
187
185 std::string BrowserPlugin::GetSrcAttribute() const { 188 std::string BrowserPlugin::GetSrcAttribute() const {
186 return GetDOMAttributeValue(browser_plugin::kAttributeSrc); 189 return GetDOMAttributeValue(browser_plugin::kAttributeSrc);
187 } 190 }
188 191
189 bool BrowserPlugin::GetAutoSizeAttribute() const { 192 bool BrowserPlugin::GetAutoSizeAttribute() const {
190 return HasDOMAttribute(browser_plugin::kAttributeAutoSize); 193 return HasDOMAttribute(browser_plugin::kAttributeAutoSize);
191 } 194 }
192 195
193 int BrowserPlugin::GetMaxHeightAttribute() const { 196 int BrowserPlugin::GetMaxHeightAttribute() const {
194 int max_height; 197 int max_height;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 255
253 void BrowserPlugin::ParseNameAttribute() { 256 void BrowserPlugin::ParseNameAttribute() {
254 if (!HasGuestInstanceID()) 257 if (!HasGuestInstanceID())
255 return; 258 return;
256 browser_plugin_manager()->Send( 259 browser_plugin_manager()->Send(
257 new BrowserPluginHostMsg_SetName(render_view_routing_id_, 260 new BrowserPluginHostMsg_SetName(render_view_routing_id_,
258 guest_instance_id_, 261 guest_instance_id_,
259 GetNameAttribute())); 262 GetNameAttribute()));
260 } 263 }
261 264
265 void BrowserPlugin::ParseAllowTransparencyAttribute() {
266 if (!HasGuestInstanceID())
267 return;
268
269 bool opaque = !GetAllowTransparencyAttribute();
270
271 if (compositing_helper_)
272 compositing_helper_->SetContentsOpaque(opaque);
273
274 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque(
275 render_view_routing_id_,
276 guest_instance_id_,
277 opaque));
278 }
279
262 bool BrowserPlugin::ParseSrcAttribute(std::string* error_message) { 280 bool BrowserPlugin::ParseSrcAttribute(std::string* error_message) {
263 if (!valid_partition_id_) { 281 if (!valid_partition_id_) {
264 *error_message = browser_plugin::kErrorInvalidPartition; 282 *error_message = browser_plugin::kErrorInvalidPartition;
265 return false; 283 return false;
266 } 284 }
267 std::string src = GetSrcAttribute(); 285 std::string src = GetSrcAttribute();
268 if (src.empty()) 286 if (src.empty())
269 return true; 287 return true;
270 288
271 // If we haven't created the guest yet, do so now. We will navigate it right 289 // If we haven't created the guest yet, do so now. We will navigate it right
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 std::map<std::string, base::Value*> props; 383 std::map<std::string, base::Value*> props;
366 props[browser_plugin::kWindowID] = 384 props[browser_plugin::kWindowID] =
367 new base::FundamentalValue(guest_instance_id); 385 new base::FundamentalValue(guest_instance_id);
368 TriggerEvent(browser_plugin::kEventInternalInstanceIDAllocated, &props); 386 TriggerEvent(browser_plugin::kEventInternalInstanceIDAllocated, &props);
369 } 387 }
370 388
371 void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) { 389 void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) {
372 BrowserPluginHostMsg_Attach_Params attach_params; 390 BrowserPluginHostMsg_Attach_Params attach_params;
373 attach_params.focused = ShouldGuestBeFocused(); 391 attach_params.focused = ShouldGuestBeFocused();
374 attach_params.visible = visible_; 392 attach_params.visible = visible_;
375 attach_params.opaque = opaque_; 393 attach_params.opaque = !GetAllowTransparencyAttribute();
376 attach_params.name = GetNameAttribute(); 394 attach_params.name = GetNameAttribute();
377 attach_params.storage_partition_id = storage_partition_id_; 395 attach_params.storage_partition_id = storage_partition_id_;
378 attach_params.persist_storage = persist_storage_; 396 attach_params.persist_storage = persist_storage_;
379 attach_params.src = GetSrcAttribute(); 397 attach_params.src = GetSrcAttribute();
380 attach_params.embedder_frame_url = embedder_frame_url_; 398 attach_params.embedder_frame_url = embedder_frame_url_;
381 GetDamageBufferWithSizeParams(&attach_params.auto_size_params, 399 GetDamageBufferWithSizeParams(&attach_params.auto_size_params,
382 &attach_params.resize_guest_params, 400 &attach_params.resize_guest_params,
383 false); 401 false);
384 402
385 browser_plugin_manager()->Send( 403 browser_plugin_manager()->Send(
386 new BrowserPluginHostMsg_Attach(render_view_routing_id_, 404 new BrowserPluginHostMsg_Attach(render_view_routing_id_,
387 guest_instance_id_, attach_params, 405 guest_instance_id_, attach_params,
388 *extra_params)); 406 *extra_params));
389 } 407 }
390 408
391 void BrowserPlugin::DidCommitCompositorFrame() { 409 void BrowserPlugin::DidCommitCompositorFrame() {
392 if (compositing_helper_.get()) 410 if (compositing_helper_.get())
393 compositing_helper_->DidCommitCompositorFrame(); 411 compositing_helper_->DidCommitCompositorFrame();
394 } 412 }
395 413
396 void BrowserPlugin::SetContentsOpaque(bool opaque) {
397 if (opaque_ == opaque)
398 return;
399
400 opaque_ = opaque;
401 if (!HasGuestInstanceID())
402 return;
403
404 if (compositing_helper_)
405 compositing_helper_->SetContentsOpaque(opaque_);
406
407 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque(
408 render_view_routing_id_,
409 guest_instance_id_,
410 opaque_));
411 }
412
413 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { 414 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) {
414 DCHECK(render_view_.get()); 415 DCHECK(render_view_.get());
415 render_view_->GetWebView()->advanceFocus(reverse); 416 render_view_->GetWebView()->advanceFocus(reverse);
416 } 417 }
417 418
418 void BrowserPlugin::OnAttachACK( 419 void BrowserPlugin::OnAttachACK(
419 int guest_instance_id, 420 int guest_instance_id,
420 const BrowserPluginMsg_Attach_ACK_Params& params) { 421 const BrowserPluginMsg_Attach_ACK_Params& params) {
421 // Update BrowserPlugin attributes to match the state of the guest. 422 // Update BrowserPlugin attributes to match the state of the guest.
422 if (!params.name.empty()) 423 if (!params.name.empty())
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 plugin_rect(), 916 plugin_rect(),
916 true /* needs_repaint */); 917 true /* needs_repaint */);
917 paint_ack_received_ = false; 918 paint_ack_received_ = false;
918 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 919 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest(
919 render_view_routing_id_, 920 render_view_routing_id_,
920 guest_instance_id_, 921 guest_instance_id_,
921 params)); 922 params));
922 } 923 }
923 } 924 }
924 compositing_helper_->EnableCompositing(enable); 925 compositing_helper_->EnableCompositing(enable);
925 compositing_helper_->SetContentsOpaque(opaque_); 926 compositing_helper_->SetContentsOpaque(!GetAllowTransparencyAttribute());
926 } 927 }
927 928
928 void BrowserPlugin::destroy() { 929 void BrowserPlugin::destroy() {
929 // If the plugin was initialized then it has a valid |npp_| identifier, and 930 // If the plugin was initialized then it has a valid |npp_| identifier, and
930 // the |container_| must clear references to the plugin's script objects. 931 // the |container_| must clear references to the plugin's script objects.
931 DCHECK(!npp_ || container_); 932 DCHECK(!npp_ || container_);
932 if (container_) 933 if (container_)
933 container_->clearScriptObjects(); 934 container_->clearScriptObjects();
934 935
935 // The BrowserPlugin's WebPluginContainer is deleted immediately after this 936 // The BrowserPlugin's WebPluginContainer is deleted immediately after this
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 const blink::WebMouseEvent& event) { 1338 const blink::WebMouseEvent& event) {
1338 browser_plugin_manager()->Send( 1339 browser_plugin_manager()->Send(
1339 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1340 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1340 guest_instance_id_, 1341 guest_instance_id_,
1341 plugin_rect_, 1342 plugin_rect_,
1342 &event)); 1343 &event));
1343 return true; 1344 return true;
1344 } 1345 }
1345 1346
1346 } // namespace content 1347 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698