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

Side by Side Diff: chrome/browser/android/banners/app_banner_manager.cc

Issue 942633002: Switch AppBannerManager on use of Unretained to use it's weakptr factory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/banners/app_banner_manager.h" 5 #include "chrome/browser/android/banners/app_banner_manager.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const GURL& validated_url) { 131 const GURL& validated_url) {
132 if (render_frame_host->GetParent()) 132 if (render_frame_host->GetParent())
133 return; 133 return;
134 validated_url_ = validated_url; 134 validated_url_ = validated_url;
135 135
136 // A secure scheme is required to show banners, so exit early if we see the 136 // A secure scheme is required to show banners, so exit early if we see the
137 // URL is invalid. 137 // URL is invalid.
138 if (!validated_url_.SchemeIsSecure() && !gDisableSecureCheckForTesting) 138 if (!validated_url_.SchemeIsSecure() && !gDisableSecureCheckForTesting)
139 return; 139 return;
140 140
141 // See if the page has a manifest. Using Unretained(this) here is safe as the 141 // See if the page has a manifest.
142 // lifetime of this object extends beyond the lifetime of the web_contents(),
143 // and when web_contents() is destroyed it will call OnDidGetManifest.
144 web_contents()->GetManifest(base::Bind(&AppBannerManager::OnDidGetManifest, 142 web_contents()->GetManifest(base::Bind(&AppBannerManager::OnDidGetManifest,
145 base::Unretained(this))); 143 weak_factory_.GetWeakPtr()));
146 } 144 }
147 145
148 void AppBannerManager::OnDidGetManifest(const content::Manifest& manifest) { 146 void AppBannerManager::OnDidGetManifest(const content::Manifest& manifest) {
149 if (web_contents()->IsBeingDestroyed()) 147 if (web_contents()->IsBeingDestroyed())
150 return; 148 return;
151 149
152 if (manifest.IsEmpty() 150 if (manifest.IsEmpty()
153 || !manifest.start_url.is_valid() 151 || !manifest.start_url.is_valid()
154 || (manifest.name.is_null() && manifest.short_name.is_null())) { 152 || (manifest.name.is_null() && manifest.short_name.is_null())) {
155 // No usable manifest, see if there is a play store meta tag. 153 // No usable manifest, see if there is a play store meta tag.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) { 370 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) {
373 gDisableSecureCheckForTesting = true; 371 gDisableSecureCheckForTesting = true;
374 } 372 }
375 373
376 // Register native methods 374 // Register native methods
377 bool RegisterAppBannerManager(JNIEnv* env) { 375 bool RegisterAppBannerManager(JNIEnv* env) {
378 return RegisterNativesImpl(env); 376 return RegisterNativesImpl(env);
379 } 377 }
380 378
381 } // namespace banners 379 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698