| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 gesture_event.sourceDevice = blink::WebGestureDeviceTouchscreen; | 39 gesture_event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 40 return gesture_event; | 40 return gesture_event; |
| 41 } | 41 } |
| 42 #endif // defined(USE_AURA) | 42 #endif // defined(USE_AURA) |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( | 46 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( |
| 47 RenderWidgetHost* widget_host, | 47 RenderWidgetHost* widget_host, |
| 48 BrowserPluginGuest* guest, | 48 BrowserPluginGuest* guest, |
| 49 RenderWidgetHostViewBase* platform_view) | 49 base::WeakPtr<RenderWidgetHostViewBase> platform_view) |
| 50 : RenderWidgetHostViewChildFrame(widget_host), | 50 : RenderWidgetHostViewChildFrame(widget_host), |
| 51 // |guest| is NULL during test. | 51 // |guest| is NULL during test. |
| 52 guest_(guest ? guest->AsWeakPtr() : base::WeakPtr<BrowserPluginGuest>()), | 52 guest_(guest ? guest->AsWeakPtr() : base::WeakPtr<BrowserPluginGuest>()), |
| 53 platform_view_(platform_view) { | 53 platform_view_(platform_view) { |
| 54 #if defined(USE_AURA) | 54 #if defined(USE_AURA) |
| 55 gesture_recognizer_.reset(ui::GestureRecognizer::Create()); | 55 gesture_recognizer_.reset(ui::GestureRecognizer::Create()); |
| 56 gesture_recognizer_->AddGestureEventHelper(this); | 56 gesture_recognizer_->AddGestureEventHelper(this); |
| 57 #endif // defined(USE_AURA) | 57 #endif // defined(USE_AURA) |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 platform_view_->RenderProcessGone(status, error_code); | 170 platform_view_->RenderProcessGone(status, error_code); |
| 171 // Destroy the guest view instance only, so we don't end up calling | 171 // Destroy the guest view instance only, so we don't end up calling |
| 172 // platform_view_->Destroy(). | 172 // platform_view_->Destroy(). |
| 173 DestroyGuestView(); | 173 DestroyGuestView(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void RenderWidgetHostViewGuest::Destroy() { | 176 void RenderWidgetHostViewGuest::Destroy() { |
| 177 // The RenderWidgetHost's destruction led here, so don't call it. | 177 // The RenderWidgetHost's destruction led here, so don't call it. |
| 178 DestroyGuestView(); | 178 DestroyGuestView(); |
| 179 | 179 |
| 180 platform_view_->Destroy(); | 180 if (platform_view_) // The platform view might have been destroyed already. |
| 181 platform_view_->Destroy(); |
| 181 } | 182 } |
| 182 | 183 |
| 183 gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const { | 184 gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const { |
| 184 return RenderWidgetHostViewBase::GetPhysicalBackingSize(); | 185 return RenderWidgetHostViewBase::GetPhysicalBackingSize(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 base::string16 RenderWidgetHostViewGuest::GetSelectedText() const { | 188 base::string16 RenderWidgetHostViewGuest::GetSelectedText() const { |
| 188 return platform_view_->GetSelectedText(); | 189 return platform_view_->GetSelectedText(); |
| 189 } | 190 } |
| 190 | 191 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 gfx::Rect embedder_bounds; | 411 gfx::Rect embedder_bounds; |
| 411 if (rwhv) | 412 if (rwhv) |
| 412 embedder_bounds = rwhv->GetViewBounds(); | 413 embedder_bounds = rwhv->GetViewBounds(); |
| 413 | 414 |
| 414 gfx::Vector2d guest_offset = gfx::Vector2d( | 415 gfx::Vector2d guest_offset = gfx::Vector2d( |
| 415 // Horizontal offset of guest from embedder. | 416 // Horizontal offset of guest from embedder. |
| 416 guest_bounds.x() - embedder_bounds.x(), | 417 guest_bounds.x() - embedder_bounds.x(), |
| 417 // Vertical offset from guest's top to embedder's bottom edge. | 418 // Vertical offset from guest's top to embedder's bottom edge. |
| 418 embedder_bounds.bottom() - guest_bounds.y()); | 419 embedder_bounds.bottom() - guest_bounds.y()); |
| 419 | 420 |
| 420 RenderWidgetHostViewMacDictionaryHelper helper(platform_view_); | 421 RenderWidgetHostViewMacDictionaryHelper helper(platform_view_.get()); |
| 421 helper.SetTargetView(rwhv); | 422 helper.SetTargetView(rwhv); |
| 422 helper.set_offset(guest_offset); | 423 helper.set_offset(guest_offset); |
| 423 helper.ShowDefinitionForSelection(); | 424 helper.ShowDefinitionForSelection(); |
| 424 } | 425 } |
| 425 | 426 |
| 426 bool RenderWidgetHostViewGuest::SupportsSpeech() const { | 427 bool RenderWidgetHostViewGuest::SupportsSpeech() const { |
| 427 return platform_view_->SupportsSpeech(); | 428 return platform_view_->SupportsSpeech(); |
| 428 } | 429 } |
| 429 | 430 |
| 430 void RenderWidgetHostViewGuest::SpeakSelection() { | 431 void RenderWidgetHostViewGuest::SpeakSelection() { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 } | 594 } |
| 594 | 595 |
| 595 if (blink::WebInputEvent::isGestureEventType(event->type)) { | 596 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
| 596 host_->ForwardGestureEvent( | 597 host_->ForwardGestureEvent( |
| 597 *static_cast<const blink::WebGestureEvent*>(event)); | 598 *static_cast<const blink::WebGestureEvent*>(event)); |
| 598 return; | 599 return; |
| 599 } | 600 } |
| 600 } | 601 } |
| 601 | 602 |
| 602 } // namespace content | 603 } // namespace content |
| OLD | NEW |