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

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

Issue 2633603002: Disable app banners in incognito. (Closed)
Patch Set: Created 3 years, 11 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 55e03e54125f80d4a2d922e12309374743c0ca21..ffd07bf143f7d79171869e55a9c8ca8c807d0925 100644
--- a/chrome/browser/banners/app_banner_manager.cc
+++ b/chrome/browser/banners/app_banner_manager.cc
@@ -80,9 +80,10 @@ bool AppBannerManager::URLsAreForTheSamePage(const GURL& first,
void AppBannerManager::RequestAppBanner(const GURL& validated_url,
bool is_debug_mode) {
+ content::WebContents* contents = web_contents();
+
// Don't start a redundant banner request. Otherwise, if one is running,
// invalidate our weak pointers so it terminates.
- content::WebContents* contents = web_contents();
if (is_active_) {
if (URLsAreForTheSamePage(validated_url, contents->GetLastCommittedURL()))
return;
@@ -98,15 +99,18 @@ void AppBannerManager::RequestAppBanner(const GURL& validated_url,
DCHECK(!need_to_log_status_);
need_to_log_status_ = !IsDebugMode();
- if (contents->GetMainFrame()->GetParent()) {
- ReportStatus(contents, NOT_IN_MAIN_FRAME);
- Stop();
- return;
+ // Exit if this is an incognito window, non-main frame, or insecure context.
+ InstallableStatusCode code = NO_ERROR_DETECTED;
+ if (Profile::FromBrowserContext(contents->GetBrowserContext())
+ ->IsOffTheRecord()) {
+ code = IN_INCOGNITO;
+ } else if (contents->GetMainFrame()->GetParent()) {
+ code = NOT_IN_MAIN_FRAME;
+ } else if (!content::IsOriginSecure(validated_url)) {
+ code = NOT_FROM_SECURE_ORIGIN;
}
- // A secure origin is required to show banners, so exit early if we see the
- // URL is invalid.
- if (!content::IsOriginSecure(validated_url)) {
+ if (code != NO_ERROR_DETECTED) {
ReportStatus(contents, NOT_FROM_SECURE_ORIGIN);
Stop();
return;

Powered by Google App Engine
This is Rietveld 408576698