| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/renderer/media/audio_renderer_impl.h" | 37 #include "chrome/renderer/media/audio_renderer_impl.h" |
| 38 #include "chrome/renderer/render_process.h" | 38 #include "chrome/renderer/render_process.h" |
| 39 #include "chrome/renderer/renderer_logging.h" | 39 #include "chrome/renderer/renderer_logging.h" |
| 40 #include "chrome/renderer/user_script_slave.h" | 40 #include "chrome/renderer/user_script_slave.h" |
| 41 #include "chrome/renderer/visitedlink_slave.h" | 41 #include "chrome/renderer/visitedlink_slave.h" |
| 42 #include "chrome/renderer/webmediaplayer_delegate_impl.h" | 42 #include "chrome/renderer/webmediaplayer_delegate_impl.h" |
| 43 #include "chrome/renderer/webplugin_delegate_proxy.h" | 43 #include "chrome/renderer/webplugin_delegate_proxy.h" |
| 44 #include "chrome/renderer/webworker_proxy.h" | 44 #include "chrome/renderer/webworker_proxy.h" |
| 45 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
| 46 #include "grit/renderer_resources.h" | 46 #include "grit/renderer_resources.h" |
| 47 #include "net/base/data_url.h" |
| 47 #include "net/base/escape.h" | 48 #include "net/base/escape.h" |
| 48 #include "net/base/net_errors.h" | 49 #include "net/base/net_errors.h" |
| 49 #include "printing/units.h" | 50 #include "printing/units.h" |
| 50 #include "skia/ext/bitmap_platform_device.h" | 51 #include "skia/ext/bitmap_platform_device.h" |
| 51 #include "skia/ext/image_operations.h" | 52 #include "skia/ext/image_operations.h" |
| 52 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" | 53 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" |
| 53 #include "webkit/default_plugin/default_plugin_shared.h" | 54 #include "webkit/default_plugin/default_plugin_shared.h" |
| 54 #include "webkit/glue/dom_operations.h" | 55 #include "webkit/glue/dom_operations.h" |
| 55 #include "webkit/glue/dom_serializer.h" | 56 #include "webkit/glue/dom_serializer.h" |
| 57 #include "webkit/glue/image_decoder.h" |
| 56 #include "webkit/glue/password_form.h" | 58 #include "webkit/glue/password_form.h" |
| 57 #include "webkit/glue/plugins/plugin_list.h" | 59 #include "webkit/glue/plugins/plugin_list.h" |
| 58 #include "webkit/glue/searchable_form_data.h" | 60 #include "webkit/glue/searchable_form_data.h" |
| 59 #include "webkit/glue/webaccessibilitymanager_impl.h" | 61 #include "webkit/glue/webaccessibilitymanager_impl.h" |
| 60 #include "webkit/glue/webdatasource.h" | 62 #include "webkit/glue/webdatasource.h" |
| 61 #include "webkit/glue/webdevtoolsagent_delegate.h" | 63 #include "webkit/glue/webdevtoolsagent_delegate.h" |
| 62 #include "webkit/glue/webdropdata.h" | 64 #include "webkit/glue/webdropdata.h" |
| 63 #include "webkit/glue/weberror.h" | 65 #include "webkit/glue/weberror.h" |
| 64 #include "webkit/glue/webframe.h" | 66 #include "webkit/glue/webframe.h" |
| 65 #include "webkit/glue/webhistoryitem.h" | 67 #include "webkit/glue/webhistoryitem.h" |
| (...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 bool errored, | 2046 bool errored, |
| 2045 const SkBitmap& image) { | 2047 const SkBitmap& image) { |
| 2046 Send(new ViewHostMsg_DidDownloadImage(routing_id_, id, image_url, errored, | 2048 Send(new ViewHostMsg_DidDownloadImage(routing_id_, id, image_url, errored, |
| 2047 image)); | 2049 image)); |
| 2048 } | 2050 } |
| 2049 | 2051 |
| 2050 | 2052 |
| 2051 void RenderView::OnDownloadImage(int id, | 2053 void RenderView::OnDownloadImage(int id, |
| 2052 const GURL& image_url, | 2054 const GURL& image_url, |
| 2053 int image_size) { | 2055 int image_size) { |
| 2054 if (!webview()->DownloadImage(id, image_url, image_size)) | 2056 |
| 2057 bool data_image_failed = false; |
| 2058 if (image_url.SchemeIs("data")) { |
| 2059 SkBitmap data_image = ImageFromDataUrl(image_url); |
| 2060 data_image_failed = data_image.empty(); |
| 2061 if (!data_image_failed) { |
| 2062 Send(new ViewHostMsg_DidDownloadImage(routing_id_, id, image_url, false, |
| 2063 data_image)); |
| 2064 } |
| 2065 } |
| 2066 |
| 2067 if (data_image_failed || !webview()->DownloadImage(id, image_url, image_size)) |
| 2055 Send(new ViewHostMsg_DidDownloadImage(routing_id_, id, image_url, true, | 2068 Send(new ViewHostMsg_DidDownloadImage(routing_id_, id, image_url, true, |
| 2056 SkBitmap())); | 2069 SkBitmap())); |
| 2057 } | 2070 } |
| 2058 | 2071 |
| 2072 SkBitmap RenderView::ImageFromDataUrl(const GURL& url) const { |
| 2073 std::string mime_type, char_set, data; |
| 2074 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { |
| 2075 // Decode the favicon using WebKit's image decoder. |
| 2076 webkit_glue::ImageDecoder decoder(gfx::Size(kFavIconSize, kFavIconSize)); |
| 2077 const unsigned char* src_data = |
| 2078 reinterpret_cast<const unsigned char*>(&data[0]); |
| 2079 |
| 2080 return decoder.Decode(src_data, data.size()); |
| 2081 } |
| 2082 return SkBitmap(); |
| 2083 } |
| 2084 |
| 2059 void RenderView::OnGetApplicationInfo(int page_id) { | 2085 void RenderView::OnGetApplicationInfo(int page_id) { |
| 2060 webkit_glue::WebApplicationInfo app_info; | 2086 webkit_glue::WebApplicationInfo app_info; |
| 2061 if (page_id == page_id_) | 2087 if (page_id == page_id_) |
| 2062 webkit_glue::GetApplicationInfo(webview(), &app_info); | 2088 webkit_glue::GetApplicationInfo(webview(), &app_info); |
| 2063 | 2089 |
| 2064 // Prune out any data URLs in the set of icons. The browser process expects | 2090 // Prune out any data URLs in the set of icons. The browser process expects |
| 2065 // any icon with a data URL to have originated from a favicon. We don't want | 2091 // any icon with a data URL to have originated from a favicon. We don't want |
| 2066 // to decode arbitrary data URLs in the browser process. See | 2092 // to decode arbitrary data URLs in the browser process. See |
| 2067 // http://b/issue?id=1162972 | 2093 // http://b/issue?id=1162972 |
| 2068 for (size_t i = 0; i < app_info.icons.size(); ++i) { | 2094 for (size_t i = 0; i < app_info.icons.size(); ++i) { |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3132 "Renderer.Other.StartToFinishDoc", start_to_finish_doc); | 3158 "Renderer.Other.StartToFinishDoc", start_to_finish_doc); |
| 3133 UMA_HISTOGRAM_TIMES( | 3159 UMA_HISTOGRAM_TIMES( |
| 3134 "Renderer.Other.FinishDocToFinish", finish_doc_to_finish); | 3160 "Renderer.Other.FinishDocToFinish", finish_doc_to_finish); |
| 3135 UMA_HISTOGRAM_TIMES( | 3161 UMA_HISTOGRAM_TIMES( |
| 3136 "Renderer.Other.RequestToFinish", request_to_finish); | 3162 "Renderer.Other.RequestToFinish", request_to_finish); |
| 3137 UMA_HISTOGRAM_TIMES( | 3163 UMA_HISTOGRAM_TIMES( |
| 3138 "Renderer.Other.StartToFinish", start_to_finish); | 3164 "Renderer.Other.StartToFinish", start_to_finish); |
| 3139 break; | 3165 break; |
| 3140 } | 3166 } |
| 3141 } | 3167 } |
| OLD | NEW |