| OLD | NEW |
| 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/test/test_web_contents.h" | 5 #include "content/test/test_web_contents.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/browser/browser_url_handler_impl.h" | 9 #include "content/browser/browser_url_handler_impl.h" |
| 10 #include "content/browser/frame_host/cross_process_frame_connector.h" | 10 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 rfh->SimulateNavigationStart(url); | 86 rfh->SimulateNavigationStart(url); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 int TestWebContents::DownloadImage(const GURL& url, | 90 int TestWebContents::DownloadImage(const GURL& url, |
| 91 bool is_favicon, | 91 bool is_favicon, |
| 92 uint32_t max_bitmap_size, | 92 uint32_t max_bitmap_size, |
| 93 bool bypass_cache, | 93 bool bypass_cache, |
| 94 const ImageDownloadCallback& callback) { | 94 const ImageDownloadCallback& callback) { |
| 95 static int g_next_image_download_id = 0; | 95 static int g_next_image_download_id = 0; |
| 96 return ++g_next_image_download_id; | 96 ++g_next_image_download_id; |
| 97 pending_image_downloads_[g_next_image_download_id].first = url; |
| 98 pending_image_downloads_[g_next_image_download_id].second = callback; |
| 99 return g_next_image_download_id; |
| 97 } | 100 } |
| 98 | 101 |
| 99 void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host, | 102 void TestWebContents::TestDidNavigate(RenderFrameHost* render_frame_host, |
| 100 int nav_entry_id, | 103 int nav_entry_id, |
| 101 bool did_create_new_entry, | 104 bool did_create_new_entry, |
| 102 const GURL& url, | 105 const GURL& url, |
| 103 ui::PageTransition transition) { | 106 ui::PageTransition transition) { |
| 104 TestDidNavigateWithReferrer(render_frame_host, | 107 TestDidNavigateWithReferrer(render_frame_host, |
| 105 nav_entry_id, | 108 nav_entry_id, |
| 106 did_create_new_entry, | 109 did_create_new_entry, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 params.searchable_form_url = GURL(); | 182 params.searchable_form_url = GURL(); |
| 180 params.searchable_form_encoding = std::string(); | 183 params.searchable_form_encoding = std::string(); |
| 181 | 184 |
| 182 rfh->SendNavigateWithParams(¶ms); | 185 rfh->SendNavigateWithParams(¶ms); |
| 183 } | 186 } |
| 184 | 187 |
| 185 const std::string& TestWebContents::GetSaveFrameHeaders() { | 188 const std::string& TestWebContents::GetSaveFrameHeaders() { |
| 186 return save_frame_headers_; | 189 return save_frame_headers_; |
| 187 } | 190 } |
| 188 | 191 |
| 192 bool TestWebContents::TestDidDownloadImage( |
| 193 int id, |
| 194 int http_status_code, |
| 195 const std::vector<SkBitmap>& bitmaps, |
| 196 const std::vector<gfx::Size>& original_bitmap_sizes) { |
| 197 std::map<int, std::pair<GURL, ImageDownloadCallback>>::iterator |
| 198 pending_download = pending_image_downloads_.find(id); |
| 199 if (pending_download == pending_image_downloads_.end()) |
| 200 return false; |
| 201 pending_download->second.second.Run(id, http_status_code, |
| 202 pending_download->second.first, bitmaps, |
| 203 original_bitmap_sizes); |
| 204 pending_image_downloads_.erase(pending_download); |
| 205 return true; |
| 206 } |
| 207 |
| 189 bool TestWebContents::CrossProcessNavigationPending() { | 208 bool TestWebContents::CrossProcessNavigationPending() { |
| 190 if (IsBrowserSideNavigationEnabled()) { | 209 if (IsBrowserSideNavigationEnabled()) { |
| 191 return GetRenderManager()->speculative_render_frame_host_ != nullptr; | 210 return GetRenderManager()->speculative_render_frame_host_ != nullptr; |
| 192 } | 211 } |
| 193 return GetRenderManager()->pending_frame_host() != nullptr; | 212 return GetRenderManager()->pending_frame_host() != nullptr; |
| 194 } | 213 } |
| 195 | 214 |
| 196 bool TestWebContents::CreateRenderViewForRenderManager( | 215 bool TestWebContents::CreateRenderViewForRenderManager( |
| 197 RenderViewHost* render_view_host, | 216 RenderViewHost* render_view_host, |
| 198 int opener_frame_routing_id, | 217 int opener_frame_routing_id, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 int route_id) { | 399 int route_id) { |
| 381 } | 400 } |
| 382 | 401 |
| 383 void TestWebContents::SaveFrameWithHeaders(const GURL& url, | 402 void TestWebContents::SaveFrameWithHeaders(const GURL& url, |
| 384 const Referrer& referrer, | 403 const Referrer& referrer, |
| 385 const std::string& headers) { | 404 const std::string& headers) { |
| 386 save_frame_headers_ = headers; | 405 save_frame_headers_ = headers; |
| 387 } | 406 } |
| 388 | 407 |
| 389 } // namespace content | 408 } // namespace content |
| OLD | NEW |