Index: chrome/renderer/chrome_render_frame_observer.cc |
diff --git a/chrome/renderer/chrome_render_frame_observer.cc b/chrome/renderer/chrome_render_frame_observer.cc |
index 08ca11e128025445d355c026ae12b3265e4af132..7b13a729d2054f82d74661c2571f1bcb84d10db1 100644 |
--- a/chrome/renderer/chrome_render_frame_observer.cc |
+++ b/chrome/renderer/chrome_render_frame_observer.cc |
@@ -16,6 +16,7 @@ |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/utf_string_conversions.h" |
#include "build/build_config.h" |
+#include "chrome/common/chrome_constants.h" |
#include "chrome/common/chrome_isolated_world_ids.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/crash_keys.h" |
@@ -24,6 +25,7 @@ |
#include "chrome/common/render_messages.h" |
#include "chrome/renderer/prerender/prerender_helper.h" |
#include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
+#include "chrome/renderer/web_apps.h" |
#include "components/translate/content/renderer/translate_helper.h" |
#include "content/public/common/associated_interface_provider.h" |
#include "content/public/renderer/render_frame.h" |
@@ -149,6 +151,8 @@ bool ChromeRenderFrameObserver::OnMessageReceived(const IPC::Message& message) { |
return false; |
IPC_BEGIN_MESSAGE_MAP(ChromeRenderFrameObserver, message) |
+ IPC_MESSAGE_HANDLER(ChromeFrameMsg_GetWebApplicationInfo, |
+ OnGetWebApplicationInfo) |
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, |
OnSetClientSidePhishingDetection) |
#if BUILDFLAG(ENABLE_PRINTING) |
@@ -231,6 +235,47 @@ void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { |
#endif |
} |
+void ChromeRenderFrameObserver::OnGetWebApplicationInfo() { |
+ WebLocalFrame* frame = render_frame()->GetWebFrame(); |
+ |
+ WebApplicationInfo web_app_info; |
+ web_apps::ParseWebAppFromWebDocument(frame, &web_app_info); |
+ |
+ // The warning below is specific to mobile but it doesn't hurt to show it even |
+ // if the Chromium build is running on a desktop. It will get more exposition. |
+ if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { |
+ blink::WebConsoleMessage message( |
+ blink::WebConsoleMessage::kLevelWarning, |
+ "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\"> is " |
+ "deprecated. Please include <meta name=\"mobile-web-app-capable\" " |
+ "content=\"yes\"> - " |
+ "http://developers.google.com/chrome/mobile/docs/installtohomescreen"); |
+ frame->AddMessageToConsole(message); |
+ } |
+ |
+ // Prune out any data URLs in the set of icons. The browser process expects |
+ // any icon with a data URL to have originated from a favicon. We don't want |
+ // to decode arbitrary data URLs in the browser process. See |
+ // http://b/issue?id=1162972 |
+ for (std::vector<WebApplicationInfo::IconInfo>::iterator it = |
+ web_app_info.icons.begin(); |
+ it != web_app_info.icons.end();) { |
+ if (it->url.SchemeIs(url::kDataScheme)) |
+ it = web_app_info.icons.erase(it); |
+ else |
+ ++it; |
+ } |
+ |
+ // Truncate the strings we send to the browser process. |
+ web_app_info.title = |
+ web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); |
+ web_app_info.description = |
+ web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength); |
+ |
+ Send(new ChromeFrameHostMsg_DidGetWebApplicationInfo(routing_id(), |
+ web_app_info)); |
+} |
+ |
void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection( |
bool enable_phishing_detection) { |
#if defined(SAFE_BROWSING_CSD) |