Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 10 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
| 52 damage_buffer_size_(0), | 52 damage_buffer_size_(0), |
| 53 remote_damage_buffer_handle_(0), | 53 remote_damage_buffer_handle_(0), |
| 54 #endif | 54 #endif |
| 55 damage_buffer_scale_factor_(1.0f), | 55 damage_buffer_scale_factor_(1.0f), |
| 56 pending_update_counter_(0), | 56 pending_update_counter_(0), |
| 57 guest_hang_timeout_( | 57 guest_hang_timeout_( |
| 58 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 58 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
| 59 focused_(params.focused), | 59 focused_(params.focused), |
| 60 visible_(params.visible), | 60 visible_(params.visible), |
| 61 name_(params.name), | |
| 61 auto_size_enabled_(params.auto_size_params.enable), | 62 auto_size_enabled_(params.auto_size_params.enable), |
| 62 max_auto_size_(params.auto_size_params.max_size), | 63 max_auto_size_(params.auto_size_params.max_size), |
| 63 min_auto_size_(params.auto_size_params.min_size) { | 64 min_auto_size_(params.auto_size_params.min_size) { |
| 64 DCHECK(web_contents); | 65 DCHECK(web_contents); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void BrowserPluginGuest::InstallHelper( | 68 void BrowserPluginGuest::InstallHelper( |
| 68 content::RenderViewHost* render_view_host) { | 69 content::RenderViewHost* render_view_host) { |
| 69 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. | 70 // |render_view_host| manages the ownership of this BrowserPluginGuestHelper. |
| 70 new BrowserPluginGuestHelper(this, render_view_host); | 71 new BrowserPluginGuestHelper(this, render_view_host); |
| 71 | 72 |
| 72 notification_registrar_.Add( | 73 notification_registrar_.Add( |
| 73 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 74 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 74 content::Source<content::WebContents>(web_contents())); | 75 content::Source<content::WebContents>(web_contents())); |
| 75 } | 76 } |
| 76 | 77 |
| 78 void BrowserPluginGuest::SetName(const std::string& name) { | |
| 79 if (name == name_) | |
| 80 return; | |
| 81 name_ = name; | |
| 82 web_contents()->GetRenderViewHost()->Send(new ViewMsg_SetName( | |
| 83 web_contents()->GetRenderViewHost()->GetRoutingID(), | |
| 84 name)); | |
|
Charlie Reis
2012/12/13 01:11:42
nit: This last arg can go on previous line, which
Fady Samuel
2012/12/13 17:46:45
Done.
| |
| 85 } | |
| 86 | |
| 87 void BrowserPluginGuest::UpdateFrameName(int frame_id, | |
| 88 bool is_top_level, | |
| 89 const std::string& name) { | |
| 90 if (!is_top_level) | |
| 91 return; | |
| 92 | |
| 93 name_ = name; | |
| 94 SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName( | |
| 95 embedder_routing_id(), | |
| 96 instance_id_, | |
| 97 name)); | |
| 98 } | |
| 99 | |
| 77 BrowserPluginGuest::~BrowserPluginGuest() { | 100 BrowserPluginGuest::~BrowserPluginGuest() { |
| 78 } | 101 } |
| 79 | 102 |
| 80 // static | 103 // static |
| 81 BrowserPluginGuest* BrowserPluginGuest::Create( | 104 BrowserPluginGuest* BrowserPluginGuest::Create( |
| 82 int instance_id, | 105 int instance_id, |
| 83 WebContentsImpl* web_contents, | 106 WebContentsImpl* web_contents, |
| 84 const BrowserPluginHostMsg_CreateGuest_Params& params) { | 107 const BrowserPluginHostMsg_CreateGuest_Params& params) { |
| 85 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create")); | 108 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create")); |
| 86 if (factory_) { | 109 if (factory_) { |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 cursor)); | 563 cursor)); |
| 541 } | 564 } |
| 542 | 565 |
| 543 void BrowserPluginGuest::DidStartProvisionalLoadForFrame( | 566 void BrowserPluginGuest::DidStartProvisionalLoadForFrame( |
| 544 int64 frame_id, | 567 int64 frame_id, |
| 545 int64 parent_frame_id, | 568 int64 parent_frame_id, |
| 546 bool is_main_frame, | 569 bool is_main_frame, |
| 547 const GURL& validated_url, | 570 const GURL& validated_url, |
| 548 bool is_error_page, | 571 bool is_error_page, |
| 549 RenderViewHost* render_view_host) { | 572 RenderViewHost* render_view_host) { |
| 573 // Reset the guest name if we are loading a new main frame. | |
| 574 UpdateFrameName(frame_id, is_main_frame, ""); | |
|
Charlie Reis
2012/12/13 01:11:42
Though I wish the web platform worked this way, it
Fady Samuel
2012/12/13 17:46:45
Removed, thanks.
| |
| 550 // Inform the embedder of the loadStart. | 575 // Inform the embedder of the loadStart. |
| 551 SendMessageToEmbedder( | 576 SendMessageToEmbedder( |
| 552 new BrowserPluginMsg_LoadStart(embedder_routing_id(), | 577 new BrowserPluginMsg_LoadStart(embedder_routing_id(), |
| 553 instance_id(), | 578 instance_id(), |
| 554 validated_url, | 579 validated_url, |
| 555 is_main_frame)); | 580 is_main_frame)); |
| 556 } | 581 } |
| 557 | 582 |
| 558 void BrowserPluginGuest::DidFailProvisionalLoad( | 583 void BrowserPluginGuest::DidFailProvisionalLoad( |
| 559 int64 frame_id, | 584 int64 frame_id, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 Send(new ViewMsg_SetFocus(routing_id(), focused_)); | 644 Send(new ViewMsg_SetFocus(routing_id(), focused_)); |
| 620 bool embedder_visible = | 645 bool embedder_visible = |
| 621 embedder_web_contents_->GetBrowserPluginEmbedder()->visible(); | 646 embedder_web_contents_->GetBrowserPluginEmbedder()->visible(); |
| 622 SetVisibility(embedder_visible, visible()); | 647 SetVisibility(embedder_visible, visible()); |
| 623 if (auto_size_enabled_) { | 648 if (auto_size_enabled_) { |
| 624 web_contents()->GetRenderViewHost()->EnableAutoResize( | 649 web_contents()->GetRenderViewHost()->EnableAutoResize( |
| 625 min_auto_size_, max_auto_size_); | 650 min_auto_size_, max_auto_size_); |
| 626 } else { | 651 } else { |
| 627 web_contents()->GetRenderViewHost()->DisableAutoResize(damage_view_size_); | 652 web_contents()->GetRenderViewHost()->DisableAutoResize(damage_view_size_); |
| 628 } | 653 } |
| 654 | |
| 655 web_contents()->GetRenderViewHost()->Send(new ViewMsg_SetName( | |
|
Charlie Reis
2012/12/13 01:11:42
We should cache the RVH in a local variable, since
Fady Samuel
2012/12/13 17:46:45
Done.
| |
| 656 web_contents()->GetRenderViewHost()->GetRoutingID(), | |
| 657 name_)); | |
| 629 } | 658 } |
| 630 | 659 |
| 631 void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { | 660 void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { |
| 632 int process_id = web_contents()->GetRenderProcessHost()->GetID(); | 661 int process_id = web_contents()->GetRenderProcessHost()->GetID(); |
| 633 SendMessageToEmbedder(new BrowserPluginMsg_GuestGone(embedder_routing_id(), | 662 SendMessageToEmbedder(new BrowserPluginMsg_GuestGone(embedder_routing_id(), |
| 634 instance_id(), | 663 instance_id(), |
| 635 process_id, | 664 process_id, |
| 636 status)); | 665 status)); |
| 637 IDMap<RenderViewHost>::const_iterator iter(&pending_updates_); | 666 IDMap<RenderViewHost>::const_iterator iter(&pending_updates_); |
| 638 while (!iter.IsAtEnd()) { | 667 while (!iter.IsAtEnd()) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 653 default: | 682 default: |
| 654 break; | 683 break; |
| 655 } | 684 } |
| 656 } | 685 } |
| 657 | 686 |
| 658 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 687 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
| 659 embedder_web_contents_->Send(msg); | 688 embedder_web_contents_->Send(msg); |
| 660 } | 689 } |
| 661 | 690 |
| 662 } // namespace content | 691 } // namespace content |
| OLD | NEW |