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

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

Issue 13467038: Browser Plugin: Expose frame name changes to the content API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expose RenderViewHost::SetName to the content API Created 7 years, 8 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 (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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // Initiating a drag from inside a guest is currently not supported. So inject 599 // Initiating a drag from inside a guest is currently not supported. So inject
600 // some JS to disable it. http://crbug.com/161112 600 // some JS to disable it. http://crbug.com/161112
601 const char script[] = "window.addEventListener('dragstart', function() { " 601 const char script[] = "window.addEventListener('dragstart', function() { "
602 " window.event.preventDefault(); " 602 " window.event.preventDefault(); "
603 "});"; 603 "});";
604 render_view_host->ExecuteJavascriptInWebFrame(string16(), 604 render_view_host->ExecuteJavascriptInWebFrame(string16(),
605 ASCIIToUTF16(script)); 605 ASCIIToUTF16(script));
606 SendMessageToEmbedder(new BrowserPluginMsg_LoadStop(instance_id())); 606 SendMessageToEmbedder(new BrowserPluginMsg_LoadStop(instance_id()));
607 } 607 }
608 608
609 void BrowserPluginGuest::DidUpdateFrameName(int frame_id,
610 bool is_top_level,
611 const std::string& name,
612 RenderViewHost* render_view_host) {
613 if (!is_top_level)
614 return;
615
616 name_ = name;
617 SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName(instance_id_, name));
618 }
619
609 void BrowserPluginGuest::RenderViewReady() { 620 void BrowserPluginGuest::RenderViewReady() {
610 // TODO(fsamuel): Investigate whether it's possible to update state earlier 621 // TODO(fsamuel): Investigate whether it's possible to update state earlier
611 // here (see http://crbug.com/158151). 622 // here (see http://crbug.com/158151).
612 Send(new ViewMsg_SetFocus(routing_id(), focused_)); 623 Send(new ViewMsg_SetFocus(routing_id(), focused_));
613 UpdateVisibility(); 624 UpdateVisibility();
614 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); 625 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost();
615 if (auto_size_enabled_) 626 if (auto_size_enabled_)
616 rvh->EnableAutoResize(min_auto_size_, max_auto_size_); 627 rvh->EnableAutoResize(min_auto_size_, max_auto_size_);
617 else 628 else
618 rvh->DisableAutoResize(damage_view_size_); 629 rvh->DisableAutoResize(damage_view_size_);
619 630
620 Send(new ViewMsg_SetName(routing_id(), name_)); 631 rvh->SetName(name_);
jam 2013/04/09 16:11:51 is the intent that this file will move out content
621 632
622 RenderWidgetHostImpl::From(rvh)-> 633 RenderWidgetHostImpl::From(rvh)->
623 set_hung_renderer_delay_ms(guest_hang_timeout_); 634 set_hung_renderer_delay_ms(guest_hang_timeout_);
624 } 635 }
625 636
626 void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { 637 void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) {
627 int process_id = GetWebContents()->GetRenderProcessHost()->GetID(); 638 int process_id = GetWebContents()->GetRenderProcessHost()->GetID();
628 SendMessageToEmbedder( 639 SendMessageToEmbedder(
629 new BrowserPluginMsg_GuestGone(instance_id(), process_id, status)); 640 new BrowserPluginMsg_GuestGone(instance_id(), process_id, status));
630 switch (status) { 641 switch (status) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 #if defined(OS_MACOSX) 707 #if defined(OS_MACOSX)
697 // MacOSX creates and populates platform-specific select drop-down menus 708 // MacOSX creates and populates platform-specific select drop-down menus
698 // whereas other platforms merely create a popup window that the guest 709 // whereas other platforms merely create a popup window that the guest
699 // renderer process paints inside. 710 // renderer process paints inside.
700 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) 711 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
701 #endif 712 #endif
702 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 713 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
703 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 714 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
704 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 715 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
705 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) 716 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
706 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName)
707 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 717 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
708 IPC_MESSAGE_UNHANDLED(handled = false) 718 IPC_MESSAGE_UNHANDLED(handled = false)
709 IPC_END_MESSAGE_MAP() 719 IPC_END_MESSAGE_MAP()
710 return handled; 720 return handled;
711 } 721 }
712 722
713 void BrowserPluginGuest::Attach( 723 void BrowserPluginGuest::Attach(
714 WebContentsImpl* embedder_web_contents, 724 WebContentsImpl* embedder_web_contents,
715 BrowserPluginHostMsg_CreateGuest_Params params) { 725 BrowserPluginHostMsg_CreateGuest_Params params) {
716 const std::string target_url = opener()->pending_new_windows_[this]; 726 const std::string target_url = opener()->pending_new_windows_[this];
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 if (focused_ == focused) 945 if (focused_ == focused)
936 return; 946 return;
937 focused_ = focused; 947 focused_ = focused;
938 Send(new ViewMsg_SetFocus(routing_id(), focused)); 948 Send(new ViewMsg_SetFocus(routing_id(), focused));
939 } 949 }
940 950
941 void BrowserPluginGuest::OnSetName(int instance_id, const std::string& name) { 951 void BrowserPluginGuest::OnSetName(int instance_id, const std::string& name) {
942 if (name == name_) 952 if (name == name_)
943 return; 953 return;
944 name_ = name; 954 name_ = name;
945 Send(new ViewMsg_SetName(routing_id(), name)); 955 GetWebContents()->GetRenderViewHost()->SetName(name_);
946 } 956 }
947 957
948 void BrowserPluginGuest::OnSetSize( 958 void BrowserPluginGuest::OnSetSize(
949 int instance_id, 959 int instance_id,
950 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, 960 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params,
951 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params) { 961 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params) {
952 bool old_auto_size_enabled = auto_size_enabled_; 962 bool old_auto_size_enabled = auto_size_enabled_;
953 gfx::Size old_max_size = max_auto_size_; 963 gfx::Size old_max_size = max_auto_size_;
954 gfx::Size old_min_size = min_auto_size_; 964 gfx::Size old_min_size = min_auto_size_;
955 auto_size_enabled_ = auto_size_params.enable; 965 auto_size_enabled_ = auto_size_params.enable;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 RenderViewHostImpl* embedder_render_view_host = 1110 RenderViewHostImpl* embedder_render_view_host =
1101 static_cast<RenderViewHostImpl*>( 1111 static_cast<RenderViewHostImpl*>(
1102 embedder_web_contents_->GetRenderViewHost()); 1112 embedder_web_contents_->GetRenderViewHost());
1103 CHECK(embedder_render_view_host); 1113 CHECK(embedder_render_view_host);
1104 RenderViewHostDelegateView* view = 1114 RenderViewHostDelegateView* view =
1105 embedder_render_view_host->GetDelegate()->GetDelegateView(); 1115 embedder_render_view_host->GetDelegate()->GetDelegateView();
1106 if (view) 1116 if (view)
1107 view->UpdateDragCursor(operation); 1117 view->UpdateDragCursor(operation);
1108 } 1118 }
1109 1119
1110 void BrowserPluginGuest::OnUpdateFrameName(int frame_id,
1111 bool is_top_level,
1112 const std::string& name) {
1113 if (!is_top_level)
1114 return;
1115
1116 name_ = name;
1117 SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName(instance_id_, name));
1118 }
1119
1120 void BrowserPluginGuest::RequestMediaAccessPermission( 1120 void BrowserPluginGuest::RequestMediaAccessPermission(
1121 WebContents* web_contents, 1121 WebContents* web_contents,
1122 const MediaStreamRequest& request, 1122 const MediaStreamRequest& request,
1123 const MediaResponseCallback& callback) { 1123 const MediaResponseCallback& callback) {
1124 if (media_requests_map_.size() >= kNumMaxOutstandingPermissionRequests) { 1124 if (media_requests_map_.size() >= kNumMaxOutstandingPermissionRequests) {
1125 // Deny the media request. 1125 // Deny the media request.
1126 callback.Run(MediaStreamDevices()); 1126 callback.Run(MediaStreamDevices());
1127 return; 1127 return;
1128 } 1128 }
1129 int request_id = next_permission_request_id_++; 1129 int request_id = next_permission_request_id_++;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 base::Value::CreateStringValue(request_method)); 1304 base::Value::CreateStringValue(request_method));
1305 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1305 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1306 1306
1307 SendMessageToEmbedder( 1307 SendMessageToEmbedder(
1308 new BrowserPluginMsg_RequestPermission(instance_id(), 1308 new BrowserPluginMsg_RequestPermission(instance_id(),
1309 BrowserPluginPermissionTypeDownload, permission_request_id, 1309 BrowserPluginPermissionTypeDownload, permission_request_id,
1310 request_info)); 1310 request_info));
1311 } 1311 }
1312 1312
1313 } // namespace content 1313 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698