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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 | 233 |
230 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { | 234 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { |
231 #if BUILDFLAG(ENABLE_PRINTING) | 235 #if BUILDFLAG(ENABLE_PRINTING) |
232 printing::PrintWebViewHelper* helper = | 236 printing::PrintWebViewHelper* helper = |
233 printing::PrintWebViewHelper::Get(render_frame()); | 237 printing::PrintWebViewHelper::Get(render_frame()); |
234 if (helper) | 238 if (helper) |
235 helper->PrintNode(render_frame()->GetWebFrame()->ContextMenuNode()); | 239 helper->PrintNode(render_frame()->GetWebFrame()->ContextMenuNode()); |
236 #endif | 240 #endif |
237 } | 241 } |
238 | 242 |
243 void ChromeRenderFrameObserver::OnGetWebApplicationInfo() { | |
244 WebLocalFrame* frame = render_frame()->GetWebFrame(); | |
Łukasz Anforowicz
2017/06/15 04:05:39
The body of this method is mostly copied from the
| |
245 | |
246 WebApplicationInfo web_app_info; | |
247 web_apps::ParseWebAppFromWebDocument(frame, &web_app_info); | |
248 | |
249 // The warning below is specific to mobile but it doesn't hurt to show it even | |
250 // if the Chromium build is running on a desktop. It will get more exposition. | |
251 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { | |
252 blink::WebConsoleMessage message( | |
253 blink::WebConsoleMessage::kLevelWarning, | |
254 "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\"> is " | |
255 "deprecated. Please include <meta name=\"mobile-web-app-capable\" " | |
256 "content=\"yes\"> - " | |
257 "http://developers.google.com/chrome/mobile/docs/installtohomescreen"); | |
258 frame->AddMessageToConsole(message); | |
259 } | |
260 | |
261 // Prune out any data URLs in the set of icons. The browser process expects | |
262 // any icon with a data URL to have originated from a favicon. We don't want | |
263 // to decode arbitrary data URLs in the browser process. See | |
264 // http://b/issue?id=1162972 | |
265 for (std::vector<WebApplicationInfo::IconInfo>::iterator it = | |
266 web_app_info.icons.begin(); | |
267 it != web_app_info.icons.end();) { | |
268 if (it->url.SchemeIs(url::kDataScheme)) | |
269 it = web_app_info.icons.erase(it); | |
270 else | |
271 ++it; | |
272 } | |
273 | |
274 // Truncate the strings we send to the browser process. | |
275 web_app_info.title = | |
276 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); | |
277 web_app_info.description = | |
278 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength); | |
279 | |
280 Send(new ChromeFrameHostMsg_DidGetWebApplicationInfo(routing_id(), | |
281 web_app_info)); | |
282 } | |
283 | |
239 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( | 284 void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( |
240 bool enable_phishing_detection) { | 285 bool enable_phishing_detection) { |
241 #if defined(SAFE_BROWSING_CSD) | 286 #if defined(SAFE_BROWSING_CSD) |
242 phishing_classifier_ = | 287 phishing_classifier_ = |
243 enable_phishing_detection | 288 enable_phishing_detection |
244 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), | 289 ? safe_browsing::PhishingClassifierDelegate::Create(render_frame(), |
245 nullptr) | 290 nullptr) |
246 : nullptr; | 291 : nullptr; |
247 #endif | 292 #endif |
248 } | 293 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 const service_manager::BindSourceInfo& source_info, | 410 const service_manager::BindSourceInfo& source_info, |
366 chrome::mojom::ImageContextMenuRendererRequest request) { | 411 chrome::mojom::ImageContextMenuRendererRequest request) { |
367 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); | 412 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); |
368 } | 413 } |
369 | 414 |
370 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( | 415 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( |
371 const service_manager::BindSourceInfo& source_info, | 416 const service_manager::BindSourceInfo& source_info, |
372 chrome::mojom::ThumbnailCapturerRequest request) { | 417 chrome::mojom::ThumbnailCapturerRequest request) { |
373 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); | 418 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); |
374 } | 419 } |
OLD | NEW |