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

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

Issue 2633603002: Disable app banners in incognito. (Closed)
Patch Set: Comment + rebase 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 dfd57ead5aa17f194687105458e59e738ddf2eb2..5344e0da7c102e943527fdc861327d25458944c6 100644
--- a/chrome/browser/banners/app_banner_manager.cc
+++ b/chrome/browser/banners/app_banner_manager.cc
@@ -79,9 +79,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;
@@ -97,16 +98,19 @@ 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 (!InstallableManager::IsContentSecure(contents)) {
+ code = NOT_FROM_SECURE_ORIGIN;
}
- // A secure origin is required to show banners, so exit early if we see the
- // URL is invalid.
- if (!InstallableManager::IsContentSecure(contents)) {
- ReportStatus(contents, NOT_FROM_SECURE_ORIGIN);
+ if (code != NO_ERROR_DETECTED) {
+ ReportStatus(contents, code);
Stop();
return;
}

Powered by Google App Engine
This is Rietveld 408576698