Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3045)

Unified Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 568823003: Merge Android RetrieveWebappInformation and Extensions GetApplicationInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_manager_content
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.h ('k') | chrome/renderer/extensions/chrome_extension_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/chrome_render_view_observer.cc
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index fb0ecc5d36d09d6587cf76d45dadc53733591475..8c1926eee09eb5c661a5a26937be603b6ebb761e 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -20,6 +20,7 @@
#include "chrome/renderer/prerender/prerender_helper.h"
#include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
#include "chrome/renderer/translate/translate_helper.h"
+#include "chrome/renderer/web_apps.h"
#include "chrome/renderer/webview_color_overlay.h"
#include "components/web_cache/renderer/web_cache_render_process_observer.h"
#include "content/public/common/bindings_policy.h"
@@ -181,11 +182,11 @@ bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
#if defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(ChromeViewMsg_UpdateTopControlsState,
OnUpdateTopControlsState)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_RetrieveWebappInformation,
- OnRetrieveWebappInformation)
IPC_MESSAGE_HANDLER(ChromeViewMsg_RetrieveMetaTagContent,
OnRetrieveMetaTagContent)
#endif
+ IPC_MESSAGE_HANDLER(ChromeViewMsg_GetWebApplicationInfo,
+ OnGetWebApplicationInfo)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection,
OnSetClientSidePhishingDetection)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetWindowFeatures, OnSetWindowFeatures)
@@ -210,52 +211,6 @@ void ChromeRenderViewObserver::OnUpdateTopControlsState(
render_view()->UpdateTopControlsState(constraints, current, animate);
}
-void ChromeRenderViewObserver::OnRetrieveWebappInformation(
- const GURL& expected_url) {
- WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
- bool found_tag;
- std::string content_str;
-
- // Search for the "mobile-web-app-capable" tag.
- bool mobile_parse_success = RetrieveMetaTagContent(
- main_frame,
- expected_url,
- "mobile-web-app-capable",
- &found_tag,
- &content_str);
- bool is_mobile_webapp_capable = mobile_parse_success && found_tag &&
- LowerCaseEqualsASCII(content_str, "yes");
-
- // Search for the "apple-mobile-web-app-capable" tag.
- bool apple_parse_success = RetrieveMetaTagContent(
- main_frame,
- expected_url,
- "apple-mobile-web-app-capable",
- &found_tag,
- &content_str);
- bool is_apple_mobile_webapp_capable = apple_parse_success && found_tag &&
- LowerCaseEqualsASCII(content_str, "yes");
-
- bool is_only_apple_mobile_webapp_capable =
- is_apple_mobile_webapp_capable && !is_mobile_webapp_capable;
- if (main_frame && is_only_apple_mobile_webapp_capable) {
- blink::WebConsoleMessage message(
- blink::WebConsoleMessage::LevelWarning,
- "<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");
- main_frame->addMessageToConsole(message);
- }
-
- Send(new ChromeViewHostMsg_DidRetrieveWebappInformation(
- routing_id(),
- mobile_parse_success && apple_parse_success,
- is_mobile_webapp_capable,
- is_apple_mobile_webapp_capable,
- expected_url));
-}
-
void ChromeRenderViewObserver::OnRetrieveMetaTagContent(
const GURL& expected_url,
const std::string tag_name) {
@@ -277,6 +232,48 @@ void ChromeRenderViewObserver::OnRetrieveMetaTagContent(
}
#endif
+void ChromeRenderViewObserver::OnGetWebApplicationInfo() {
+ WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
+ DCHECK(main_frame);
+
+ WebApplicationInfo web_app_info;
+ web_apps::ParseWebAppFromWebDocument(main_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::LevelWarning,
+ "<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");
+ main_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 ChromeViewHostMsg_DidGetWebApplicationInfo(
+ routing_id(), web_app_info));
+}
+
void ChromeRenderViewObserver::OnSetWindowFeatures(
const WebWindowFeatures& window_features) {
render_view()->GetWebView()->setWindowFeatures(window_features);
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.h ('k') | chrome/renderer/extensions/chrome_extension_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698