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

Unified Diff: chrome/browser/banners/app_banner_manager.cc

Issue 1148163003: Allow only responsive websites to install as a web app on mobile. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging with latest master Created 5 years, 6 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
Index: chrome/browser/banners/app_banner_manager.cc
diff --git a/chrome/browser/banners/app_banner_manager.cc b/chrome/browser/banners/app_banner_manager.cc
index dd3615d7c47fe25355a4d3a6ddfa439acaf7fdce..62484f40996facc01bb3340214c58db40ac6ec0b 100644
--- a/chrome/browser/banners/app_banner_manager.cc
+++ b/chrome/browser/banners/app_banner_manager.cc
@@ -49,21 +49,8 @@ AppBannerManager::~AppBannerManager() {
void AppBannerManager::DidFinishLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url) {
- if (render_frame_host->GetParent())
- return;
-
- if (data_fetcher_.get() && data_fetcher_->is_active() &&
- URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) {
+ if (!ValidateFrameHostAndOrigin(render_frame_host, validated_url))
benwells 2015/06/11 01:54:24 What is this change for?
dominickn (DO NOT USE) 2015/06/11 03:32:12 It was due to the former implementation of this fe
return;
- }
-
- // A secure origin is required to show banners, so exit early if we see the
- // URL is invalid.
- if (!content::IsOriginSecure(validated_url) &&
- !gDisableSecureCheckForTesting) {
- OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin);
- return;
- }
// Kick off the data retrieval pipeline.
data_fetcher_ = CreateAppBannerDataFetcher(weak_factory_.GetWeakPtr(),
@@ -77,6 +64,27 @@ bool AppBannerManager::HandleNonWebApp(const std::string& platform,
return false;
}
+bool AppBannerManager::ValidateFrameHostAndOrigin(
+ content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url) {
+ if (render_frame_host->GetParent())
+ return false;
+
+ if (data_fetcher_.get() && data_fetcher_->is_active() &&
+ URLsAreForTheSamePage(data_fetcher_->validated_url(), validated_url)) {
+ return false;
+ }
+
+ // A secure origin is required to show banners, so exit early if we see the
+ // URL is invalid.
+ if (!content::IsOriginSecure(validated_url) &&
+ !gDisableSecureCheckForTesting) {
+ OutputDeveloperNotShownMessage(web_contents(), kNotServedFromSecureOrigin);
+ return false;
+ }
+ return true;
+}
+
void AppBannerManager::ReplaceWebContents(content::WebContents* web_contents) {
Observe(web_contents);
if (data_fetcher_.get())

Powered by Google App Engine
This is Rietveld 408576698