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 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "chrome/common/chrome_isolated_world_ids.h" | 17 #include "chrome/common/chrome_isolated_world_ids.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/crash_keys.h" | 19 #include "chrome/common/crash_keys.h" |
20 #include "chrome/common/prerender_messages.h" | 20 #include "chrome/common/prerender_messages.h" |
21 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
22 #include "chrome/renderer/prerender/prerender_helper.h" | 22 #include "chrome/renderer/prerender/prerender_helper.h" |
23 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 23 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
24 #include "components/printing/common/print_messages.h" | |
25 #include "components/printing/renderer/print_web_view_helper.h" | |
26 #include "components/translate/content/renderer/translate_helper.h" | 24 #include "components/translate/content/renderer/translate_helper.h" |
27 #include "content/public/renderer/render_frame.h" | 25 #include "content/public/renderer/render_frame.h" |
28 #include "content/public/renderer/render_view.h" | 26 #include "content/public/renderer/render_view.h" |
29 #include "extensions/common/constants.h" | 27 #include "extensions/common/constants.h" |
30 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
31 #include "skia/ext/image_operations.h" | 29 #include "skia/ext/image_operations.h" |
32 #include "third_party/WebKit/public/platform/WebImage.h" | 30 #include "third_party/WebKit/public/platform/WebImage.h" |
33 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" | 31 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" |
34 #include "third_party/WebKit/public/web/WebDataSource.h" | 32 #include "third_party/WebKit/public/web/WebDataSource.h" |
35 #include "third_party/WebKit/public/web/WebDocument.h" | 33 #include "third_party/WebKit/public/web/WebDocument.h" |
36 #include "third_party/WebKit/public/web/WebElement.h" | 34 #include "third_party/WebKit/public/web/WebElement.h" |
37 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 35 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
38 #include "third_party/WebKit/public/web/WebNode.h" | 36 #include "third_party/WebKit/public/web/WebNode.h" |
39 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 37 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
40 #include "third_party/skia/include/core/SkBitmap.h" | 38 #include "third_party/skia/include/core/SkBitmap.h" |
41 #include "ui/gfx/codec/jpeg_codec.h" | 39 #include "ui/gfx/codec/jpeg_codec.h" |
42 #include "ui/gfx/geometry/size_f.h" | 40 #include "ui/gfx/geometry/size_f.h" |
43 #include "url/gurl.h" | 41 #include "url/gurl.h" |
44 | 42 |
| 43 #if defined(ENABLE_PRINTING) |
| 44 #include "components/printing/common/print_messages.h" |
| 45 #include "components/printing/renderer/print_web_view_helper.h" |
| 46 #endif |
| 47 |
45 using blink::WebDataSource; | 48 using blink::WebDataSource; |
46 using blink::WebElement; | 49 using blink::WebElement; |
47 using blink::WebLocalFrame; | 50 using blink::WebLocalFrame; |
48 using blink::WebNode; | 51 using blink::WebNode; |
49 using blink::WebString; | 52 using blink::WebString; |
50 using content::SSLStatus; | 53 using content::SSLStatus; |
51 using content::RenderFrame; | 54 using content::RenderFrame; |
52 | 55 |
53 // Delay in milliseconds that we'll wait before capturing the page contents. | 56 // Delay in milliseconds that we'll wait before capturing the page contents. |
54 static const int kDelayForCaptureMs = 500; | 57 static const int kDelayForCaptureMs = 500; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (handled) | 208 if (handled) |
206 return false; | 209 return false; |
207 | 210 |
208 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) | 211 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) |
209 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestReloadImageForContextNode, | 212 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestReloadImageForContextNode, |
210 OnRequestReloadImageForContextNode) | 213 OnRequestReloadImageForContextNode) |
211 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestThumbnailForContextNode, | 214 IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestThumbnailForContextNode, |
212 OnRequestThumbnailForContextNode) | 215 OnRequestThumbnailForContextNode) |
213 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, | 216 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, |
214 OnSetClientSidePhishingDetection) | 217 OnSetClientSidePhishingDetection) |
| 218 #if defined(ENABLE_PRINTING) |
215 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, | 219 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, |
216 OnPrintNodeUnderContextMenu) | 220 OnPrintNodeUnderContextMenu) |
| 221 #endif |
217 IPC_MESSAGE_HANDLER(ChromeViewMsg_AppBannerPromptRequest, | 222 IPC_MESSAGE_HANDLER(ChromeViewMsg_AppBannerPromptRequest, |
218 OnAppBannerPromptRequest) | 223 OnAppBannerPromptRequest) |
219 IPC_MESSAGE_UNHANDLED(handled = false) | 224 IPC_MESSAGE_UNHANDLED(handled = false) |
220 IPC_END_MESSAGE_MAP() | 225 IPC_END_MESSAGE_MAP() |
221 | 226 |
222 return handled; | 227 return handled; |
223 } | 228 } |
224 | 229 |
225 void ChromeRenderFrameObserver::OnSetIsPrerendering(bool is_prerendering) { | 230 void ChromeRenderFrameObserver::OnSetIsPrerendering(bool is_prerendering) { |
226 if (is_prerendering) { | 231 if (is_prerendering) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), | 281 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), |
277 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) | 282 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) |
278 thumbnail_data = std::string(data.begin(), data.end()); | 283 thumbnail_data = std::string(data.begin(), data.end()); |
279 } | 284 } |
280 | 285 |
281 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( | 286 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( |
282 routing_id(), thumbnail_data, original_size, callback_id)); | 287 routing_id(), thumbnail_data, original_size, callback_id)); |
283 } | 288 } |
284 | 289 |
285 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { | 290 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { |
| 291 #if defined(ENABLE_PRINTING) |
286 printing::PrintWebViewHelper* helper = | 292 printing::PrintWebViewHelper* helper = |
287 printing::PrintWebViewHelper::Get(render_frame()->GetRenderView()); | 293 printing::PrintWebViewHelper::Get(render_frame()->GetRenderView()); |
288 if (helper) | 294 if (helper) |
289 helper->PrintNode(render_frame()->GetContextMenuNode()); | 295 helper->PrintNode(render_frame()->GetContextMenuNode()); |
| 296 #endif |
290 } | 297 } |
291 | 298 |
292 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( | 299 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( |
293 bool enable_phishing_detection) { | 300 bool enable_phishing_detection) { |
294 #if defined(FULL_SAFE_BROWSING) && !defined(OS_CHROMEOS) | 301 #if defined(FULL_SAFE_BROWSING) && !defined(OS_CHROMEOS) |
295 phishing_classifier_ = | 302 phishing_classifier_ = |
296 enable_phishing_detection | 303 enable_phishing_detection |
297 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), | 304 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), |
298 nullptr) | 305 nullptr) |
299 : nullptr; | 306 : nullptr; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 425 |
419 TRACE_EVENT0("renderer", "ChromeRenderViewObserver::CapturePageInfo"); | 426 TRACE_EVENT0("renderer", "ChromeRenderViewObserver::CapturePageInfo"); |
420 | 427 |
421 #if defined(FULL_SAFE_BROWSING) | 428 #if defined(FULL_SAFE_BROWSING) |
422 // Will swap out the string. | 429 // Will swap out the string. |
423 if (phishing_classifier_) | 430 if (phishing_classifier_) |
424 phishing_classifier_->PageCaptured(content, | 431 phishing_classifier_->PageCaptured(content, |
425 capture_type == PRELIMINARY_CAPTURE); | 432 capture_type == PRELIMINARY_CAPTURE); |
426 #endif | 433 #endif |
427 } | 434 } |
OLD | NEW |