OLD | NEW |
(Empty) | |
| 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/web_contents/web_contents_view_cast.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_cast.h" |
| 11 #include "content/browser/web_contents/web_contents_impl.h" |
| 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_delegate.h" |
| 14 #include "content/public/browser/web_contents_view_delegate.h" |
| 15 |
| 16 // Chromecast porting notes: this file is derived from the Linux version of the |
| 17 // same file. |
| 18 |
| 19 namespace content { |
| 20 |
| 21 WebContentsViewPort* CreateWebContentsView( |
| 22 WebContentsImpl* web_contents, |
| 23 WebContentsViewDelegate* delegate, |
| 24 RenderViewHostDelegateView** render_view_host_delegate_view) { |
| 25 WebContentsViewCast* rv = new WebContentsViewCast(web_contents, delegate); |
| 26 *render_view_host_delegate_view = rv; |
| 27 return rv; |
| 28 } |
| 29 |
| 30 WebContentsViewCast::WebContentsViewCast( |
| 31 WebContentsImpl* web_contents, |
| 32 WebContentsViewDelegate* delegate) |
| 33 : web_contents_(web_contents), |
| 34 delegate_(delegate) { |
| 35 } |
| 36 |
| 37 WebContentsViewCast::~WebContentsViewCast() { |
| 38 } |
| 39 |
| 40 gfx::NativeView WebContentsViewCast::GetNativeView() const { |
| 41 NOTIMPLEMENTED(); |
| 42 return NULL; |
| 43 } |
| 44 |
| 45 gfx::NativeView WebContentsViewCast::GetContentNativeView() const { |
| 46 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 47 if (!rwhv) |
| 48 return NULL; |
| 49 return rwhv->GetNativeView(); |
| 50 } |
| 51 |
| 52 gfx::NativeWindow WebContentsViewCast::GetTopLevelNativeWindow() const { |
| 53 NOTIMPLEMENTED(); |
| 54 return NULL; |
| 55 } |
| 56 |
| 57 void WebContentsViewCast::GetContainerBounds(gfx::Rect* out) const { |
| 58 // If we ever add a border (other widgets on the screen), this |
| 59 // code will have to be revisited to account for other widgets on the screen. |
| 60 out->SetRect(0, 0, requested_size_.width(), requested_size_.height()); |
| 61 } |
| 62 |
| 63 void WebContentsViewCast::OnTabCrashed(base::TerminationStatus status, |
| 64 int error_code) { |
| 65 NOTIMPLEMENTED(); |
| 66 } |
| 67 |
| 68 void WebContentsViewCast::Focus() { |
| 69 NOTIMPLEMENTED(); |
| 70 } |
| 71 |
| 72 void WebContentsViewCast::SetInitialFocus() { |
| 73 if (web_contents_->FocusLocationBarByDefault()) |
| 74 web_contents_->SetFocusToLocationBar(false); |
| 75 else |
| 76 Focus(); |
| 77 } |
| 78 |
| 79 void WebContentsViewCast::StoreFocus() { |
| 80 NOTIMPLEMENTED(); |
| 81 } |
| 82 |
| 83 void WebContentsViewCast::RestoreFocus() { |
| 84 NOTIMPLEMENTED(); |
| 85 } |
| 86 |
| 87 DropData* WebContentsViewCast::GetDropData() const { |
| 88 NOTIMPLEMENTED(); |
| 89 return NULL; |
| 90 } |
| 91 |
| 92 gfx::Rect WebContentsViewCast::GetViewBounds() const { |
| 93 // As in GetContainerBounds, the code will have to be revisited if other |
| 94 // widgets are visible on the screen. |
| 95 gfx::Rect out; |
| 96 out.SetRect(0, 0, requested_size_.width(), requested_size_.height()); |
| 97 return out; |
| 98 } |
| 99 |
| 100 void WebContentsViewCast::CreateView(const gfx::Size& initial_size, |
| 101 gfx::NativeView context) { |
| 102 requested_size_ = initial_size; |
| 103 } |
| 104 |
| 105 RenderWidgetHostView* WebContentsViewCast::CreateViewForWidget( |
| 106 RenderWidgetHost* render_widget_host) { |
| 107 if (render_widget_host->GetView()) { |
| 108 // During testing, the view will already be set up in most cases to the |
| 109 // test view, so we don't want to clobber it with a real one. To verify that |
| 110 // this actually is happening (and somebody isn't accidentally creating the |
| 111 // view twice), we check for the RVH Factory, which will be set when we're |
| 112 // making special ones (which go along with the special views). |
| 113 DCHECK(RenderViewHostFactory::has_factory()); |
| 114 return render_widget_host->GetView(); |
| 115 } |
| 116 |
| 117 RenderWidgetHostView* view = |
| 118 RenderWidgetHostView::CreateViewForWidget(render_widget_host); |
| 119 view->InitAsChild(NULL); |
| 120 |
| 121 // TODO(lcwu): Need to look at whether these calls are in the correct place. |
| 122 // They are currently here to make sure we have the correct view size for |
| 123 // compositing path. |
| 124 view->SetSize(requested_size_); |
| 125 view->Show(); |
| 126 return view; |
| 127 } |
| 128 |
| 129 RenderWidgetHostView* WebContentsViewCast::CreateViewForPopupWidget( |
| 130 RenderWidgetHost* render_widget_host) { |
| 131 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); |
| 132 } |
| 133 |
| 134 void WebContentsViewCast::SetPageTitle(const base::string16& title) { |
| 135 NOTIMPLEMENTED(); |
| 136 } |
| 137 |
| 138 void WebContentsViewCast::SizeContents(const gfx::Size& size) { |
| 139 requested_size_ = size; |
| 140 // Pass the sizing information on to the RWHV which will pass the sizing |
| 141 // information on to the renderer. |
| 142 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 143 if (rwhv) |
| 144 rwhv->SetSize(size); |
| 145 } |
| 146 |
| 147 void WebContentsViewCast::RenderViewCreated(RenderViewHost* host) { |
| 148 NOTIMPLEMENTED(); |
| 149 } |
| 150 |
| 151 void WebContentsViewCast::RenderViewSwappedIn(RenderViewHost* host) { |
| 152 NOTIMPLEMENTED(); |
| 153 } |
| 154 |
| 155 void WebContentsViewCast::SetOverscrollControllerEnabled(bool enabled) { |
| 156 NOTIMPLEMENTED(); |
| 157 } |
| 158 |
| 159 WebContents* WebContentsViewCast::web_contents() { |
| 160 return web_contents_; |
| 161 } |
| 162 |
| 163 void WebContentsViewCast::ShowContextMenu( |
| 164 RenderFrameHost* render_frame_host, |
| 165 const ContextMenuParams& params) { |
| 166 if (delegate_.get()) |
| 167 delegate_->ShowContextMenu(render_frame_host, params); |
| 168 else |
| 169 DLOG(ERROR) << "Cannot show context menus without a delegate."; |
| 170 } |
| 171 |
| 172 void WebContentsViewCast::ShowPopupMenu( |
| 173 const gfx::Rect& bounds, |
| 174 int item_height, |
| 175 double item_font_size, |
| 176 int selected_item, |
| 177 const std::vector<MenuItem>& items, |
| 178 bool right_aligned, |
| 179 bool allow_multiple_selection) { |
| 180 // External popup menus are only used on Mac and Android. |
| 181 NOTIMPLEMENTED(); |
| 182 } |
| 183 |
| 184 void WebContentsViewCast::StartDragging( |
| 185 const DropData& drop_data, |
| 186 blink::WebDragOperationsMask allowed_ops, |
| 187 const gfx::ImageSkia& image, |
| 188 const gfx::Vector2d& image_offset, |
| 189 const DragEventSourceInfo& event_info) { |
| 190 NOTIMPLEMENTED(); |
| 191 } |
| 192 |
| 193 void WebContentsViewCast::UpdateDragCursor(blink::WebDragOperation op) { |
| 194 NOTIMPLEMENTED(); |
| 195 } |
| 196 |
| 197 void WebContentsViewCast::GotFocus() { |
| 198 NOTIMPLEMENTED(); |
| 199 } |
| 200 |
| 201 void WebContentsViewCast::TakeFocus(bool reverse) { |
| 202 NOTIMPLEMENTED(); |
| 203 } |
| 204 |
| 205 } // namespace content |
OLD | NEW |