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_constants.h" |
19 #include "chrome/common/chrome_isolated_world_ids.h" | 20 #include "chrome/common/chrome_isolated_world_ids.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/crash_keys.h" | 22 #include "chrome/common/crash_keys.h" |
22 #include "chrome/common/open_search_description_document_handler.mojom.h" | 23 #include "chrome/common/open_search_description_document_handler.mojom.h" |
23 #include "chrome/common/prerender_messages.h" | 24 #include "chrome/common/prerender_messages.h" |
24 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
25 #include "chrome/renderer/prerender/prerender_helper.h" | 26 #include "chrome/renderer/prerender/prerender_helper.h" |
26 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 27 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 28 #include "chrome/renderer/web_apps.h" |
27 #include "components/translate/content/renderer/translate_helper.h" | 29 #include "components/translate/content/renderer/translate_helper.h" |
28 #include "content/public/common/associated_interface_provider.h" | 30 #include "content/public/common/associated_interface_provider.h" |
29 #include "content/public/renderer/render_frame.h" | 31 #include "content/public/renderer/render_frame.h" |
30 #include "content/public/renderer/render_view.h" | 32 #include "content/public/renderer/render_view.h" |
31 #include "extensions/common/constants.h" | 33 #include "extensions/common/constants.h" |
32 #include "printing/features/features.h" | 34 #include "printing/features/features.h" |
33 #include "services/service_manager/public/cpp/binder_registry.h" | 35 #include "services/service_manager/public/cpp/binder_registry.h" |
34 #include "skia/ext/image_operations.h" | 36 #include "skia/ext/image_operations.h" |
35 #include "third_party/WebKit/public/platform/WebImage.h" | 37 #include "third_party/WebKit/public/platform/WebImage.h" |
36 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 38 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Filter only. | 144 // Filter only. |
143 bool handled = true; | 145 bool handled = true; |
144 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) | 146 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) |
145 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) | 147 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) |
146 IPC_MESSAGE_UNHANDLED(handled = false) | 148 IPC_MESSAGE_UNHANDLED(handled = false) |
147 IPC_END_MESSAGE_MAP() | 149 IPC_END_MESSAGE_MAP() |
148 if (handled) | 150 if (handled) |
149 return false; | 151 return false; |
150 | 152 |
151 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) | 153 IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) |
| 154 IPC_MESSAGE_HANDLER(ChromeFrameMsg_GetWebApplicationInfo, |
| 155 OnGetWebApplicationInfo) |
152 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, | 156 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, |
153 OnSetClientSidePhishingDetection) | 157 OnSetClientSidePhishingDetection) |
154 #if BUILDFLAG(ENABLE_PRINTING) | 158 #if BUILDFLAG(ENABLE_PRINTING) |
155 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, | 159 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, |
156 OnPrintNodeUnderContextMenu) | 160 OnPrintNodeUnderContextMenu) |
157 #endif | 161 #endif |
158 IPC_MESSAGE_UNHANDLED(handled = false) | 162 IPC_MESSAGE_UNHANDLED(handled = false) |
159 IPC_END_MESSAGE_MAP() | 163 IPC_END_MESSAGE_MAP() |
160 | 164 |
161 return handled; | 165 return handled; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 228 |
225 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { | 229 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { |
226 #if BUILDFLAG(ENABLE_PRINTING) | 230 #if BUILDFLAG(ENABLE_PRINTING) |
227 printing::PrintWebViewHelper* helper = | 231 printing::PrintWebViewHelper* helper = |
228 printing::PrintWebViewHelper::Get(render_frame()); | 232 printing::PrintWebViewHelper::Get(render_frame()); |
229 if (helper) | 233 if (helper) |
230 helper->PrintNode(render_frame()->GetWebFrame()->ContextMenuNode()); | 234 helper->PrintNode(render_frame()->GetWebFrame()->ContextMenuNode()); |
231 #endif | 235 #endif |
232 } | 236 } |
233 | 237 |
| 238 void ChromeRenderFrameObserver::OnGetWebApplicationInfo() { |
| 239 WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| 240 |
| 241 WebApplicationInfo web_app_info; |
| 242 web_apps::ParseWebAppFromWebDocument(frame, &web_app_info); |
| 243 |
| 244 // The warning below is specific to mobile but it doesn't hurt to show it even |
| 245 // if the Chromium build is running on a desktop. It will get more exposition. |
| 246 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { |
| 247 blink::WebConsoleMessage message( |
| 248 blink::WebConsoleMessage::kLevelWarning, |
| 249 "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\"> is " |
| 250 "deprecated. Please include <meta name=\"mobile-web-app-capable\" " |
| 251 "content=\"yes\"> - " |
| 252 "http://developers.google.com/chrome/mobile/docs/installtohomescreen"); |
| 253 frame->AddMessageToConsole(message); |
| 254 } |
| 255 |
| 256 // Prune out any data URLs in the set of icons. The browser process expects |
| 257 // any icon with a data URL to have originated from a favicon. We don't want |
| 258 // to decode arbitrary data URLs in the browser process. See |
| 259 // http://b/issue?id=1162972 |
| 260 for (std::vector<WebApplicationInfo::IconInfo>::iterator it = |
| 261 web_app_info.icons.begin(); |
| 262 it != web_app_info.icons.end();) { |
| 263 if (it->url.SchemeIs(url::kDataScheme)) |
| 264 it = web_app_info.icons.erase(it); |
| 265 else |
| 266 ++it; |
| 267 } |
| 268 |
| 269 // Truncate the strings we send to the browser process. |
| 270 web_app_info.title = |
| 271 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); |
| 272 web_app_info.description = |
| 273 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength); |
| 274 |
| 275 Send(new ChromeFrameHostMsg_DidGetWebApplicationInfo(routing_id(), |
| 276 web_app_info)); |
| 277 } |
| 278 |
234 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( | 279 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( |
235 bool enable_phishing_detection) { | 280 bool enable_phishing_detection) { |
236 #if defined(SAFE_BROWSING_CSD) | 281 #if defined(SAFE_BROWSING_CSD) |
237 phishing_classifier_ = | 282 phishing_classifier_ = |
238 enable_phishing_detection | 283 enable_phishing_detection |
239 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), | 284 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), |
240 nullptr) | 285 nullptr) |
241 : nullptr; | 286 : nullptr; |
242 #endif | 287 #endif |
243 } | 288 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 const service_manager::BindSourceInfo& source_info, | 405 const service_manager::BindSourceInfo& source_info, |
361 chrome::mojom::ImageContextMenuRendererRequest request) { | 406 chrome::mojom::ImageContextMenuRendererRequest request) { |
362 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); | 407 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); |
363 } | 408 } |
364 | 409 |
365 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( | 410 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( |
366 const service_manager::BindSourceInfo& source_info, | 411 const service_manager::BindSourceInfo& source_info, |
367 chrome::mojom::ThumbnailCapturerRequest request) { | 412 chrome::mojom::ThumbnailCapturerRequest request) { |
368 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); | 413 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); |
369 } | 414 } |
OLD | NEW |