| 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.h" | 15 #include "base/metrics/histogram.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/prerender_messages.h" | 22 #include "chrome/common/prerender_messages.h" |
| 23 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
| 24 #include "chrome/renderer/prerender/prerender_helper.h" | 24 #include "chrome/renderer/prerender/prerender_helper.h" |
| 25 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 25 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 26 #include "components/translate/content/renderer/translate_helper.h" | 26 #include "components/translate/content/renderer/translate_helper.h" |
| 27 #include "content/public/renderer/render_frame.h" | 27 #include "content/public/renderer/render_frame.h" |
| 28 #include "content/public/renderer/render_view.h" | 28 #include "content/public/renderer/render_view.h" |
| 29 #include "extensions/common/constants.h" | 29 #include "extensions/common/constants.h" |
| 30 #include "printing/features/features.h" |
| 30 #include "skia/ext/image_operations.h" | 31 #include "skia/ext/image_operations.h" |
| 31 #include "third_party/WebKit/public/platform/WebImage.h" | 32 #include "third_party/WebKit/public/platform/WebImage.h" |
| 32 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 33 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 33 #include "third_party/WebKit/public/web/WebDataSource.h" | 34 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 34 #include "third_party/WebKit/public/web/WebDocument.h" | 35 #include "third_party/WebKit/public/web/WebDocument.h" |
| 35 #include "third_party/WebKit/public/web/WebElement.h" | 36 #include "third_party/WebKit/public/web/WebElement.h" |
| 36 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" | 37 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
| 37 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 38 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 38 #include "third_party/WebKit/public/web/WebNode.h" | 39 #include "third_party/WebKit/public/web/WebNode.h" |
| 39 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 40 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 40 #include "third_party/skia/include/core/SkBitmap.h" | 41 #include "third_party/skia/include/core/SkBitmap.h" |
| 41 #include "ui/gfx/codec/jpeg_codec.h" | 42 #include "ui/gfx/codec/jpeg_codec.h" |
| 42 #include "ui/gfx/geometry/size_f.h" | 43 #include "ui/gfx/geometry/size_f.h" |
| 43 #include "url/gurl.h" | 44 #include "url/gurl.h" |
| 44 | 45 |
| 45 #if defined(ENABLE_PRINTING) | 46 #if BUILDFLAG(ENABLE_PRINTING) |
| 46 #include "components/printing/common/print_messages.h" | 47 #include "components/printing/common/print_messages.h" |
| 47 #include "components/printing/renderer/print_web_view_helper.h" | 48 #include "components/printing/renderer/print_web_view_helper.h" |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 using blink::WebDataSource; | 51 using blink::WebDataSource; |
| 51 using blink::WebElement; | 52 using blink::WebElement; |
| 52 using blink::WebFrameContentDumper; | 53 using blink::WebFrameContentDumper; |
| 53 using blink::WebLocalFrame; | 54 using blink::WebLocalFrame; |
| 54 using blink::WebNode; | 55 using blink::WebNode; |
| 55 using blink::WebString; | 56 using blink::WebString; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 if (handled) | 138 if (handled) |
| 138 return false; | 139 return false; |
| 139 | 140 |
| 140 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) | 141 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) |
| 141 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestReloadImageForContextNode, | 142 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestReloadImageForContextNode, |
| 142 OnRequestReloadImageForContextNode) | 143 OnRequestReloadImageForContextNode) |
| 143 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestThumbnailForContextNode, | 144 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestThumbnailForContextNode, |
| 144 OnRequestThumbnailForContextNode) | 145 OnRequestThumbnailForContextNode) |
| 145 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, | 146 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, |
| 146 OnSetClientSidePhishingDetection) | 147 OnSetClientSidePhishingDetection) |
| 147 #if defined(ENABLE_PRINTING) | 148 #if BUILDFLAG(ENABLE_PRINTING) |
| 148 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, | 149 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, |
| 149 OnPrintNodeUnderContextMenu) | 150 OnPrintNodeUnderContextMenu) |
| 150 #endif | 151 #endif |
| 151 IPC_MESSAGE_UNHANDLED(handled = false) | 152 IPC_MESSAGE_UNHANDLED(handled = false) |
| 152 IPC_END_MESSAGE_MAP() | 153 IPC_END_MESSAGE_MAP() |
| 153 | 154 |
| 154 return handled; | 155 return handled; |
| 155 } | 156 } |
| 156 | 157 |
| 157 void ChromeRenderFrameObserver::OnSetIsPrerendering( | 158 void ChromeRenderFrameObserver::OnSetIsPrerendering( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), | 212 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), |
| 212 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) | 213 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) |
| 213 thumbnail_data = std::string(data.begin(), data.end()); | 214 thumbnail_data = std::string(data.begin(), data.end()); |
| 214 } | 215 } |
| 215 | 216 |
| 216 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( | 217 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( |
| 217 routing_id(), thumbnail_data, original_size, callback_id)); | 218 routing_id(), thumbnail_data, original_size, callback_id)); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { | 221 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { |
| 221 #if defined(ENABLE_PRINTING) | 222 #if BUILDFLAG(ENABLE_PRINTING) |
| 222 printing::PrintWebViewHelper* helper = | 223 printing::PrintWebViewHelper* helper = |
| 223 printing::PrintWebViewHelper::Get(render_frame()->GetRenderView()); | 224 printing::PrintWebViewHelper::Get(render_frame()->GetRenderView()); |
| 224 if (helper) | 225 if (helper) |
| 225 helper->PrintNode(render_frame()->GetWebFrame()->contextMenuNode()); | 226 helper->PrintNode(render_frame()->GetWebFrame()->contextMenuNode()); |
| 226 #endif | 227 #endif |
| 227 } | 228 } |
| 228 | 229 |
| 229 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( | 230 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( |
| 230 bool enable_phishing_detection) { | 231 bool enable_phishing_detection) { |
| 231 #if defined(SAFE_BROWSING_CSD) | 232 #if defined(SAFE_BROWSING_CSD) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 CapturePageText(FINAL_CAPTURE); | 338 CapturePageText(FINAL_CAPTURE); |
| 338 break; | 339 break; |
| 339 default: | 340 default: |
| 340 break; | 341 break; |
| 341 } | 342 } |
| 342 } | 343 } |
| 343 | 344 |
| 344 void ChromeRenderFrameObserver::OnDestruct() { | 345 void ChromeRenderFrameObserver::OnDestruct() { |
| 345 delete this; | 346 delete this; |
| 346 } | 347 } |
| OLD | NEW |