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 <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/command_line.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/prerender_messages.h" | 14 #include "chrome/common/prerender_messages.h" |
13 #include "chrome/common/render_messages.h" | 15 #include "chrome/common/render_messages.h" |
14 #include "chrome/renderer/prerender/prerender_helper.h" | 16 #include "chrome/renderer/prerender/prerender_helper.h" |
15 #include "components/printing/common/print_messages.h" | 17 #include "components/printing/common/print_messages.h" |
16 #include "components/printing/renderer/print_web_view_helper.h" | 18 #include "components/printing/renderer/print_web_view_helper.h" |
17 #include "content/public/renderer/render_frame.h" | 19 #include "content/public/renderer/render_frame.h" |
| 20 #include "content/public/renderer/render_view.h" |
| 21 #include "net/base/net_util.h" |
18 #include "skia/ext/image_operations.h" | 22 #include "skia/ext/image_operations.h" |
19 #include "third_party/WebKit/public/platform/WebImage.h" | 23 #include "third_party/WebKit/public/platform/WebImage.h" |
| 24 #include "third_party/WebKit/public/web/WebDataSource.h" |
20 #include "third_party/WebKit/public/web/WebElement.h" | 25 #include "third_party/WebKit/public/web/WebElement.h" |
| 26 #include "third_party/WebKit/public/web/WebFrame.h" |
| 27 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
21 #include "third_party/WebKit/public/web/WebNode.h" | 28 #include "third_party/WebKit/public/web/WebNode.h" |
22 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
23 #include "ui/gfx/codec/jpeg_codec.h" | 30 #include "ui/gfx/codec/jpeg_codec.h" |
24 | 31 |
| 32 using blink::WebDataSource; |
25 using blink::WebElement; | 33 using blink::WebElement; |
26 using blink::WebNode; | 34 using blink::WebNode; |
| 35 using content::SSLStatus; |
27 | 36 |
28 namespace { | 37 namespace { |
29 | 38 |
30 // If the source image is null or occupies less area than | 39 // If the source image is null or occupies less area than |
31 // |thumbnail_min_area_pixels|, we return the image unmodified. Otherwise, we | 40 // |thumbnail_min_area_pixels|, we return the image unmodified. Otherwise, we |
32 // scale down the image so that the width and height do not exceed | 41 // scale down the image so that the width and height do not exceed |
33 // |thumbnail_max_size_pixels|, preserving the original aspect ratio. | 42 // |thumbnail_max_size_pixels|, preserving the original aspect ratio. |
34 SkBitmap Downscale(const blink::WebImage& image, | 43 SkBitmap Downscale(const blink::WebImage& image, |
35 int thumbnail_min_area_pixels, | 44 int thumbnail_min_area_pixels, |
36 const gfx::Size& thumbnail_max_size_pixels) { | 45 const gfx::Size& thumbnail_max_size_pixels) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( | 153 Send(new ChromeViewHostMsg_RequestThumbnailForContextNode_ACK( |
145 routing_id(), thumbnail_data, original_size)); | 154 routing_id(), thumbnail_data, original_size)); |
146 } | 155 } |
147 | 156 |
148 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { | 157 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { |
149 printing::PrintWebViewHelper* helper = | 158 printing::PrintWebViewHelper* helper = |
150 printing::PrintWebViewHelper::Get(render_frame()->GetRenderView()); | 159 printing::PrintWebViewHelper::Get(render_frame()->GetRenderView()); |
151 if (helper) | 160 if (helper) |
152 helper->PrintNode(render_frame()->GetContextMenuNode()); | 161 helper->PrintNode(render_frame()->GetContextMenuNode()); |
153 } | 162 } |
| 163 |
| 164 void ChromeRenderFrameObserver::DidFinishDocumentLoad() { |
| 165 // If the navigation is to a localhost URL (and the flag is set to |
| 166 // allow localhost SSL misconfigurations), print a warning to the |
| 167 // console telling the developer to check their SSL configuration |
| 168 // before going to production. |
| 169 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 170 switches::kAllowInsecureLocalhost); |
| 171 WebDataSource* ds = render_frame()->GetWebFrame()->dataSource(); |
| 172 |
| 173 if (allow_localhost) { |
| 174 SSLStatus ssl_status = render_frame()->GetRenderView()->GetSSLStatusOfFrame( |
| 175 render_frame()->GetWebFrame()); |
| 176 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) && |
| 177 !net::IsCertStatusMinorError(ssl_status.cert_status); |
| 178 bool is_localhost = net::IsLocalhost(GURL(ds->request().url()).host()); |
| 179 |
| 180 if (is_cert_error && is_localhost) { |
| 181 render_frame()->GetWebFrame()->addMessageToConsole( |
| 182 blink::WebConsoleMessage( |
| 183 blink::WebConsoleMessage::LevelWarning, |
| 184 base::ASCIIToUTF16( |
| 185 "This site does not have a valid SSL " |
| 186 "certificate! Without SSL, your site's and " |
| 187 "visitors' data is vulnerable to theft and " |
| 188 "tampering. Get a valid SSL certificate before" |
| 189 " releasing your website to the public."))); |
| 190 } |
| 191 } |
| 192 } |
OLD | NEW |