| 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 3073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3084 const int download_id = ++next_image_download_id; | 3084 const int download_id = ++next_image_download_id; |
| 3085 if (!mojo_image_downloader) { | 3085 if (!mojo_image_downloader) { |
| 3086 // If the renderer process is dead (i.e. crash, or memory pressure on | 3086 // If the renderer process is dead (i.e. crash, or memory pressure on |
| 3087 // Android), the downloader service will be invalid. Pre-Mojo, this would | 3087 // Android), the downloader service will be invalid. Pre-Mojo, this would |
| 3088 // hang the callback indefinetly since the IPC would be dropped. Now, | 3088 // hang the callback indefinetly since the IPC would be dropped. Now, |
| 3089 // respond with a 400 HTTP error code to indicate that something went wrong. | 3089 // respond with a 400 HTTP error code to indicate that something went wrong. |
| 3090 BrowserThread::PostTask( | 3090 BrowserThread::PostTask( |
| 3091 BrowserThread::UI, FROM_HERE, | 3091 BrowserThread::UI, FROM_HERE, |
| 3092 base::Bind(&WebContentsImpl::OnDidDownloadImage, | 3092 base::Bind(&WebContentsImpl::OnDidDownloadImage, |
| 3093 weak_factory_.GetWeakPtr(), callback, download_id, url, 400, | 3093 weak_factory_.GetWeakPtr(), callback, download_id, url, 400, |
| 3094 nullptr, nullptr)); | 3094 std::vector<SkBitmap>(), std::vector<gfx::Size>())); |
| 3095 return download_id; | 3095 return download_id; |
| 3096 } | 3096 } |
| 3097 | 3097 |
| 3098 mojo_image_downloader->DownloadImage( | 3098 mojo_image_downloader->DownloadImage( |
| 3099 url, is_favicon, max_bitmap_size, bypass_cache, | 3099 url, is_favicon, max_bitmap_size, bypass_cache, |
| 3100 base::Bind(&WebContentsImpl::OnDidDownloadImage, | 3100 base::Bind(&WebContentsImpl::OnDidDownloadImage, |
| 3101 weak_factory_.GetWeakPtr(), callback, download_id, url)); | 3101 weak_factory_.GetWeakPtr(), callback, download_id, url)); |
| 3102 return download_id; | 3102 return download_id; |
| 3103 } | 3103 } |
| 3104 | 3104 |
| (...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4969 return view_->GetAllowOtherViews(); | 4969 return view_->GetAllowOtherViews(); |
| 4970 } | 4970 } |
| 4971 | 4971 |
| 4972 #endif | 4972 #endif |
| 4973 | 4973 |
| 4974 void WebContentsImpl::OnDidDownloadImage( | 4974 void WebContentsImpl::OnDidDownloadImage( |
| 4975 const ImageDownloadCallback& callback, | 4975 const ImageDownloadCallback& callback, |
| 4976 int id, | 4976 int id, |
| 4977 const GURL& image_url, | 4977 const GURL& image_url, |
| 4978 int32_t http_status_code, | 4978 int32_t http_status_code, |
| 4979 mojo::Array<SkBitmap> images, | 4979 const std::vector<SkBitmap>& images, |
| 4980 mojo::Array<gfx::Size> original_image_sizes) { | 4980 const std::vector<gfx::Size>& original_image_sizes) { |
| 4981 const std::vector<SkBitmap> bitmaps = images.To<std::vector<SkBitmap>>(); | 4981 callback.Run(id, http_status_code, image_url, images, original_image_sizes); |
| 4982 | |
| 4983 callback.Run(id, http_status_code, image_url, bitmaps, | |
| 4984 original_image_sizes.PassStorage()); | |
| 4985 } | 4982 } |
| 4986 | 4983 |
| 4987 void WebContentsImpl::OnDialogClosed(int render_process_id, | 4984 void WebContentsImpl::OnDialogClosed(int render_process_id, |
| 4988 int render_frame_id, | 4985 int render_frame_id, |
| 4989 IPC::Message* reply_msg, | 4986 IPC::Message* reply_msg, |
| 4990 bool dialog_was_suppressed, | 4987 bool dialog_was_suppressed, |
| 4991 bool success, | 4988 bool success, |
| 4992 const base::string16& user_input) { | 4989 const base::string16& user_input) { |
| 4993 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id, | 4990 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id, |
| 4994 render_frame_id); | 4991 render_frame_id); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5209 for (RenderViewHost* render_view_host : render_view_host_set) | 5206 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5210 render_view_host->OnWebkitPreferencesChanged(); | 5207 render_view_host->OnWebkitPreferencesChanged(); |
| 5211 } | 5208 } |
| 5212 | 5209 |
| 5213 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5210 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 5214 JavaScriptDialogManager* dialog_manager) { | 5211 JavaScriptDialogManager* dialog_manager) { |
| 5215 dialog_manager_ = dialog_manager; | 5212 dialog_manager_ = dialog_manager; |
| 5216 } | 5213 } |
| 5217 | 5214 |
| 5218 } // namespace content | 5215 } // namespace content |
| OLD | NEW |