Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 5 | #include "content/browser/renderer_host/test_render_view_host.h" |
| 6 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 7 | #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 8 | #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 9 | #include "content/browser/renderer_host/test_backing_store.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 10 | #include "content/browser/site_instance_impl.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 11 | #include "content/common/dom_storage/dom_storage_types.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 12 | #include "content/common/view_messages.h" |
| 13 | #include "content/public/browser/browser_context.h" |
| 14 | #include "content/public/browser/navigation_controller.h" |
| 15 | #include "content/public/browser/storage_partition.h" |
| 16 | #include "content/public/common/content_client.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 17 | #include "content/public/common/page_state.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 18 | #include "content/public/common/password_form.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 19 | #include "content/test/test_web_contents.h" |
| 20 | #include "media/base/video_frame.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 21 | #include "ui/gfx/rect.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 22 | #include "webkit/common/webpreferences.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 23 | |
| 24 | namespace content { |
| 25 | |
| 26 | namespace { |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 27 | |
| 28 | const int64 kFrameId = 13UL; |
| 29 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 30 | } // namespace |
| 31 | |
| 32 | |
| 33 | void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, |
| 34 | int page_id, |
| 35 | const GURL& url, |
| 36 | PageTransition transition) { |
| 37 | params->page_id = page_id; |
| 38 | params->url = url; |
| 39 | params->referrer = Referrer(); |
| 40 | params->transition = transition; |
| 41 | params->redirects = std::vector<GURL>(); |
| 42 | params->should_update_history = false; |
| 43 | params->searchable_form_url = GURL(); |
| 44 | params->searchable_form_encoding = std::string(); |
| 45 | params->password_form = PasswordForm(); |
| 46 | params->security_info = std::string(); |
| 47 | params->gesture = NavigationGestureUser; |
| 48 | params->was_within_same_page = false; |
| 49 | params->is_post = false; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 50 | params->page_state = PageState::CreateFromURL(url); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) |
| 54 | : rwh_(RenderWidgetHostImpl::From(rwh)), |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 55 | is_showing_(false), |
| 56 | did_swap_compositor_frame_(false) { |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 57 | rwh_->SetView(this); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | TestRenderWidgetHostView::~TestRenderWidgetHostView() { |
| 61 | } |
| 62 | |
| 63 | RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { |
| 64 | return NULL; |
| 65 | } |
| 66 | |
| 67 | gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { |
| 68 | return NULL; |
| 69 | } |
| 70 | |
| 71 | gfx::NativeViewId TestRenderWidgetHostView::GetNativeViewId() const { |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | gfx::NativeViewAccessible TestRenderWidgetHostView::GetNativeViewAccessible() { |
| 76 | return NULL; |
| 77 | } |
| 78 | |
| 79 | bool TestRenderWidgetHostView::HasFocus() const { |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | bool TestRenderWidgetHostView::IsSurfaceAvailableForCopy() const { |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | void TestRenderWidgetHostView::Show() { |
| 88 | is_showing_ = true; |
| 89 | } |
| 90 | |
| 91 | void TestRenderWidgetHostView::Hide() { |
| 92 | is_showing_ = false; |
| 93 | } |
| 94 | |
| 95 | bool TestRenderWidgetHostView::IsShowing() { |
| 96 | return is_showing_; |
| 97 | } |
| 98 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 99 | void TestRenderWidgetHostView::RenderProcessGone(base::TerminationStatus status, |
| 100 | int error_code) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 101 | delete this; |
| 102 | } |
| 103 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 104 | void TestRenderWidgetHostView::Destroy() { delete this; } |
| 105 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 106 | gfx::Rect TestRenderWidgetHostView::GetViewBounds() const { |
| 107 | return gfx::Rect(); |
| 108 | } |
| 109 | |
| 110 | BackingStore* TestRenderWidgetHostView::AllocBackingStore( |
| 111 | const gfx::Size& size) { |
| 112 | return new TestBackingStore(rwh_, size); |
| 113 | } |
| 114 | |
| 115 | void TestRenderWidgetHostView::CopyFromCompositingSurface( |
| 116 | const gfx::Rect& src_subrect, |
| 117 | const gfx::Size& dst_size, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 118 | const base::Callback<void(bool, const SkBitmap&)>& callback) { |
| 119 | callback.Run(false, SkBitmap()); |
| 120 | } |
| 121 | |
| 122 | void TestRenderWidgetHostView::CopyFromCompositingSurfaceToVideoFrame( |
| 123 | const gfx::Rect& src_subrect, |
| 124 | const scoped_refptr<media::VideoFrame>& target, |
| 125 | const base::Callback<void(bool)>& callback) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 126 | callback.Run(false); |
| 127 | } |
| 128 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 129 | bool TestRenderWidgetHostView::CanCopyToVideoFrame() const { |
| 130 | return false; |
| 131 | } |
| 132 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 133 | void TestRenderWidgetHostView::OnAcceleratedCompositingStateChange() { |
| 134 | } |
| 135 | |
| 136 | void TestRenderWidgetHostView::AcceleratedSurfaceBuffersSwapped( |
| 137 | const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 138 | int gpu_host_id) { |
| 139 | } |
| 140 | |
| 141 | void TestRenderWidgetHostView::AcceleratedSurfacePostSubBuffer( |
| 142 | const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
| 143 | int gpu_host_id) { |
| 144 | } |
| 145 | |
| 146 | void TestRenderWidgetHostView::AcceleratedSurfaceSuspend() { |
| 147 | } |
| 148 | |
| 149 | bool TestRenderWidgetHostView::HasAcceleratedSurface( |
| 150 | const gfx::Size& desired_size) { |
| 151 | return false; |
| 152 | } |
| 153 | |
| 154 | #if defined(OS_MACOSX) |
| 155 | |
| 156 | void TestRenderWidgetHostView::AboutToWaitForBackingStoreMsg() { |
| 157 | } |
| 158 | |
| 159 | void TestRenderWidgetHostView::SetActive(bool active) { |
| 160 | // <viettrungluu@gmail.com>: Do I need to do anything here? |
| 161 | } |
| 162 | |
| 163 | bool TestRenderWidgetHostView::SupportsSpeech() const { |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | void TestRenderWidgetHostView::SpeakSelection() { |
| 168 | } |
| 169 | |
| 170 | bool TestRenderWidgetHostView::IsSpeaking() const { |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | void TestRenderWidgetHostView::StopSpeaking() { |
| 175 | } |
| 176 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 177 | bool TestRenderWidgetHostView::PostProcessEventForPluginIme( |
| 178 | const NativeWebKeyboardEvent& event) { |
| 179 | return false; |
| 180 | } |
| 181 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 182 | #elif defined(OS_WIN) && !defined(USE_AURA) |
| 183 | void TestRenderWidgetHostView::WillWmDestroy() { |
| 184 | } |
| 185 | #endif |
| 186 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 187 | gfx::Rect TestRenderWidgetHostView::GetBoundsInRootWindow() { |
| 188 | return gfx::Rect(); |
| 189 | } |
| 190 | |
| 191 | #if defined(TOOLKIT_GTK) |
| 192 | GdkEventButton* TestRenderWidgetHostView::GetLastMouseDown() { |
| 193 | return NULL; |
| 194 | } |
| 195 | |
| 196 | gfx::NativeView TestRenderWidgetHostView::BuildInputMethodsGtkMenu() { |
| 197 | return NULL; |
| 198 | } |
| 199 | #endif // defined(TOOLKIT_GTK) |
| 200 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 201 | void TestRenderWidgetHostView::OnSwapCompositorFrame( |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 202 | uint32 output_surface_id, |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 203 | scoped_ptr<cc::CompositorFrame> frame) { |
| 204 | did_swap_compositor_frame_ = true; |
| 205 | } |
| 206 | |
| 207 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 208 | gfx::GLSurfaceHandle TestRenderWidgetHostView::GetCompositingSurface() { |
| 209 | return gfx::GLSurfaceHandle(); |
| 210 | } |
| 211 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 212 | #if defined(OS_WIN) && !defined(USE_AURA) |
| 213 | void TestRenderWidgetHostView::SetClickthroughRegion(SkRegion* region) { |
| 214 | } |
| 215 | #endif |
| 216 | |
| 217 | #if defined(OS_WIN) && defined(USE_AURA) |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 218 | gfx::NativeViewAccessible |
| 219 | TestRenderWidgetHostView::AccessibleObjectFromChildId(long child_id) { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 220 | NOTIMPLEMENTED(); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 221 | return NULL; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 222 | } |
| 223 | #endif |
| 224 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 225 | bool TestRenderWidgetHostView::LockMouse() { |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | void TestRenderWidgetHostView::UnlockMouse() { |
| 230 | } |
| 231 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 232 | #if defined(OS_WIN) && defined(USE_AURA) |
| 233 | void TestRenderWidgetHostView::SetParentNativeViewAccessible( |
| 234 | gfx::NativeViewAccessible accessible_parent) { |
| 235 | } |
| 236 | #endif |
| 237 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 238 | TestRenderViewHost::TestRenderViewHost( |
| 239 | SiteInstance* instance, |
| 240 | RenderViewHostDelegate* delegate, |
| 241 | RenderWidgetHostDelegate* widget_delegate, |
| 242 | int routing_id, |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 243 | int main_frame_routing_id, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 244 | bool swapped_out) |
| 245 | : RenderViewHostImpl(instance, |
| 246 | delegate, |
| 247 | widget_delegate, |
| 248 | routing_id, |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 249 | main_frame_routing_id, |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 250 | swapped_out), |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 251 | render_view_created_(false), |
| 252 | delete_counter_(NULL), |
| 253 | simulate_fetch_via_proxy_(false), |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 254 | simulate_history_list_was_cleared_(false), |
Ben Murdoch | fb25065 | 2013-07-31 11:42:55 +0100 | [diff] [blame] | 255 | contents_mime_type_("text/html"), |
| 256 | opener_route_id_(MSG_ROUTING_NONE) { |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 257 | // TestRenderWidgetHostView installs itself into this->view_ in its |
| 258 | // constructor, and deletes itself when TestRenderWidgetHostView::Destroy() is |
| 259 | // called. |
| 260 | new TestRenderWidgetHostView(this); |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 261 | |
| 262 | main_frame_id_ = kFrameId; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | TestRenderViewHost::~TestRenderViewHost() { |
| 266 | if (delete_counter_) |
| 267 | ++*delete_counter_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | bool TestRenderViewHost::CreateRenderView( |
| 271 | const string16& frame_name, |
| 272 | int opener_route_id, |
| 273 | int32 max_page_id) { |
| 274 | DCHECK(!render_view_created_); |
| 275 | render_view_created_ = true; |
Ben Murdoch | fb25065 | 2013-07-31 11:42:55 +0100 | [diff] [blame] | 276 | opener_route_id_ = opener_route_id; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 277 | return true; |
| 278 | } |
| 279 | |
| 280 | bool TestRenderViewHost::IsRenderViewLive() const { |
| 281 | return render_view_created_; |
| 282 | } |
| 283 | |
| 284 | void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) { |
| 285 | SendNavigateWithTransition(page_id, url, PAGE_TRANSITION_LINK); |
| 286 | } |
| 287 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 288 | void TestRenderViewHost::SendFailedNavigate(int page_id, const GURL& url) { |
| 289 | SendNavigateWithTransitionAndResponseCode( |
| 290 | page_id, url, PAGE_TRANSITION_LINK, 500); |
| 291 | } |
| 292 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 293 | void TestRenderViewHost::SendNavigateWithTransition( |
| 294 | int page_id, const GURL& url, PageTransition transition) { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 295 | SendNavigateWithTransitionAndResponseCode(page_id, url, transition, 200); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | void TestRenderViewHost::SendNavigateWithOriginalRequestURL( |
| 299 | int page_id, const GURL& url, const GURL& original_request_url) { |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 300 | OnDidStartProvisionalLoadForFrame(kFrameId, -1, true, url); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 301 | SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 302 | original_request_url, 200, 0); |
| 303 | } |
| 304 | |
| 305 | void TestRenderViewHost::SendNavigateWithFile( |
| 306 | int page_id, const GURL& url, const base::FilePath& file_path) { |
| 307 | SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, |
| 308 | url, 200, &file_path); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | void TestRenderViewHost::SendNavigateWithTransitionAndResponseCode( |
| 312 | int page_id, const GURL& url, PageTransition transition, |
| 313 | int response_code) { |
Ben Murdoch | 3240926 | 2013-08-07 11:04:47 +0100 | [diff] [blame] | 314 | OnDidStartProvisionalLoadForFrame(kFrameId, -1, true, url); |
| 315 | SendNavigateWithParameters(page_id, url, transition, url, response_code, 0); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | void TestRenderViewHost::SendNavigateWithParameters( |
| 319 | int page_id, const GURL& url, PageTransition transition, |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 320 | const GURL& original_request_url, int response_code, |
| 321 | const base::FilePath* file_path_for_history_item) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 322 | ViewHostMsg_FrameNavigate_Params params; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 323 | params.page_id = page_id; |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 324 | params.frame_id = kFrameId; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 325 | params.url = url; |
| 326 | params.referrer = Referrer(); |
| 327 | params.transition = transition; |
| 328 | params.redirects = std::vector<GURL>(); |
| 329 | params.should_update_history = true; |
| 330 | params.searchable_form_url = GURL(); |
| 331 | params.searchable_form_encoding = std::string(); |
| 332 | params.password_form = PasswordForm(); |
| 333 | params.security_info = std::string(); |
| 334 | params.gesture = NavigationGestureUser; |
| 335 | params.contents_mime_type = contents_mime_type_; |
| 336 | params.is_post = false; |
| 337 | params.was_within_same_page = false; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 338 | params.http_status_code = response_code; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 339 | params.socket_address.set_host("2001:db8::1"); |
| 340 | params.socket_address.set_port(80); |
| 341 | params.was_fetched_via_proxy = simulate_fetch_via_proxy_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 342 | params.history_list_was_cleared = simulate_history_list_was_cleared_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 343 | params.original_request_url = original_request_url; |
| 344 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 345 | params.page_state = PageState::CreateForTesting( |
| 346 | url, |
| 347 | false, |
| 348 | file_path_for_history_item ? "data" : NULL, |
| 349 | file_path_for_history_item); |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 350 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 351 | ViewHostMsg_FrameNavigate msg(1, params); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 352 | OnNavigate(msg); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | void TestRenderViewHost::SendShouldCloseACK(bool proceed) { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 356 | base::TimeTicks now = base::TimeTicks::Now(); |
| 357 | OnShouldCloseACK(proceed, now, now); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | void TestRenderViewHost::SetContentsMimeType(const std::string& mime_type) { |
| 361 | contents_mime_type_ = mime_type; |
| 362 | } |
| 363 | |
| 364 | void TestRenderViewHost::SimulateSwapOutACK() { |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 365 | OnSwappedOut(false); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | void TestRenderViewHost::SimulateWasHidden() { |
| 369 | WasHidden(); |
| 370 | } |
| 371 | |
| 372 | void TestRenderViewHost::SimulateWasShown() { |
| 373 | WasShown(); |
| 374 | } |
| 375 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 376 | void TestRenderViewHost::TestOnStartDragging( |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 377 | const DropData& drop_data) { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 378 | WebKit::WebDragOperationsMask drag_operation = WebKit::WebDragOperationEvery; |
| 379 | DragEventSourceInfo event_info; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 380 | OnStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d(), |
| 381 | event_info); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 382 | } |
| 383 | |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 384 | void TestRenderViewHost::TestOnUpdateStateWithFile( |
| 385 | int process_id, |
| 386 | const base::FilePath& file_path) { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 387 | OnUpdateState(process_id, |
| 388 | PageState::CreateForTesting(GURL("http://www.google.com"), |
| 389 | false, |
| 390 | "data", |
| 391 | &file_path)); |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 392 | } |
| 393 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 394 | void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) { |
| 395 | simulate_fetch_via_proxy_ = proxy; |
| 396 | } |
| 397 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 398 | void TestRenderViewHost::set_simulate_history_list_was_cleared(bool cleared) { |
| 399 | simulate_history_list_was_cleared_ = cleared; |
| 400 | } |
| 401 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 402 | RenderViewHostImplTestHarness::RenderViewHostImplTestHarness() { |
| 403 | } |
| 404 | |
| 405 | RenderViewHostImplTestHarness::~RenderViewHostImplTestHarness() { |
| 406 | } |
| 407 | |
| 408 | TestRenderViewHost* RenderViewHostImplTestHarness::test_rvh() { |
| 409 | return static_cast<TestRenderViewHost*>(rvh()); |
| 410 | } |
| 411 | |
| 412 | TestRenderViewHost* RenderViewHostImplTestHarness::pending_test_rvh() { |
| 413 | return static_cast<TestRenderViewHost*>(pending_rvh()); |
| 414 | } |
| 415 | |
| 416 | TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { |
| 417 | return static_cast<TestRenderViewHost*>(active_rvh()); |
| 418 | } |
| 419 | |
| 420 | TestWebContents* RenderViewHostImplTestHarness::contents() { |
| 421 | return static_cast<TestWebContents*>(web_contents()); |
| 422 | } |
| 423 | |
| 424 | } // namespace content |