| OLD | NEW |
| 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/metrics/field_trial.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" | 12 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" |
| 13 #include "chrome/browser/android/manifest_icon_selector.h" | 13 #include "chrome/browser/android/manifest_icon_selector.h" |
| 14 #include "chrome/browser/android/shortcut_helper.h" | 14 #include "chrome/browser/android/shortcut_helper.h" |
| 15 #include "chrome/browser/android/shortcut_info.h" | 15 #include "chrome/browser/android/shortcut_info.h" |
| 16 #include "chrome/browser/banners/app_banner_metrics.h" | 16 #include "chrome/browser/banners/app_banner_metrics.h" |
| 17 #include "chrome/browser/banners/app_banner_settings_helper.h" | 17 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 18 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 19 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_switches.h" | |
| 23 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
| 24 #include "content/public/browser/android/content_view_core.h" | 23 #include "content/public/browser/android/content_view_core.h" |
| 25 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
| 26 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/navigation_details.h" | 26 #include "content/public/browser/navigation_details.h" |
| 28 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| 29 #include "content/public/browser/service_worker_context.h" | 28 #include "content/public/browser/service_worker_context.h" |
| 30 #include "content/public/browser/storage_partition.h" | 29 #include "content/public/browser/storage_partition.h" |
| 31 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| 32 #include "content/public/common/frame_navigate_params.h" | 31 #include "content/public/common/frame_navigate_params.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 base::Time AppBannerManager::GetCurrentTime() { | 347 base::Time AppBannerManager::GetCurrentTime() { |
| 349 return base::Time::Now() + gTimeDeltaForTesting; | 348 return base::Time::Now() + gTimeDeltaForTesting; |
| 350 } | 349 } |
| 351 | 350 |
| 352 jlong Init(JNIEnv* env, jobject obj, jint icon_size) { | 351 jlong Init(JNIEnv* env, jobject obj, jint icon_size) { |
| 353 AppBannerManager* manager = new AppBannerManager(env, obj, icon_size); | 352 AppBannerManager* manager = new AppBannerManager(env, obj, icon_size); |
| 354 return reinterpret_cast<intptr_t>(manager); | 353 return reinterpret_cast<intptr_t>(manager); |
| 355 } | 354 } |
| 356 | 355 |
| 357 jboolean IsEnabled(JNIEnv* env, jclass clazz) { | 356 jboolean IsEnabled(JNIEnv* env, jclass clazz) { |
| 358 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 357 const std::string group_name = |
| 359 switches::kEnableAppInstallAlerts); | 358 base::FieldTrialList::FindFullName("AppBanners"); |
| 359 return group_name == "Enabled"; |
| 360 } | 360 } |
| 361 | 361 |
| 362 void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) { | 362 void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) { |
| 363 gTimeDeltaForTesting = base::TimeDelta::FromDays(days); | 363 gTimeDeltaForTesting = base::TimeDelta::FromDays(days); |
| 364 } | 364 } |
| 365 | 365 |
| 366 // Register native methods | 366 // Register native methods |
| 367 bool RegisterAppBannerManager(JNIEnv* env) { | 367 bool RegisterAppBannerManager(JNIEnv* env) { |
| 368 return RegisterNativesImpl(env); | 368 return RegisterNativesImpl(env); |
| 369 } | 369 } |
| 370 | 370 |
| 371 } // namespace banners | 371 } // namespace banners |
| OLD | NEW |