| 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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 3068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 const int download_id = ++next_image_download_id; | 3079 const int download_id = ++next_image_download_id; |
| 3080 if (!mojo_image_downloader) { | 3080 if (!mojo_image_downloader) { |
| 3081 // If the renderer process is dead (i.e. crash, or memory pressure on | 3081 // If the renderer process is dead (i.e. crash, or memory pressure on |
| 3082 // Android), the downloader service will be invalid. Pre-Mojo, this would | 3082 // Android), the downloader service will be invalid. Pre-Mojo, this would |
| 3083 // hang the callback indefinetly since the IPC would be dropped. Now, | 3083 // hang the callback indefinetly since the IPC would be dropped. Now, |
| 3084 // respond with a 400 HTTP error code to indicate that something went wrong. | 3084 // respond with a 400 HTTP error code to indicate that something went wrong. |
| 3085 BrowserThread::PostTask( | 3085 BrowserThread::PostTask( |
| 3086 BrowserThread::UI, FROM_HERE, | 3086 BrowserThread::UI, FROM_HERE, |
| 3087 base::Bind(&WebContentsImpl::OnDidDownloadImage, | 3087 base::Bind(&WebContentsImpl::OnDidDownloadImage, |
| 3088 weak_factory_.GetWeakPtr(), callback, download_id, url, 400, | 3088 weak_factory_.GetWeakPtr(), callback, download_id, url, 400, |
| 3089 nullptr, nullptr)); | 3089 std::vector<SkBitmap>(), std::vector<gfx::Size>())); |
| 3090 return download_id; | 3090 return download_id; |
| 3091 } | 3091 } |
| 3092 | 3092 |
| 3093 mojo_image_downloader->DownloadImage( | 3093 mojo_image_downloader->DownloadImage( |
| 3094 url, is_favicon, max_bitmap_size, bypass_cache, | 3094 url, is_favicon, max_bitmap_size, bypass_cache, |
| 3095 base::Bind(&WebContentsImpl::OnDidDownloadImage, | 3095 base::Bind(&WebContentsImpl::OnDidDownloadImage, |
| 3096 weak_factory_.GetWeakPtr(), callback, download_id, url)); | 3096 weak_factory_.GetWeakPtr(), callback, download_id, url)); |
| 3097 return download_id; | 3097 return download_id; |
| 3098 } | 3098 } |
| 3099 | 3099 |
| (...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4991 return view_->GetAllowOtherViews(); | 4991 return view_->GetAllowOtherViews(); |
| 4992 } | 4992 } |
| 4993 | 4993 |
| 4994 #endif | 4994 #endif |
| 4995 | 4995 |
| 4996 void WebContentsImpl::OnDidDownloadImage( | 4996 void WebContentsImpl::OnDidDownloadImage( |
| 4997 const ImageDownloadCallback& callback, | 4997 const ImageDownloadCallback& callback, |
| 4998 int id, | 4998 int id, |
| 4999 const GURL& image_url, | 4999 const GURL& image_url, |
| 5000 int32_t http_status_code, | 5000 int32_t http_status_code, |
| 5001 mojo::Array<SkBitmap> images, | 5001 const std::vector<SkBitmap>& images, |
| 5002 mojo::Array<gfx::Size> original_image_sizes) { | 5002 const std::vector<gfx::Size>& original_image_sizes) { |
| 5003 const std::vector<SkBitmap> bitmaps = images.To<std::vector<SkBitmap>>(); | 5003 callback.Run(id, http_status_code, image_url, images, original_image_sizes); |
| 5004 | |
| 5005 callback.Run(id, http_status_code, image_url, bitmaps, | |
| 5006 original_image_sizes.PassStorage()); | |
| 5007 } | 5004 } |
| 5008 | 5005 |
| 5009 void WebContentsImpl::OnDialogClosed(int render_process_id, | 5006 void WebContentsImpl::OnDialogClosed(int render_process_id, |
| 5010 int render_frame_id, | 5007 int render_frame_id, |
| 5011 IPC::Message* reply_msg, | 5008 IPC::Message* reply_msg, |
| 5012 bool dialog_was_suppressed, | 5009 bool dialog_was_suppressed, |
| 5013 bool success, | 5010 bool success, |
| 5014 const base::string16& user_input) { | 5011 const base::string16& user_input) { |
| 5015 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id, | 5012 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id, |
| 5016 render_frame_id); | 5013 render_frame_id); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5231 for (RenderViewHost* render_view_host : render_view_host_set) | 5228 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5232 render_view_host->OnWebkitPreferencesChanged(); | 5229 render_view_host->OnWebkitPreferencesChanged(); |
| 5233 } | 5230 } |
| 5234 | 5231 |
| 5235 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5232 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 5236 JavaScriptDialogManager* dialog_manager) { | 5233 JavaScriptDialogManager* dialog_manager) { |
| 5237 dialog_manager_ = dialog_manager; | 5234 dialog_manager_ = dialog_manager; |
| 5238 } | 5235 } |
| 5239 | 5236 |
| 5240 } // namespace content | 5237 } // namespace content |
| OLD | NEW |