| 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> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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/common/ssl_status.h" | 27 #include "content/public/common/ssl_status.h" |
| 28 #include "content/public/renderer/render_frame.h" | 28 #include "content/public/renderer/render_frame.h" |
| 29 #include "content/public/renderer/render_view.h" | 29 #include "content/public/renderer/render_view.h" |
| 30 #include "extensions/common/constants.h" | 30 #include "extensions/common/constants.h" |
| 31 #include "net/base/url_util.h" | |
| 32 #include "net/ssl/ssl_cipher_suite_names.h" | |
| 33 #include "net/ssl/ssl_connection_status_flags.h" | |
| 34 #include "skia/ext/image_operations.h" | 31 #include "skia/ext/image_operations.h" |
| 35 #include "third_party/WebKit/public/platform/WebImage.h" | 32 #include "third_party/WebKit/public/platform/WebImage.h" |
| 36 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 33 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 37 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" | 34 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" |
| 38 #include "third_party/WebKit/public/web/WebDataSource.h" | 35 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 39 #include "third_party/WebKit/public/web/WebDocument.h" | 36 #include "third_party/WebKit/public/web/WebDocument.h" |
| 40 #include "third_party/WebKit/public/web/WebElement.h" | 37 #include "third_party/WebKit/public/web/WebElement.h" |
| 41 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" | 38 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
| 42 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 39 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 43 #include "third_party/WebKit/public/web/WebNode.h" | 40 #include "third_party/WebKit/public/web/WebNode.h" |
| 44 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 41 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 45 #include "third_party/skia/include/core/SkBitmap.h" | 42 #include "third_party/skia/include/core/SkBitmap.h" |
| 46 #include "ui/gfx/codec/jpeg_codec.h" | 43 #include "ui/gfx/codec/jpeg_codec.h" |
| 47 #include "ui/gfx/geometry/size_f.h" | 44 #include "ui/gfx/geometry/size_f.h" |
| 48 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 49 | 46 |
| 50 #if defined(ENABLE_PRINTING) | 47 #if defined(ENABLE_PRINTING) |
| 51 #include "components/printing/common/print_messages.h" | 48 #include "components/printing/common/print_messages.h" |
| 52 #include "components/printing/renderer/print_web_view_helper.h" | 49 #include "components/printing/renderer/print_web_view_helper.h" |
| 53 #endif | 50 #endif |
| 54 | 51 |
| 55 using blink::WebDataSource; | 52 using blink::WebDataSource; |
| 56 using blink::WebElement; | 53 using blink::WebElement; |
| 57 using blink::WebFrameContentDumper; | 54 using blink::WebFrameContentDumper; |
| 58 using blink::WebLocalFrame; | 55 using blink::WebLocalFrame; |
| 59 using blink::WebNode; | 56 using blink::WebNode; |
| 60 using blink::WebString; | 57 using blink::WebString; |
| 61 using content::SSLStatus; | |
| 62 using content::RenderFrame; | 58 using content::RenderFrame; |
| 63 | 59 |
| 64 // Maximum number of characters in the document to index. | 60 // Maximum number of characters in the document to index. |
| 65 // Any text beyond this point will be clipped. | 61 // Any text beyond this point will be clipped. |
| 66 static const size_t kMaxIndexChars = 65535; | 62 static const size_t kMaxIndexChars = 65535; |
| 67 | 63 |
| 68 // Constants for UMA statistic collection. | 64 // Constants for UMA statistic collection. |
| 69 static const char kTranslateCaptureText[] = "Translate.CaptureText"; | 65 static const char kTranslateCaptureText[] = "Translate.CaptureText"; |
| 70 | 66 |
| 71 // For a page that auto-refreshes, we still show the bubble, if | 67 // For a page that auto-refreshes, we still show the bubble, if |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 bool enable_phishing_detection) { | 233 bool enable_phishing_detection) { |
| 238 #if defined(SAFE_BROWSING_CSD) | 234 #if defined(SAFE_BROWSING_CSD) |
| 239 phishing_classifier_ = | 235 phishing_classifier_ = |
| 240 enable_phishing_detection | 236 enable_phishing_detection |
| 241 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), | 237 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), |
| 242 nullptr) | 238 nullptr) |
| 243 : nullptr; | 239 : nullptr; |
| 244 #endif | 240 #endif |
| 245 } | 241 } |
| 246 | 242 |
| 247 void ChromeRenderFrameObserver::DidFinishDocumentLoad() { | |
| 248 // If the navigation is to a localhost URL (and the flag is set to | |
| 249 // allow localhost SSL misconfigurations), print a warning to the | |
| 250 // console telling the developer to check their SSL configuration | |
| 251 // before going to production. | |
| 252 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 253 switches::kAllowInsecureLocalhost); | |
| 254 WebDataSource* ds = render_frame()->GetWebFrame()->dataSource(); | |
| 255 | |
| 256 SSLStatus ssl_status = render_frame()->GetRenderView()->GetSSLStatusOfFrame( | |
| 257 render_frame()->GetWebFrame()); | |
| 258 | |
| 259 if (allow_localhost) { | |
| 260 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) && | |
| 261 !net::IsCertStatusMinorError(ssl_status.cert_status); | |
| 262 bool is_localhost = net::IsLocalhost(GURL(ds->request().url()).host()); | |
| 263 | |
| 264 if (is_cert_error && is_localhost) { | |
| 265 render_frame()->GetWebFrame()->addMessageToConsole( | |
| 266 blink::WebConsoleMessage( | |
| 267 blink::WebConsoleMessage::LevelWarning, | |
| 268 base::ASCIIToUTF16( | |
| 269 "This site does not have a valid SSL " | |
| 270 "certificate! Without SSL, your site's and " | |
| 271 "visitors' data is vulnerable to theft and " | |
| 272 "tampering. Get a valid SSL certificate before" | |
| 273 " releasing your website to the public."))); | |
| 274 } | |
| 275 } | |
| 276 | |
| 277 // DHE is deprecated and will be removed in M52. See https://crbug.com/598109. | |
| 278 // TODO(davidben): Remove this logic when DHE is removed. | |
| 279 uint16_t cipher_suite = | |
| 280 net::SSLConnectionStatusToCipherSuite(ssl_status.connection_status); | |
| 281 const char* key_exchange; | |
| 282 const char* unused; | |
| 283 bool is_aead_unused; | |
| 284 net::SSLCipherSuiteToStrings(&key_exchange, &unused, &unused, &is_aead_unused, | |
| 285 cipher_suite); | |
| 286 if (strcmp(key_exchange, "DHE_RSA") == 0) { | |
| 287 render_frame()->GetWebFrame()->addMessageToConsole(blink::WebConsoleMessage( | |
| 288 blink::WebConsoleMessage::LevelWarning, | |
| 289 base::ASCIIToUTF16("This site requires a DHE-based SSL cipher suite. " | |
| 290 "These are deprecated and will be removed in M52, " | |
| 291 "around July 2016. See " | |
| 292 "https://www.chromestatus.com/feature/" | |
| 293 "5752033759985664 for more details."))); | |
| 294 } | |
| 295 } | |
| 296 | |
| 297 void ChromeRenderFrameObserver::OnAppBannerPromptRequest( | 243 void ChromeRenderFrameObserver::OnAppBannerPromptRequest( |
| 298 int request_id, | 244 int request_id, |
| 299 const std::string& platform) { | 245 const std::string& platform) { |
| 300 // App banner prompt requests are handled in the general chrome render frame | 246 // App banner prompt requests are handled in the general chrome render frame |
| 301 // observer, not the AppBannerClient, as the AppBannerClient is created lazily | 247 // observer, not the AppBannerClient, as the AppBannerClient is created lazily |
| 302 // by blink and may not exist when the request is sent. | 248 // by blink and may not exist when the request is sent. |
| 303 blink::WebAppBannerPromptReply reply = blink::WebAppBannerPromptReply::None; | 249 blink::WebAppBannerPromptReply reply = blink::WebAppBannerPromptReply::None; |
| 304 blink::WebString web_platform(base::UTF8ToUTF16(platform)); | 250 blink::WebString web_platform(base::UTF8ToUTF16(platform)); |
| 305 blink::WebVector<blink::WebString> web_platforms(&web_platform, 1); | 251 blink::WebVector<blink::WebString> web_platforms(&web_platform, 1); |
| 306 | 252 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 CapturePageText(FINAL_CAPTURE); | 364 CapturePageText(FINAL_CAPTURE); |
| 419 break; | 365 break; |
| 420 default: | 366 default: |
| 421 break; | 367 break; |
| 422 } | 368 } |
| 423 } | 369 } |
| 424 | 370 |
| 425 void ChromeRenderFrameObserver::OnDestruct() { | 371 void ChromeRenderFrameObserver::OnDestruct() { |
| 426 delete this; | 372 delete this; |
| 427 } | 373 } |
| OLD | NEW |