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

Unified Diff: chrome/browser/android/banners/app_banner_manager_android.cc

Issue 1129103003: Log messages regarding why app banners aren't displayed to the console (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Factoring out debug log message function Created 5 years, 7 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/android/banners/app_banner_manager_android.cc
diff --git a/chrome/browser/android/banners/app_banner_manager_android.cc b/chrome/browser/android/banners/app_banner_manager_android.cc
index 829b0b019296829cc6feabd9b4eaf49d56749ae7..780752f310e6207c2591e6ef338f1a5f43211b02 100644
--- a/chrome/browser/android/banners/app_banner_manager_android.cc
+++ b/chrome/browser/android/banners/app_banner_manager_android.cc
@@ -51,7 +51,7 @@ void AppBannerManagerAndroid::ReplaceWebContents(JNIEnv* env,
bool AppBannerManagerAndroid::HandleNonWebApp(const std::string& platform,
const GURL& url,
const std::string& id) {
- if (platform != kPlayPlatform || id.empty())
+ if (!CheckPlatformAndId(platform, id))
return false;
banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED);
@@ -71,6 +71,35 @@ bool AppBannerManagerAndroid::HandleNonWebApp(const std::string& platform,
return true;
}
+bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform,
benwells 2015/05/11 08:08:39 Actually ... this probably shouldn't generate a 'n
dominickn (DO NOT USE) 2015/05/12 07:41:30 Done.
+ const std::string& id) {
+ if (platform != kPlayPlatform) {
+ banners::SendDebugMessage(web_contents(),
+ "not shown: application not from Play platform");
+ return false;
+ } else if (id.empty()) {
benwells 2015/05/11 08:08:39 Nit: no else after return (and ditto later).
+ banners::SendDebugMessage(web_contents(),
+ "not shown: application id is empty");
+ return false;
+ }
+ return true;
+}
+
+bool AppBannerManagerAndroid::CheckFetcherMatchesContents() {
+ if (!data_fetcher()) {
+ banners::SendDebugMessage(web_contents(),
+ "not shown: data fetcher is not active");
benwells 2015/05/11 08:08:39 This error should be the same as the 'the user nav
dominickn (DO NOT USE) 2015/05/12 07:41:30 Done.
+ return false;
+ } else if (!web_contents()) {
+ return false;
+ } else if (data_fetcher()->validated_url() != web_contents()->GetURL()) {
+ banners::SendDebugMessage(web_contents(),
+ "not shown: page URL does not match fetcher URL");
benwells 2015/05/11 08:08:39 Same, here, I think this only happens when the use
dominickn (DO NOT USE) 2015/05/12 07:41:30 Done.
+ return false;
+ }
+ return true;
+}
+
AppBannerDataFetcher* AppBannerManagerAndroid::CreateAppBannerDataFetcher(
base::WeakPtr<Delegate> weak_delegate,
const int ideal_icon_size) {
@@ -84,10 +113,8 @@ bool AppBannerManagerAndroid::OnAppDetailsRetrieved(JNIEnv* env,
jstring japp_title,
jstring japp_package,
jstring jicon_url) {
- if (!data_fetcher() || !web_contents()
- || data_fetcher()->validated_url() != web_contents()->GetURL()) {
+ if (!CheckFetcherMatchesContents())
return false;
- }
base::android::ScopedJavaLocalRef<jobject> native_app_data;
native_app_data.Reset(env, japp_data);

Powered by Google App Engine
This is Rietveld 408576698