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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 408 |
409 // We would like the guest to report changes to frame names so that we can | 409 // We would like the guest to report changes to frame names so that we can |
410 // update the BrowserPlugin's corresponding 'name' attribute. | 410 // update the BrowserPlugin's corresponding 'name' attribute. |
411 // TODO(fsamuel): Remove this once http://crbug.com/169110 is addressed. | 411 // TODO(fsamuel): Remove this once http://crbug.com/169110 is addressed. |
412 renderer_prefs->report_frame_name_changes = true; | 412 renderer_prefs->report_frame_name_changes = true; |
413 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated | 413 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated |
414 // navigations still continue to function inside the app. | 414 // navigations still continue to function inside the app. |
415 renderer_prefs->browser_handles_all_top_level_requests = false; | 415 renderer_prefs->browser_handles_all_top_level_requests = false; |
416 | 416 |
417 notification_registrar_.Add( | 417 notification_registrar_.Add( |
418 this, NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | |
419 Source<WebContents>(GetWebContents())); | |
420 | |
421 notification_registrar_.Add( | |
422 this, NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 418 this, NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
423 Source<WebContents>(GetWebContents())); | 419 Source<WebContents>(GetWebContents())); |
424 | 420 |
425 // Listen to embedder visibility changes so that the guest is in a 'shown' | 421 // Listen to embedder visibility changes so that the guest is in a 'shown' |
426 // state if both the embedder is visible and the BrowserPlugin is marked as | 422 // state if both the embedder is visible and the BrowserPlugin is marked as |
427 // visible. | 423 // visible. |
428 notification_registrar_.Add( | 424 notification_registrar_.Add( |
429 this, NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 425 this, NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
430 Source<WebContents>(embedder_web_contents_)); | 426 Source<WebContents>(embedder_web_contents_)); |
431 | 427 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { | 512 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { |
517 gfx::Rect guest_rect(bounds); | 513 gfx::Rect guest_rect(bounds); |
518 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); | 514 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); |
519 return guest_rect; | 515 return guest_rect; |
520 } | 516 } |
521 | 517 |
522 void BrowserPluginGuest::Observe(int type, | 518 void BrowserPluginGuest::Observe(int type, |
523 const NotificationSource& source, | 519 const NotificationSource& source, |
524 const NotificationDetails& details) { | 520 const NotificationDetails& details) { |
525 switch (type) { | 521 switch (type) { |
526 case NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { | |
527 DCHECK_EQ(Source<WebContents>(source).ptr(), GetWebContents()); | |
528 LoadHandlerCalled(); | |
529 break; | |
530 } | |
531 case NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { | 522 case NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: { |
532 DCHECK_EQ(Source<WebContents>(source).ptr(), GetWebContents()); | 523 DCHECK_EQ(Source<WebContents>(source).ptr(), GetWebContents()); |
533 ResourceRedirectDetails* resource_redirect_details = | 524 ResourceRedirectDetails* resource_redirect_details = |
534 Details<ResourceRedirectDetails>(details).ptr(); | 525 Details<ResourceRedirectDetails>(details).ptr(); |
535 bool is_top_level = | 526 bool is_top_level = |
536 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME; | 527 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME; |
537 LoadRedirect(resource_redirect_details->url, | 528 LoadRedirect(resource_redirect_details->url, |
538 resource_redirect_details->new_url, | 529 resource_redirect_details->new_url, |
539 is_top_level); | 530 is_top_level); |
540 break; | 531 break; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 // As a result, we must save all these IPCs until attachment and then | 805 // As a result, we must save all these IPCs until attachment and then |
815 // forward them so that the embedder gets a chance to see and process | 806 // forward them so that the embedder gets a chance to see and process |
816 // the load events. | 807 // the load events. |
817 pending_messages_.push(msg); | 808 pending_messages_.push(msg); |
818 return; | 809 return; |
819 } | 810 } |
820 msg->set_routing_id(embedder_web_contents_->GetRoutingID()); | 811 msg->set_routing_id(embedder_web_contents_->GetRoutingID()); |
821 embedder_web_contents_->Send(msg); | 812 embedder_web_contents_->Send(msg); |
822 } | 813 } |
823 | 814 |
824 void BrowserPluginGuest::LoadHandlerCalled() { | |
825 SendMessageToEmbedder(new BrowserPluginMsg_LoadHandlerCalled(instance_id())); | |
826 } | |
827 | |
828 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, | 815 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, |
829 int screen_x, int screen_y, WebKit::WebDragOperation operation) { | 816 int screen_x, int screen_y, WebKit::WebDragOperation operation) { |
830 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, | 817 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, |
831 screen_x, screen_y, operation); | 818 screen_x, screen_y, operation); |
832 } | 819 } |
833 | 820 |
834 void BrowserPluginGuest::DragSourceMovedTo(int client_x, int client_y, | 821 void BrowserPluginGuest::DragSourceMovedTo(int client_x, int client_y, |
835 int screen_x, int screen_y) { | 822 int screen_x, int screen_y) { |
836 web_contents()->GetRenderViewHost()->DragSourceMovedTo(client_x, client_y, | 823 web_contents()->GetRenderViewHost()->DragSourceMovedTo(client_x, client_y, |
837 screen_x, screen_y); | 824 screen_x, screen_y); |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 base::Value::CreateStringValue(request_method)); | 1582 base::Value::CreateStringValue(request_method)); |
1596 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); | 1583 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); |
1597 | 1584 |
1598 SendMessageToEmbedder( | 1585 SendMessageToEmbedder( |
1599 new BrowserPluginMsg_RequestPermission(instance_id(), | 1586 new BrowserPluginMsg_RequestPermission(instance_id(), |
1600 BrowserPluginPermissionTypeDownload, permission_request_id, | 1587 BrowserPluginPermissionTypeDownload, permission_request_id, |
1601 request_info)); | 1588 request_info)); |
1602 } | 1589 } |
1603 | 1590 |
1604 } // namespace content | 1591 } // namespace content |
OLD | NEW |