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

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

Issue 941823002: [App banners] Add server-controlled experiment to disable app banners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add flag BACK to about:flags, use it to disable half of the feature 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 | « chrome/browser/android/banners/app_banner_manager.h ('k') | 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"
11 #include "base/metrics/field_trial.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" 13 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h"
13 #include "chrome/browser/android/manifest_icon_selector.h" 14 #include "chrome/browser/android/manifest_icon_selector.h"
14 #include "chrome/browser/android/shortcut_helper.h" 15 #include "chrome/browser/android/shortcut_helper.h"
15 #include "chrome/browser/android/shortcut_info.h" 16 #include "chrome/browser/android/shortcut_info.h"
16 #include "chrome/browser/banners/app_banner_metrics.h" 17 #include "chrome/browser/banners/app_banner_metrics.h"
17 #include "chrome/browser/banners/app_banner_settings_helper.h" 18 #include "chrome/browser/banners/app_banner_settings_helper.h"
18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 19 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
19 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
20 #include "chrome/browser/metrics/rappor/sampling.h" 21 #include "chrome/browser/metrics/rappor/sampling.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 146 }
146 147
147 void AppBannerManager::OnDidGetManifest(const content::Manifest& manifest) { 148 void AppBannerManager::OnDidGetManifest(const content::Manifest& manifest) {
148 if (web_contents()->IsBeingDestroyed()) 149 if (web_contents()->IsBeingDestroyed())
149 return; 150 return;
150 151
151 if (manifest.IsEmpty() 152 if (manifest.IsEmpty()
152 || !manifest.start_url.is_valid() 153 || !manifest.start_url.is_valid()
153 || (manifest.name.is_null() && manifest.short_name.is_null())) { 154 || (manifest.name.is_null() && manifest.short_name.is_null())) {
154 // No usable manifest, see if there is a play store meta tag. 155 // No usable manifest, see if there is a play store meta tag.
156 if (!IsEnabledForNativeApps())
157 return;
158
155 Send(new ChromeViewMsg_RetrieveMetaTagContent(routing_id(), 159 Send(new ChromeViewMsg_RetrieveMetaTagContent(routing_id(),
156 validated_url_, 160 validated_url_,
157 kBannerTag)); 161 kBannerTag));
158 return; 162 return;
159 } 163 }
160 164
161 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED); 165 banners::TrackDisplayEvent(DISPLAY_EVENT_BANNER_REQUESTED);
162 166
163 web_app_data_ = manifest; 167 web_app_data_ = manifest;
164 app_title_ = web_app_data_.name.string(); 168 app_title_ = web_app_data_.name.string();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 fetcher_->Start( 358 fetcher_->Start(
355 profile->GetRequestContext(), 359 profile->GetRequestContext(),
356 std::string(), 360 std::string(),
357 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, 361 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
358 net::LOAD_NORMAL); 362 net::LOAD_NORMAL);
359 app_icon_url_ = image_url; 363 app_icon_url_ = image_url;
360 return true; 364 return true;
361 } 365 }
362 366
363 // static 367 // static
368 bool AppBannerManager::IsEnabledForNativeApps() {
369 return base::CommandLine::ForCurrentProcess()->HasSwitch(
370 switches::kEnableAppInstallAlerts);
371 }
372
373 // static
364 base::Time AppBannerManager::GetCurrentTime() { 374 base::Time AppBannerManager::GetCurrentTime() {
365 return base::Time::Now() + gTimeDeltaForTesting; 375 return base::Time::Now() + gTimeDeltaForTesting;
366 } 376 }
367 377
368 jlong Init(JNIEnv* env, jobject obj, jint icon_size) { 378 jlong Init(JNIEnv* env, jobject obj, jint icon_size) {
369 AppBannerManager* manager = new AppBannerManager(env, obj, icon_size); 379 AppBannerManager* manager = new AppBannerManager(env, obj, icon_size);
370 return reinterpret_cast<intptr_t>(manager); 380 return reinterpret_cast<intptr_t>(manager);
371 } 381 }
372 382
373 jboolean IsEnabled(JNIEnv* env, jclass clazz) { 383 jboolean IsEnabled(JNIEnv* env, jclass clazz) {
374 return base::CommandLine::ForCurrentProcess()->HasSwitch( 384 const std::string group_name =
375 switches::kEnableAppInstallAlerts); 385 base::FieldTrialList::FindFullName("AppBanners");
386 return group_name == "Enabled";
376 } 387 }
377 388
378 void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) { 389 void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) {
379 gTimeDeltaForTesting = base::TimeDelta::FromDays(days); 390 gTimeDeltaForTesting = base::TimeDelta::FromDays(days);
380 } 391 }
381 392
382 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) { 393 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) {
383 gDisableSecureCheckForTesting = true; 394 gDisableSecureCheckForTesting = true;
384 } 395 }
385 396
386 // Register native methods 397 // Register native methods
387 bool RegisterAppBannerManager(JNIEnv* env) { 398 bool RegisterAppBannerManager(JNIEnv* env) {
388 return RegisterNativesImpl(env); 399 return RegisterNativesImpl(env);
389 } 400 }
390 401
391 } // namespace banners 402 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698