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

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

Issue 549323002: BrowserPlugin: Interstitial Pages work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 17 matching lines...) Expand all
28 #include "content/common/host_shared_bitmap_manager.h" 28 #include "content/common/host_shared_bitmap_manager.h"
29 #include "content/common/input_messages.h" 29 #include "content/common/input_messages.h"
30 #include "content/common/view_messages.h" 30 #include "content/common/view_messages.h"
31 #include "content/public/browser/browser_context.h" 31 #include "content/public/browser/browser_context.h"
32 #include "content/public/browser/browser_plugin_guest_manager.h" 32 #include "content/public/browser/browser_plugin_guest_manager.h"
33 #include "content/public/browser/content_browser_client.h" 33 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/render_widget_host_view.h" 34 #include "content/public/browser/render_widget_host_view.h"
35 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
36 #include "content/public/browser/web_contents_observer.h" 36 #include "content/public/browser/web_contents_observer.h"
37 #include "content/public/common/drop_data.h" 37 #include "content/public/common/drop_data.h"
38 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
39 38
40 #if defined(OS_MACOSX) 39 #if defined(OS_MACOSX)
41 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h" 40 #include "content/browser/browser_plugin/browser_plugin_popup_menu_helper_mac.h"
42 #endif 41 #endif
43 42
44 namespace content { 43 namespace content {
45 44
46 class BrowserPluginGuest::EmbedderWebContentsObserver 45 class BrowserPluginGuest::EmbedderWebContentsObserver
47 : public WebContentsObserver { 46 : public WebContentsObserver {
48 public: 47 public:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 99
101 void BrowserPluginGuest::WillDestroy() { 100 void BrowserPluginGuest::WillDestroy() {
102 is_in_destruction_ = true; 101 is_in_destruction_ = true;
103 embedder_web_contents_ = NULL; 102 embedder_web_contents_ = NULL;
104 } 103 }
105 104
106 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() { 105 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() {
107 return weak_ptr_factory_.GetWeakPtr(); 106 return weak_ptr_factory_.GetWeakPtr();
108 } 107 }
109 108
109 void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh, bool focused) {
110 focused_ = focused;
111 rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused));
112 if (!focused && mouse_locked_)
113 OnUnlockMouse();
114
115 // Restore the last seen state of text input to the view.
116 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>(
117 web_contents()->GetRenderWidgetHostView());
118 if (rwhv) {
119 ViewHostMsg_TextInputState_Params params;
120 params.type = last_text_input_type_;
121 params.mode = last_input_mode_;
122 params.can_compose_inline = last_can_compose_inline_;
123 rwhv->TextInputStateChanged(params);
124 }
125 }
126
110 bool BrowserPluginGuest::LockMouse(bool allowed) { 127 bool BrowserPluginGuest::LockMouse(bool allowed) {
111 if (!attached() || (mouse_locked_ == allowed)) 128 if (!attached() || (mouse_locked_ == allowed))
112 return false; 129 return false;
113 130
114 return embedder_web_contents()->GotResponseToLockMouseRequest(allowed); 131 return embedder_web_contents()->GotResponseToLockMouseRequest(allowed);
115 } 132 }
116 133
117 void BrowserPluginGuest::Destroy() { 134 void BrowserPluginGuest::Destroy() {
118 delegate_->Destroy(); 135 delegate_->Destroy();
119 } 136 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) 496 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
480 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition, 497 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCancelComposition,
481 OnImeCancelComposition) 498 OnImeCancelComposition)
482 #if defined(OS_MACOSX) || defined(USE_AURA) 499 #if defined(OS_MACOSX) || defined(USE_AURA)
483 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, 500 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged,
484 OnImeCompositionRangeChanged) 501 OnImeCompositionRangeChanged)
485 #endif 502 #endif
486 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, 503 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
487 OnHasTouchEventHandlers) 504 OnHasTouchEventHandlers)
488 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 505 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
489 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
490 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 506 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
491 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 507 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
492 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, 508 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged,
493 OnTextInputStateChanged) 509 OnTextInputStateChanged)
494 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 510 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
495 IPC_MESSAGE_UNHANDLED(handled = false) 511 IPC_MESSAGE_UNHANDLED(handled = false)
496 IPC_END_MESSAGE_MAP() 512 IPC_END_MESSAGE_MAP()
497 return handled; 513 return handled;
498 } 514 }
499 515
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 702
687 // Just resize the WebContents and repaint if needed. 703 // Just resize the WebContents and repaint if needed.
688 if (!params.view_size.IsEmpty()) 704 if (!params.view_size.IsEmpty())
689 GetWebContents()->GetView()->SizeContents(params.view_size); 705 GetWebContents()->GetView()->SizeContents(params.view_size);
690 if (params.repaint) 706 if (params.repaint)
691 Send(new ViewMsg_Repaint(routing_id(), params.view_size)); 707 Send(new ViewMsg_Repaint(routing_id(), params.view_size));
692 } 708 }
693 709
694 void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id, 710 void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id,
695 bool focused) { 711 bool focused) {
696 focused_ = focused;
697 Send(new InputMsg_SetFocus(routing_id(), focused));
698 if (!focused && mouse_locked_)
699 OnUnlockMouse();
700 712
701 // Restore the last seen state of text input to the view. 713 RenderWidgetHost* rwh = web_contents()->GetRenderWidgetHostView()->
702 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( 714 GetRenderWidgetHost();
703 web_contents()->GetRenderWidgetHostView()); 715 SetFocus(rwh, focused);
704 if (rwhv) {
705 ViewHostMsg_TextInputState_Params params;
706 params.type = last_text_input_type_;
707 params.mode = last_input_mode_;
708 params.can_compose_inline = last_can_compose_inline_;
709 rwhv->TextInputStateChanged(params);
710 }
711 } 716 }
712 717
713 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( 718 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent(
714 int browser_plugin_instance_id, 719 int browser_plugin_instance_id,
715 const std::vector<EditCommand>& edit_commands) { 720 const std::vector<EditCommand>& edit_commands) {
716 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), 721 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(),
717 edit_commands)); 722 edit_commands));
718 } 723 }
719 724
720 void BrowserPluginGuest::OnSetContentsOpaque(int browser_plugin_instance_id, 725 void BrowserPluginGuest::OnSetContentsOpaque(int browser_plugin_instance_id,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 if (rvh) 773 if (rvh)
769 rvh->SendScreenRects(); 774 rvh->SendScreenRects();
770 } 775 }
771 776
772 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { 777 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) {
773 SendMessageToEmbedder( 778 SendMessageToEmbedder(
774 new BrowserPluginMsg_ShouldAcceptTouchEvents( 779 new BrowserPluginMsg_ShouldAcceptTouchEvents(
775 browser_plugin_instance_id(), accept)); 780 browser_plugin_instance_id(), accept));
776 } 781 }
777 782
778 void BrowserPluginGuest::OnSetCursor(const WebCursor& cursor) {
779 SendMessageToEmbedder(
780 new BrowserPluginMsg_SetCursor(browser_plugin_instance_id(), cursor));
781 }
782
783 #if defined(OS_MACOSX) 783 #if defined(OS_MACOSX)
784 void BrowserPluginGuest::OnShowPopup( 784 void BrowserPluginGuest::OnShowPopup(
785 RenderFrameHost* render_frame_host, 785 RenderFrameHost* render_frame_host,
786 const FrameHostMsg_ShowPopup_Params& params) { 786 const FrameHostMsg_ShowPopup_Params& params) {
787 gfx::Rect translated_bounds(params.bounds); 787 gfx::Rect translated_bounds(params.bounds);
788 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin()); 788 translated_bounds.Offset(guest_window_rect_.OffsetFromOrigin());
789 BrowserPluginPopupMenuHelper popup_menu_helper( 789 BrowserPluginPopupMenuHelper popup_menu_helper(
790 embedder_web_contents_->GetRenderViewHost(), render_frame_host); 790 embedder_web_contents_->GetRenderViewHost(), render_frame_host);
791 popup_menu_helper.ShowPopupMenu(translated_bounds, 791 popup_menu_helper.ShowPopupMenu(translated_bounds,
792 params.item_height, 792 params.item_height,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 void BrowserPluginGuest::OnImeCompositionRangeChanged( 828 void BrowserPluginGuest::OnImeCompositionRangeChanged(
829 const gfx::Range& range, 829 const gfx::Range& range,
830 const std::vector<gfx::Rect>& character_bounds) { 830 const std::vector<gfx::Rect>& character_bounds) {
831 static_cast<RenderWidgetHostViewBase*>( 831 static_cast<RenderWidgetHostViewBase*>(
832 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 832 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
833 range, character_bounds); 833 range, character_bounds);
834 } 834 }
835 #endif 835 #endif
836 836
837 } // namespace content 837 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698