| OLD | NEW |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 using blink::WebPluginParams; | 47 using blink::WebPluginParams; |
| 48 using blink::WebPoint; | 48 using blink::WebPoint; |
| 49 using blink::WebRect; | 49 using blink::WebRect; |
| 50 using blink::WebURL; | 50 using blink::WebURL; |
| 51 using blink::WebVector; | 51 using blink::WebVector; |
| 52 | 52 |
| 53 namespace content { | 53 namespace content { |
| 54 | 54 |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 const char* kCustomPersistPartition = "persist:custom_plugin"; | |
| 58 | |
| 59 static std::string GetInternalEventName(const char* event_name) { | 57 static std::string GetInternalEventName(const char* event_name) { |
| 60 return base::StringPrintf("-internal-%s", event_name); | 58 return base::StringPrintf("-internal-%s", event_name); |
| 61 } | 59 } |
| 62 | 60 |
| 63 } // namespace | 61 } // namespace |
| 64 | 62 |
| 65 BrowserPlugin::BrowserPlugin(RenderViewImpl* render_view, | 63 BrowserPlugin::BrowserPlugin(RenderViewImpl* render_view, |
| 66 blink::WebFrame* frame, | 64 blink::WebFrame* frame, |
| 67 bool auto_navigate) | 65 bool auto_navigate) |
| 68 : guest_instance_id_(browser_plugin::kInstanceIDNone), | 66 : guest_instance_id_(browser_plugin::kInstanceIDNone), |
| 69 attached_(false), | 67 attached_(false), |
| 70 render_view_(render_view->AsWeakPtr()), | 68 render_view_(render_view->AsWeakPtr()), |
| 71 render_view_routing_id_(render_view->GetRoutingID()), | 69 render_view_routing_id_(render_view->GetRoutingID()), |
| 72 container_(NULL), | 70 container_(NULL), |
| 73 paint_ack_received_(true), | 71 paint_ack_received_(true), |
| 74 last_device_scale_factor_(1.0f), | 72 last_device_scale_factor_(1.0f), |
| 75 sad_guest_(NULL), | 73 sad_guest_(NULL), |
| 76 guest_crashed_(false), | 74 guest_crashed_(false), |
| 77 is_auto_size_state_dirty_(false), | 75 is_auto_size_state_dirty_(false), |
| 78 persist_storage_(false), | |
| 79 valid_partition_id_(true), | |
| 80 content_window_routing_id_(MSG_ROUTING_NONE), | 76 content_window_routing_id_(MSG_ROUTING_NONE), |
| 81 plugin_focused_(false), | 77 plugin_focused_(false), |
| 82 visible_(true), | 78 visible_(true), |
| 83 auto_navigate_(auto_navigate), | 79 auto_navigate_(auto_navigate), |
| 84 before_first_navigation_(true), | |
| 85 mouse_locked_(false), | 80 mouse_locked_(false), |
| 86 browser_plugin_manager_(render_view->GetBrowserPluginManager()), | 81 browser_plugin_manager_(render_view->GetBrowserPluginManager()), |
| 87 embedder_frame_url_(frame->document().url()), | 82 embedder_frame_url_(frame->document().url()), |
| 88 weak_ptr_factory_(this) { | 83 weak_ptr_factory_(this) { |
| 89 } | 84 } |
| 90 | 85 |
| 91 BrowserPlugin::~BrowserPlugin() { | 86 BrowserPlugin::~BrowserPlugin() { |
| 92 // If the BrowserPlugin has never navigated then the browser process and | 87 // If the BrowserPlugin has never navigated then the browser process and |
| 93 // BrowserPluginManager don't know about it and so there is nothing to do | 88 // BrowserPluginManager don't know about it and so there is nothing to do |
| 94 // here. | 89 // here. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 return false; | 156 return false; |
| 162 | 157 |
| 163 return container()->element().hasAttribute( | 158 return container()->element().hasAttribute( |
| 164 blink::WebString::fromUTF8(attribute_name)); | 159 blink::WebString::fromUTF8(attribute_name)); |
| 165 } | 160 } |
| 166 | 161 |
| 167 bool BrowserPlugin::GetAllowTransparencyAttribute() const { | 162 bool BrowserPlugin::GetAllowTransparencyAttribute() const { |
| 168 return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency); | 163 return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency); |
| 169 } | 164 } |
| 170 | 165 |
| 171 std::string BrowserPlugin::GetSrcAttribute() const { | |
| 172 return GetDOMAttributeValue(browser_plugin::kAttributeSrc); | |
| 173 } | |
| 174 | |
| 175 bool BrowserPlugin::GetAutoSizeAttribute() const { | 166 bool BrowserPlugin::GetAutoSizeAttribute() const { |
| 176 return HasDOMAttribute(browser_plugin::kAttributeAutoSize); | 167 return HasDOMAttribute(browser_plugin::kAttributeAutoSize); |
| 177 } | 168 } |
| 178 | 169 |
| 179 int BrowserPlugin::GetMaxHeightAttribute() const { | 170 int BrowserPlugin::GetMaxHeightAttribute() const { |
| 180 int max_height; | 171 int max_height; |
| 181 base::StringToInt(GetDOMAttributeValue(browser_plugin::kAttributeMaxHeight), | 172 base::StringToInt(GetDOMAttributeValue(browser_plugin::kAttributeMaxHeight), |
| 182 &max_height); | 173 &max_height); |
| 183 return max_height; | 174 return max_height; |
| 184 } | 175 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 216 |
| 226 int BrowserPlugin::GetAdjustedMinWidth() const { | 217 int BrowserPlugin::GetAdjustedMinWidth() const { |
| 227 int min_width = GetMinWidthAttribute(); | 218 int min_width = GetMinWidthAttribute(); |
| 228 // FrameView.cpp does not allow this value to be <= 0, so when the value is | 219 // FrameView.cpp does not allow this value to be <= 0, so when the value is |
| 229 // unset (or set to 0), we set it to the container size. | 220 // unset (or set to 0), we set it to the container size. |
| 230 min_width = min_width ? min_width : width(); | 221 min_width = min_width ? min_width : width(); |
| 231 // For autosize, minWidth should not be bigger than maxWidth. | 222 // For autosize, minWidth should not be bigger than maxWidth. |
| 232 return std::min(min_width, GetAdjustedMaxWidth()); | 223 return std::min(min_width, GetAdjustedMaxWidth()); |
| 233 } | 224 } |
| 234 | 225 |
| 235 std::string BrowserPlugin::GetPartitionAttribute() const { | |
| 236 return GetDOMAttributeValue(browser_plugin::kAttributePartition); | |
| 237 } | |
| 238 | |
| 239 void BrowserPlugin::ParseAllowTransparencyAttribute() { | 226 void BrowserPlugin::ParseAllowTransparencyAttribute() { |
| 240 if (!HasGuestInstanceID()) | 227 if (!HasGuestInstanceID()) |
| 241 return; | 228 return; |
| 242 | 229 |
| 243 bool opaque = !GetAllowTransparencyAttribute(); | 230 bool opaque = !GetAllowTransparencyAttribute(); |
| 244 | 231 |
| 245 if (compositing_helper_) | 232 if (compositing_helper_) |
| 246 compositing_helper_->SetContentsOpaque(opaque); | 233 compositing_helper_->SetContentsOpaque(opaque); |
| 247 | 234 |
| 248 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque( | 235 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque( |
| 249 render_view_routing_id_, | 236 render_view_routing_id_, |
| 250 guest_instance_id_, | 237 guest_instance_id_, |
| 251 opaque)); | 238 opaque)); |
| 252 } | 239 } |
| 253 | 240 |
| 254 bool BrowserPlugin::ParseSrcAttribute(std::string* error_message) { | |
| 255 if (!valid_partition_id_) { | |
| 256 *error_message = browser_plugin::kErrorInvalidPartition; | |
| 257 return false; | |
| 258 } | |
| 259 std::string src = GetSrcAttribute(); | |
| 260 if (src.empty()) | |
| 261 return true; | |
| 262 | |
| 263 // If we haven't created the guest yet, do so now. We will navigate it right | |
| 264 // after creation. If |src| is empty, we can delay the creation until we | |
| 265 // actually need it. | |
| 266 if (!HasGuestInstanceID()) { | |
| 267 // On initial navigation, we request an instance ID from the browser | |
| 268 // process. We essentially ignore all subsequent calls to SetSrcAttribute | |
| 269 // until we receive an instance ID. |before_first_navigation_| | |
| 270 // prevents BrowserPlugin from allocating more than one instance ID. | |
| 271 // Upon receiving an instance ID from the browser process, we continue | |
| 272 // the process of navigation by populating the | |
| 273 // BrowserPluginHostMsg_Attach_Params with the current state of | |
| 274 // BrowserPlugin and sending a BrowserPluginHostMsg_CreateGuest to the | |
| 275 // browser process in order to create a new guest. | |
| 276 if (before_first_navigation_) { | |
| 277 browser_plugin_manager()->AllocateInstanceID( | |
| 278 weak_ptr_factory_.GetWeakPtr()); | |
| 279 before_first_navigation_ = false; | |
| 280 } | |
| 281 return true; | |
| 282 } | |
| 283 | |
| 284 browser_plugin_manager()->Send( | |
| 285 new BrowserPluginHostMsg_NavigateGuest(render_view_routing_id_, | |
| 286 guest_instance_id_, | |
| 287 src)); | |
| 288 return true; | |
| 289 } | |
| 290 | |
| 291 void BrowserPlugin::ParseAutoSizeAttribute() { | 241 void BrowserPlugin::ParseAutoSizeAttribute() { |
| 292 last_view_size_ = plugin_rect_.size(); | 242 last_view_size_ = plugin_rect_.size(); |
| 293 is_auto_size_state_dirty_ = true; | 243 is_auto_size_state_dirty_ = true; |
| 294 UpdateGuestAutoSizeState(GetAutoSizeAttribute()); | 244 UpdateGuestAutoSizeState(GetAutoSizeAttribute()); |
| 295 } | 245 } |
| 296 | 246 |
| 297 void BrowserPlugin::PopulateAutoSizeParameters( | 247 void BrowserPlugin::PopulateAutoSizeParameters( |
| 298 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled) { | 248 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled) { |
| 299 params->enable = auto_size_enabled; | 249 params->enable = auto_size_enabled; |
| 300 // No need to populate the params if autosize is off. | 250 // No need to populate the params if autosize is off. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 326 GetSizeParams(NULL, &resize_guest_params, true); | 276 GetSizeParams(NULL, &resize_guest_params, true); |
| 327 } | 277 } |
| 328 paint_ack_received_ = false; | 278 paint_ack_received_ = false; |
| 329 browser_plugin_manager()->Send( | 279 browser_plugin_manager()->Send( |
| 330 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, | 280 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, |
| 331 guest_instance_id_, | 281 guest_instance_id_, |
| 332 auto_size_params, | 282 auto_size_params, |
| 333 resize_guest_params)); | 283 resize_guest_params)); |
| 334 } | 284 } |
| 335 | 285 |
| 336 void BrowserPlugin::OnInstanceIDAllocated(int guest_instance_id) { | |
| 337 CHECK(guest_instance_id != browser_plugin::kInstanceIDNone); | |
| 338 | |
| 339 if (auto_navigate_) { | |
| 340 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | |
| 341 Attach(guest_instance_id, params.Pass()); | |
| 342 return; | |
| 343 } | |
| 344 | |
| 345 std::map<std::string, base::Value*> props; | |
| 346 props[browser_plugin::kWindowID] = | |
| 347 new base::FundamentalValue(guest_instance_id); | |
| 348 TriggerEvent(browser_plugin::kEventInternalInstanceIDAllocated, &props); | |
| 349 } | |
| 350 | |
| 351 void BrowserPlugin::Attach(int guest_instance_id, | 286 void BrowserPlugin::Attach(int guest_instance_id, |
| 352 scoped_ptr<base::DictionaryValue> extra_params) { | 287 scoped_ptr<base::DictionaryValue> extra_params) { |
| 353 CHECK(guest_instance_id != browser_plugin::kInstanceIDNone); | 288 CHECK(guest_instance_id != browser_plugin::kInstanceIDNone); |
| 354 | 289 |
| 355 // If this BrowserPlugin is already attached to a guest, then do nothing. | 290 // If this BrowserPlugin is already attached to a guest, then do nothing. |
| 356 if (HasGuestInstanceID()) | 291 if (HasGuestInstanceID()) |
| 357 return; | 292 return; |
| 358 | 293 |
| 359 // This API may be called directly without setting the src attribute. | 294 // This API may be called directly without setting the src attribute. |
| 360 // In that case, we need to make sure we don't allocate another instance ID. | 295 // In that case, we need to make sure we don't allocate another instance ID. |
| 361 before_first_navigation_ = false; | |
| 362 guest_instance_id_ = guest_instance_id; | 296 guest_instance_id_ = guest_instance_id; |
| 363 browser_plugin_manager()->AddBrowserPlugin(guest_instance_id, this); | 297 browser_plugin_manager()->AddBrowserPlugin(guest_instance_id, this); |
| 364 | 298 |
| 365 BrowserPluginHostMsg_Attach_Params attach_params; | 299 BrowserPluginHostMsg_Attach_Params attach_params; |
| 366 attach_params.focused = ShouldGuestBeFocused(); | 300 attach_params.focused = ShouldGuestBeFocused(); |
| 367 attach_params.visible = visible_; | 301 attach_params.visible = visible_; |
| 368 attach_params.opaque = !GetAllowTransparencyAttribute(); | 302 attach_params.opaque = !GetAllowTransparencyAttribute(); |
| 369 attach_params.storage_partition_id = storage_partition_id_; | |
| 370 attach_params.persist_storage = persist_storage_; | |
| 371 attach_params.src = GetSrcAttribute(); | |
| 372 attach_params.embedder_frame_url = embedder_frame_url_; | 303 attach_params.embedder_frame_url = embedder_frame_url_; |
| 373 GetSizeParams(&attach_params.auto_size_params, | 304 GetSizeParams(&attach_params.auto_size_params, |
| 374 &attach_params.resize_guest_params, | 305 &attach_params.resize_guest_params, |
| 375 false); | 306 false); |
| 376 | 307 |
| 377 browser_plugin_manager()->Send( | 308 browser_plugin_manager()->Send( |
| 378 new BrowserPluginHostMsg_Attach(render_view_routing_id_, | 309 new BrowserPluginHostMsg_Attach(render_view_routing_id_, |
| 379 guest_instance_id_, attach_params, | 310 guest_instance_id_, attach_params, |
| 380 *extra_params)); | 311 *extra_params)); |
| 381 } | 312 } |
| 382 | 313 |
| 383 void BrowserPlugin::DidCommitCompositorFrame() { | 314 void BrowserPlugin::DidCommitCompositorFrame() { |
| 384 if (compositing_helper_.get()) | 315 if (compositing_helper_.get()) |
| 385 compositing_helper_->DidCommitCompositorFrame(); | 316 compositing_helper_->DidCommitCompositorFrame(); |
| 386 } | 317 } |
| 387 | 318 |
| 388 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { | 319 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { |
| 389 DCHECK(render_view_.get()); | 320 DCHECK(render_view_.get()); |
| 390 render_view_->GetWebView()->advanceFocus(reverse); | 321 render_view_->GetWebView()->advanceFocus(reverse); |
| 391 } | 322 } |
| 392 | 323 |
| 393 void BrowserPlugin::OnAttachACK( | 324 void BrowserPlugin::OnAttachACK( |
| 394 int guest_instance_id, | 325 int guest_instance_id, |
| 395 const BrowserPluginMsg_Attach_ACK_Params& params) { | 326 const BrowserPluginMsg_Attach_ACK_Params& params) { |
| 396 if (!params.storage_partition_id.empty()) { | |
| 397 std::string partition_name = | |
| 398 (params.persist_storage ? browser_plugin::kPersistPrefix : "") + | |
| 399 params.storage_partition_id; | |
| 400 UpdateDOMAttribute(browser_plugin::kAttributePartition, partition_name); | |
| 401 } | |
| 402 attached_ = true; | 327 attached_ = true; |
| 403 } | 328 } |
| 404 | 329 |
| 405 void BrowserPlugin::OnBuffersSwapped( | 330 void BrowserPlugin::OnBuffersSwapped( |
| 406 int instance_id, | 331 int instance_id, |
| 407 const FrameMsg_BuffersSwapped_Params& params) { | 332 const FrameMsg_BuffersSwapped_Params& params) { |
| 408 EnableCompositing(true); | 333 EnableCompositing(true); |
| 409 | 334 |
| 410 compositing_helper_->OnBuffersSwapped(params.size, | 335 compositing_helper_->OnBuffersSwapped(params.size, |
| 411 params.mailbox, | 336 params.mailbox, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (content_window_routing_id_ == MSG_ROUTING_NONE) | 483 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
| 559 return NULL; | 484 return NULL; |
| 560 RenderViewImpl* guest_render_view = RenderViewImpl::FromRoutingID( | 485 RenderViewImpl* guest_render_view = RenderViewImpl::FromRoutingID( |
| 561 content_window_routing_id_); | 486 content_window_routing_id_); |
| 562 if (!guest_render_view) | 487 if (!guest_render_view) |
| 563 return NULL; | 488 return NULL; |
| 564 blink::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); | 489 blink::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); |
| 565 return guest_frame->windowObject(); | 490 return guest_frame->windowObject(); |
| 566 } | 491 } |
| 567 | 492 |
| 568 bool BrowserPlugin::HasNavigated() const { | |
| 569 return !before_first_navigation_; | |
| 570 } | |
| 571 | |
| 572 bool BrowserPlugin::HasGuestInstanceID() const { | 493 bool BrowserPlugin::HasGuestInstanceID() const { |
| 573 return guest_instance_id_ != browser_plugin::kInstanceIDNone; | 494 return guest_instance_id_ != browser_plugin::kInstanceIDNone; |
| 574 } | 495 } |
| 575 | 496 |
| 576 bool BrowserPlugin::ParsePartitionAttribute(std::string* error_message) { | |
| 577 if (HasNavigated()) { | |
| 578 *error_message = browser_plugin::kErrorAlreadyNavigated; | |
| 579 return false; | |
| 580 } | |
| 581 | 497 |
| 582 std::string input; | 498 // TODO(lazyboy): Need equivalent in web_view.js |
| 583 if (auto_navigate_) | 499 // Also write test. |
| 584 input = kCustomPersistPartition; | |
| 585 else | |
| 586 input = GetPartitionAttribute(); | |
| 587 | |
| 588 // Since the "persist:" prefix is in ASCII, StartsWith will work fine on | |
| 589 // UTF-8 encoded |partition_id|. If the prefix is a match, we can safely | |
| 590 // remove the prefix without splicing in the middle of a multi-byte codepoint. | |
| 591 // We can use the rest of the string as UTF-8 encoded one. | |
| 592 if (StartsWithASCII(input, browser_plugin::kPersistPrefix, true)) { | |
| 593 size_t index = input.find(":"); | |
| 594 CHECK(index != std::string::npos); | |
| 595 // It is safe to do index + 1, since we tested for the full prefix above. | |
| 596 input = input.substr(index + 1); | |
| 597 if (input.empty()) { | |
| 598 valid_partition_id_ = false; | |
| 599 *error_message = browser_plugin::kErrorInvalidPartition; | |
| 600 return false; | |
| 601 } | |
| 602 persist_storage_ = true; | |
| 603 } else { | |
| 604 persist_storage_ = false; | |
| 605 } | |
| 606 | |
| 607 valid_partition_id_ = true; | |
| 608 storage_partition_id_ = input; | |
| 609 return true; | |
| 610 } | |
| 611 | |
| 612 bool BrowserPlugin::CanRemovePartitionAttribute(std::string* error_message) { | 500 bool BrowserPlugin::CanRemovePartitionAttribute(std::string* error_message) { |
| 613 if (HasGuestInstanceID()) | 501 if (HasGuestInstanceID()) |
| 614 *error_message = browser_plugin::kErrorCannotRemovePartition; | 502 *error_message = browser_plugin::kErrorCannotRemovePartition; |
| 615 return !HasGuestInstanceID(); | 503 return !HasGuestInstanceID(); |
| 616 } | 504 } |
| 617 | 505 |
| 618 void BrowserPlugin::ShowSadGraphic() { | 506 void BrowserPlugin::ShowSadGraphic() { |
| 619 // If the BrowserPlugin is scheduled to be deleted, then container_ will be | 507 // If the BrowserPlugin is scheduled to be deleted, then container_ will be |
| 620 // NULL so we shouldn't attempt to access it. | 508 // NULL so we shouldn't attempt to access it. |
| 621 if (container_) | 509 if (container_) |
| 622 container_->invalidate(); | 510 container_->invalidate(); |
| 623 } | 511 } |
| 624 | 512 |
| 625 void BrowserPlugin::ParseAttributes() { | |
| 626 // TODO(mthiesse): Handle errors here? | |
| 627 std::string error; | |
| 628 ParsePartitionAttribute(&error); | |
| 629 | |
| 630 // Parse the 'src' attribute last, as it will set the has_navigated_ flag to | |
| 631 // true, which prevents changing the 'partition' attribute. | |
| 632 ParseSrcAttribute(&error); | |
| 633 } | |
| 634 | |
| 635 float BrowserPlugin::GetDeviceScaleFactor() const { | 513 float BrowserPlugin::GetDeviceScaleFactor() const { |
| 636 if (!render_view_.get()) | 514 if (!render_view_.get()) |
| 637 return 1.0f; | 515 return 1.0f; |
| 638 return render_view_->GetWebView()->deviceScaleFactor(); | 516 return render_view_->GetWebView()->deviceScaleFactor(); |
| 639 } | 517 } |
| 640 | 518 |
| 641 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { | 519 void BrowserPlugin::UpdateDeviceScaleFactor(float device_scale_factor) { |
| 642 if (last_device_scale_factor_ == device_scale_factor || !paint_ack_received_) | 520 if (last_device_scale_factor_ == device_scale_factor || !paint_ack_received_) |
| 643 return; | 521 return; |
| 644 | 522 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 if (render_view_.get()) | 588 if (render_view_.get()) |
| 711 embedder_focused = render_view_->has_focus(); | 589 embedder_focused = render_view_->has_focus(); |
| 712 return plugin_focused_ && embedder_focused; | 590 return plugin_focused_ && embedder_focused; |
| 713 } | 591 } |
| 714 | 592 |
| 715 blink::WebPluginContainer* BrowserPlugin::container() const { | 593 blink::WebPluginContainer* BrowserPlugin::container() const { |
| 716 return container_; | 594 return container_; |
| 717 } | 595 } |
| 718 | 596 |
| 719 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 597 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
| 598 printf("BP::initialize()\n"); |
| 720 if (!container) | 599 if (!container) |
| 721 return false; | 600 return false; |
| 722 | 601 |
| 723 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container) && | 602 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container) && |
| 724 !auto_navigate_) | 603 !auto_navigate_) |
| 725 return false; | 604 return false; |
| 726 | 605 |
| 727 // Tell |container| to allow this plugin to use script objects. | 606 // Tell |container| to allow this plugin to use script objects. |
| 728 npp_.reset(new NPP_t); | 607 npp_.reset(new NPP_t); |
| 729 container->allowScriptObjects(); | 608 container->allowScriptObjects(); |
| 730 | 609 |
| 731 bindings_.reset(new BrowserPluginBindings(this)); | 610 bindings_.reset(new BrowserPluginBindings(this)); |
| 732 container_ = container; | 611 container_ = container; |
| 733 container_->setWantsWheelEvents(true); | 612 container_->setWantsWheelEvents(true); |
| 734 ParseAttributes(); | |
| 735 return true; | 613 return true; |
| 736 } | 614 } |
| 737 | 615 |
| 738 void BrowserPlugin::EnableCompositing(bool enable) { | 616 void BrowserPlugin::EnableCompositing(bool enable) { |
| 739 bool enabled = !!compositing_helper_; | 617 bool enabled = !!compositing_helper_; |
| 740 if (enabled == enable) | 618 if (enabled == enable) |
| 741 return; | 619 return; |
| 742 | 620 |
| 743 if (enable) { | 621 if (enable) { |
| 744 DCHECK(!compositing_helper_.get()); | 622 DCHECK(!compositing_helper_.get()); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 } | 918 } |
| 1041 | 919 |
| 1042 void BrowserPlugin::didReceiveData(const char* data, int data_length) { | 920 void BrowserPlugin::didReceiveData(const char* data, int data_length) { |
| 1043 if (auto_navigate_) { | 921 if (auto_navigate_) { |
| 1044 std::string value(data, data_length); | 922 std::string value(data, data_length); |
| 1045 html_string_ += value; | 923 html_string_ += value; |
| 1046 } | 924 } |
| 1047 } | 925 } |
| 1048 | 926 |
| 1049 void BrowserPlugin::didFinishLoading() { | 927 void BrowserPlugin::didFinishLoading() { |
| 928 printf("BP::didFinishLoading(), will update partition attr.\n"); |
| 1050 if (auto_navigate_) { | 929 if (auto_navigate_) { |
| 930 // web_view.js should pick this mutation. |
| 1051 UpdateDOMAttribute(content::browser_plugin::kAttributeSrc, html_string_); | 931 UpdateDOMAttribute(content::browser_plugin::kAttributeSrc, html_string_); |
| 1052 ParseAttributes(); | |
| 1053 } | 932 } |
| 1054 } | 933 } |
| 1055 | 934 |
| 1056 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { | 935 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { |
| 1057 } | 936 } |
| 1058 | 937 |
| 1059 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, | 938 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, |
| 1060 void* notify_data) { | 939 void* notify_data) { |
| 1061 } | 940 } |
| 1062 | 941 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 const blink::WebMouseEvent& event) { | 1029 const blink::WebMouseEvent& event) { |
| 1151 browser_plugin_manager()->Send( | 1030 browser_plugin_manager()->Send( |
| 1152 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 1031 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 1153 guest_instance_id_, | 1032 guest_instance_id_, |
| 1154 plugin_rect_, | 1033 plugin_rect_, |
| 1155 &event)); | 1034 &event)); |
| 1156 return true; | 1035 return true; |
| 1157 } | 1036 } |
| 1158 | 1037 |
| 1159 } // namespace content | 1038 } // namespace content |
| OLD | NEW |