OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chrome_render_frame_observer.h" | 5 #include "chrome/renderer/chrome_render_frame_observer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/common/chrome_isolated_world_ids.h" | 19 #include "chrome/common/chrome_isolated_world_ids.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/crash_keys.h" | 21 #include "chrome/common/crash_keys.h" |
| 22 #include "chrome/common/open_search_description_document_handler.mojom.h" |
22 #include "chrome/common/prerender_messages.h" | 23 #include "chrome/common/prerender_messages.h" |
23 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
24 #include "chrome/renderer/prerender/prerender_helper.h" | 25 #include "chrome/renderer/prerender/prerender_helper.h" |
25 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 26 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
26 #include "components/translate/content/renderer/translate_helper.h" | 27 #include "components/translate/content/renderer/translate_helper.h" |
| 28 #include "content/public/common/associated_interface_provider.h" |
27 #include "content/public/renderer/render_frame.h" | 29 #include "content/public/renderer/render_frame.h" |
28 #include "content/public/renderer/render_view.h" | 30 #include "content/public/renderer/render_view.h" |
29 #include "extensions/common/constants.h" | 31 #include "extensions/common/constants.h" |
30 #include "printing/features/features.h" | 32 #include "printing/features/features.h" |
31 #include "services/service_manager/public/cpp/interface_registry.h" | 33 #include "services/service_manager/public/cpp/interface_registry.h" |
32 #include "skia/ext/image_operations.h" | 34 #include "skia/ext/image_operations.h" |
33 #include "third_party/WebKit/public/platform/WebImage.h" | 35 #include "third_party/WebKit/public/platform/WebImage.h" |
34 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 36 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
35 #include "third_party/WebKit/public/web/WebDataSource.h" | 37 #include "third_party/WebKit/public/web/WebDataSource.h" |
36 #include "third_party/WebKit/public/web/WebDocument.h" | 38 #include "third_party/WebKit/public/web/WebDocument.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 void ChromeRenderFrameObserver::RequestThumbnailForContextNode( | 190 void ChromeRenderFrameObserver::RequestThumbnailForContextNode( |
189 int32_t thumbnail_min_area_pixels, | 191 int32_t thumbnail_min_area_pixels, |
190 const gfx::Size& thumbnail_max_size_pixels, | 192 const gfx::Size& thumbnail_max_size_pixels, |
191 const RequestThumbnailForContextNodeCallback& callback) { | 193 const RequestThumbnailForContextNodeCallback& callback) { |
192 WebNode context_node = render_frame()->GetWebFrame()->contextMenuNode(); | 194 WebNode context_node = render_frame()->GetWebFrame()->contextMenuNode(); |
193 SkBitmap thumbnail; | 195 SkBitmap thumbnail; |
194 gfx::Size original_size; | 196 gfx::Size original_size; |
195 if (!context_node.isNull() && context_node.isElementNode()) { | 197 if (!context_node.isNull() && context_node.isElementNode()) { |
196 blink::WebImage image = context_node.to<WebElement>().imageContents(); | 198 blink::WebImage image = context_node.to<WebElement>().imageContents(); |
197 original_size = image.size(); | 199 original_size = image.size(); |
198 thumbnail = | 200 thumbnail = Downscale(image, |
199 Downscale(image, thumbnail_min_area_pixels, thumbnail_max_size_pixels); | 201 thumbnail_min_area_pixels, |
| 202 thumbnail_max_size_pixels); |
200 } | 203 } |
201 | 204 |
202 SkBitmap bitmap; | 205 SkBitmap bitmap; |
203 if (thumbnail.colorType() == kN32_SkColorType) | 206 if (thumbnail.colorType() == kN32_SkColorType) |
204 bitmap = thumbnail; | 207 bitmap = thumbnail; |
205 else | 208 else |
206 thumbnail.copyTo(&bitmap, kN32_SkColorType); | 209 thumbnail.copyTo(&bitmap, kN32_SkColorType); |
207 | 210 |
208 std::vector<uint8_t> thumbnail_data; | 211 std::vector<uint8_t> thumbnail_data; |
209 SkAutoLockPixels lock(bitmap); | 212 SkAutoLockPixels lock(bitmap); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 245 } |
243 | 246 |
244 void ChromeRenderFrameObserver::DidFinishLoad() { | 247 void ChromeRenderFrameObserver::DidFinishLoad() { |
245 WebLocalFrame* frame = render_frame()->GetWebFrame(); | 248 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
246 // Don't do anything for subframes. | 249 // Don't do anything for subframes. |
247 if (frame->parent()) | 250 if (frame->parent()) |
248 return; | 251 return; |
249 | 252 |
250 GURL osdd_url = frame->document().openSearchDescriptionURL(); | 253 GURL osdd_url = frame->document().openSearchDescriptionURL(); |
251 if (!osdd_url.is_empty()) { | 254 if (!osdd_url.is_empty()) { |
252 Send(new ChromeViewHostMsg_PageHasOSDD( | 255 chrome::mojom::OpenSearchDescriptionDocumentHandlerAssociatedPtr |
253 routing_id(), frame->document().url(), osdd_url)); | 256 osdd_handler; |
| 257 render_frame()->GetRemoteAssociatedInterfaces()->GetInterface( |
| 258 &osdd_handler); |
| 259 osdd_handler->PageHasOpenSearchDescriptionDocument( |
| 260 frame->document().url(), osdd_url); |
254 } | 261 } |
255 } | 262 } |
256 | 263 |
257 void ChromeRenderFrameObserver::DidStartProvisionalLoad( | 264 void ChromeRenderFrameObserver::DidStartProvisionalLoad( |
258 blink::WebDataSource* data_source) { | 265 blink::WebDataSource* data_source) { |
259 // Let translate_helper do any preparatory work for loading a URL. | 266 // Let translate_helper do any preparatory work for loading a URL. |
260 if (!translate_helper_) | 267 if (!translate_helper_) |
261 return; | 268 return; |
262 | 269 |
263 translate_helper_->PrepareForUrl( | 270 translate_helper_->PrepareForUrl( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 360 |
354 void ChromeRenderFrameObserver::OnImageContextMenuRendererRequest( | 361 void ChromeRenderFrameObserver::OnImageContextMenuRendererRequest( |
355 chrome::mojom::ImageContextMenuRendererRequest request) { | 362 chrome::mojom::ImageContextMenuRendererRequest request) { |
356 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); | 363 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); |
357 } | 364 } |
358 | 365 |
359 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( | 366 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( |
360 chrome::mojom::ThumbnailCapturerRequest request) { | 367 chrome::mojom::ThumbnailCapturerRequest request) { |
361 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); | 368 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); |
362 } | 369 } |
OLD | NEW |