Home | History | Annotate | Download | only in frame_host
      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
      3 // found in the LICENSE file.
      4 
      5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
      6 
      7 #include "content/browser/accessibility/browser_accessibility_manager.h"
      8 #include "content/browser/frame_host/cross_process_frame_connector.h"
      9 #include "content/browser/renderer_host/render_widget_host_impl.h"
     10 #include "content/common/gpu/gpu_messages.h"
     11 #include "content/common/view_messages.h"
     12 #include "content/public/browser/render_process_host.h"
     13 
     14 namespace content {
     15 
     16 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
     17     RenderWidgetHost* widget_host)
     18     : host_(RenderWidgetHostImpl::From(widget_host)),
     19       frame_connector_(NULL) {
     20   host_->SetView(this);
     21 }
     22 
     23 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
     24 }
     25 
     26 void RenderWidgetHostViewChildFrame::InitAsChild(
     27     gfx::NativeView parent_view) {
     28   NOTREACHED();
     29 }
     30 
     31 RenderWidgetHost* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const {
     32   return host_;
     33 }
     34 
     35 void RenderWidgetHostViewChildFrame::SetSize(const gfx::Size& size) {
     36   host_->WasResized();
     37 }
     38 
     39 void RenderWidgetHostViewChildFrame::SetBounds(const gfx::Rect& rect) {
     40   SetSize(rect.size());
     41 }
     42 
     43 void RenderWidgetHostViewChildFrame::Focus() {
     44 }
     45 
     46 bool RenderWidgetHostViewChildFrame::HasFocus() const {
     47   return false;
     48 }
     49 
     50 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const {
     51   NOTIMPLEMENTED();
     52   return false;
     53 }
     54 
     55 void RenderWidgetHostViewChildFrame::Show() {
     56   WasShown();
     57 }
     58 
     59 void RenderWidgetHostViewChildFrame::Hide() {
     60   WasHidden();
     61 }
     62 
     63 bool RenderWidgetHostViewChildFrame::IsShowing() {
     64   return !host_->is_hidden();
     65 }
     66 
     67 gfx::Rect RenderWidgetHostViewChildFrame::GetViewBounds() const {
     68   gfx::Rect rect;
     69   if (frame_connector_)
     70     rect = frame_connector_->ChildFrameRect();
     71   return rect;
     72 }
     73 
     74 gfx::Vector2dF RenderWidgetHostViewChildFrame::GetLastScrollOffset() const {
     75   return last_scroll_offset_;
     76 }
     77 
     78 gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() const {
     79   NOTREACHED();
     80   return NULL;
     81 }
     82 
     83 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetNativeViewId() const {
     84   NOTREACHED();
     85   return 0;
     86 }
     87 
     88 gfx::NativeViewAccessible
     89 RenderWidgetHostViewChildFrame::GetNativeViewAccessible() {
     90   NOTREACHED();
     91   return NULL;
     92 }
     93 
     94 void RenderWidgetHostViewChildFrame::SetBackgroundOpaque(bool opaque) {
     95 }
     96 
     97 gfx::Size RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const {
     98   gfx::Size size;
     99   if (frame_connector_)
    100     size = frame_connector_->ChildFrameRect().size();
    101   return size;
    102 }
    103 
    104 void RenderWidgetHostViewChildFrame::InitAsPopup(
    105     RenderWidgetHostView* parent_host_view,
    106     const gfx::Rect& pos) {
    107   NOTREACHED();
    108 }
    109 
    110 void RenderWidgetHostViewChildFrame::InitAsFullscreen(
    111     RenderWidgetHostView* reference_host_view) {
    112   NOTREACHED();
    113 }
    114 
    115 void RenderWidgetHostViewChildFrame::ImeCancelComposition() {
    116   NOTREACHED();
    117 }
    118 
    119 #if defined(OS_MACOSX) || defined(USE_AURA)
    120 void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged(
    121     const gfx::Range& range,
    122     const std::vector<gfx::Rect>& character_bounds) {
    123   NOTREACHED();
    124 }
    125 #endif
    126 
    127 void RenderWidgetHostViewChildFrame::WasShown() {
    128   if (!host_->is_hidden())
    129     return;
    130   host_->WasShown(ui::LatencyInfo());
    131 }
    132 
    133 void RenderWidgetHostViewChildFrame::WasHidden() {
    134   if (host_->is_hidden())
    135     return;
    136   host_->WasHidden();
    137 }
    138 
    139 void RenderWidgetHostViewChildFrame::MovePluginWindows(
    140     const std::vector<WebPluginGeometry>& moves) {
    141 }
    142 
    143 void RenderWidgetHostViewChildFrame::Blur() {
    144 }
    145 
    146 void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor& cursor) {
    147 }
    148 
    149 void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading) {
    150   NOTREACHED();
    151 }
    152 
    153 void RenderWidgetHostViewChildFrame::TextInputTypeChanged(
    154     ui::TextInputType type,
    155     ui::TextInputMode input_mode,
    156     bool can_compose_inline) {
    157   NOTREACHED();
    158 }
    159 
    160 void RenderWidgetHostViewChildFrame::RenderProcessGone(
    161     base::TerminationStatus status,
    162     int error_code) {
    163   if (frame_connector_)
    164     frame_connector_->RenderProcessGone();
    165   Destroy();
    166 }
    167 
    168 void RenderWidgetHostViewChildFrame::Destroy() {
    169   if (frame_connector_) {
    170     frame_connector_->set_view(NULL);
    171     frame_connector_ = NULL;
    172   }
    173 
    174   host_->SetView(NULL);
    175   host_ = NULL;
    176   base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
    177 }
    178 
    179 void RenderWidgetHostViewChildFrame::SetTooltipText(
    180     const base::string16& tooltip_text) {
    181 }
    182 
    183 void RenderWidgetHostViewChildFrame::SelectionChanged(
    184     const base::string16& text,
    185     size_t offset,
    186     const gfx::Range& range) {
    187 }
    188 
    189 void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
    190     const ViewHostMsg_SelectionBounds_Params& params) {
    191 }
    192 
    193 #if defined(OS_ANDROID) || defined(TOOLKIT_VIEWS) || defined(USE_AURA)
    194 void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup(
    195     const gfx::Rect& rect_pixels,
    196     const SkBitmap& zoomed_bitmap) {
    197 }
    198 #endif
    199 
    200 #if defined(OS_ANDROID)
    201 void RenderWidgetHostViewChildFrame::LockCompositingSurface() {
    202 }
    203 
    204 void RenderWidgetHostViewChildFrame::UnlockCompositingSurface() {
    205 }
    206 #endif
    207 
    208 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id,
    209                                                               int route_id) {
    210 }
    211 
    212 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped(
    213     const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
    214     int gpu_host_id) {
    215   NOTREACHED();
    216 }
    217 
    218 void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer(
    219     const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
    220     int gpu_host_id) {
    221 }
    222 
    223 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
    224       uint32 output_surface_id,
    225       scoped_ptr<cc::CompositorFrame> frame) {
    226   last_scroll_offset_ = frame->metadata.root_scroll_offset;
    227   if (frame_connector_) {
    228     frame_connector_->ChildFrameCompositorFrameSwapped(
    229         output_surface_id,
    230         host_->GetProcess()->GetID(),
    231         host_->GetRoutingID(),
    232         frame.Pass());
    233   }
    234 }
    235 
    236 void RenderWidgetHostViewChildFrame::GetScreenInfo(
    237     blink::WebScreenInfo* results) {
    238 }
    239 
    240 gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
    241   // We do not have any root window specific parts in this view.
    242   return GetViewBounds();
    243 }
    244 
    245 #if defined(USE_AURA)
    246 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
    247     const TouchEventWithLatencyInfo& touch,
    248     InputEventAckState ack_result) {
    249 }
    250 #endif  // defined(USE_AURA)
    251 
    252 bool RenderWidgetHostViewChildFrame::LockMouse() {
    253   return false;
    254 }
    255 
    256 void RenderWidgetHostViewChildFrame::UnlockMouse() {
    257 }
    258 
    259 #if defined(OS_MACOSX)
    260 void RenderWidgetHostViewChildFrame::SetActive(bool active) {
    261 }
    262 
    263 void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag) {
    264 }
    265 
    266 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible) {
    267 }
    268 
    269 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
    270 }
    271 
    272 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
    273 }
    274 
    275 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
    276   return false;
    277 }
    278 
    279 void RenderWidgetHostViewChildFrame::SpeakSelection() {
    280 }
    281 
    282 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
    283   return false;
    284 }
    285 
    286 void RenderWidgetHostViewChildFrame::StopSpeaking() {
    287 }
    288 
    289 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
    290       const NativeWebKeyboardEvent& event) {
    291   return false;
    292 }
    293 #endif // defined(OS_MACOSX)
    294 
    295 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
    296     const gfx::Rect& src_subrect,
    297     const gfx::Size& /* dst_size */,
    298     CopyFromCompositingSurfaceCallback& callback,
    299     const SkColorType color_type) {
    300   callback.Run(false, SkBitmap());
    301 }
    302 
    303 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
    304       const gfx::Rect& src_subrect,
    305       const scoped_refptr<media::VideoFrame>& target,
    306       const base::Callback<void(bool)>& callback) {
    307   NOTIMPLEMENTED();
    308   callback.Run(false);
    309 }
    310 
    311 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
    312   return false;
    313 }
    314 
    315 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() {
    316   NOTREACHED();
    317 }
    318 
    319 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() {
    320 }
    321 
    322 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
    323       const gfx::Size& desired_size) {
    324   return false;
    325 }
    326 
    327 gfx::GLSurfaceHandle RenderWidgetHostViewChildFrame::GetCompositingSurface() {
    328   return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT);
    329 }
    330 
    331 #if defined(OS_WIN)
    332 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
    333     gfx::NativeViewAccessible accessible_parent) {
    334 }
    335 
    336 gfx::NativeViewId RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
    337     const {
    338   return NULL;
    339 }
    340 #endif // defined(OS_WIN)
    341 
    342 SkColorType RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
    343   return kN32_SkColorType;
    344 }
    345 
    346 BrowserAccessibilityManager*
    347 RenderWidgetHostViewChildFrame::CreateBrowserAccessibilityManager(
    348     BrowserAccessibilityDelegate* delegate) {
    349   return BrowserAccessibilityManager::Create(
    350       BrowserAccessibilityManager::GetEmptyDocument(), delegate);
    351 }
    352 
    353 }  // namespace content
    354