| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/webapps/add_to_homescreen_dialog_helper.h" | 5 #include "chrome/browser/android/webapps/add_to_homescreen_dialog_helper.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/guid.h" | 12 #include "base/guid.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/android/shortcut_helper.h" | 16 #include "chrome/browser/android/shortcut_helper.h" |
| 17 #include "chrome/browser/banners/app_banner_settings_helper.h" | 17 #include "chrome/browser/banners/app_banner_settings_helper.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/common/manifest.h" | 20 #include "content/public/common/manifest.h" |
| 21 #include "jni/AddToHomescreenDialogHelper_jni.h" | 21 #include "jni/AddToHomescreenDialogHelper_jni.h" |
| 22 #include "ui/gfx/android/java_bitmap.h" | 22 #include "ui/gfx/android/java_bitmap.h" |
| 23 #include "ui/gfx/color_analysis.h" | 23 #include "ui/gfx/color_analysis.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 using content::Manifest; | 26 using content::Manifest; |
| 27 | 27 |
| 28 jlong Initialize(JNIEnv* env, | 28 jlong Initialize(JNIEnv* env, |
| 29 const JavaParamRef<jobject>& obj, | 29 const JavaParamRef<jobject>& obj, |
| 30 const JavaParamRef<jobject>& java_web_contents, | 30 const JavaParamRef<jobject>& java_web_contents) { |
| 31 jint ideal_splash_image_size_in_dp, | |
| 32 jint ideal_icon_size_in_dp) { | |
| 33 content::WebContents* web_contents = | 31 content::WebContents* web_contents = |
| 34 content::WebContents::FromJavaWebContents(java_web_contents); | 32 content::WebContents::FromJavaWebContents(java_web_contents); |
| 35 AddToHomescreenDialogHelper* add_to_homescreen_helper = | 33 AddToHomescreenDialogHelper* add_to_homescreen_helper = |
| 36 new AddToHomescreenDialogHelper(env, obj, web_contents, | 34 new AddToHomescreenDialogHelper(env, obj, web_contents); |
| 37 ideal_splash_image_size_in_dp, ideal_icon_size_in_dp); | |
| 38 return reinterpret_cast<intptr_t>(add_to_homescreen_helper); | 35 return reinterpret_cast<intptr_t>(add_to_homescreen_helper); |
| 39 } | 36 } |
| 40 | 37 |
| 41 AddToHomescreenDialogHelper::AddToHomescreenDialogHelper( | 38 AddToHomescreenDialogHelper::AddToHomescreenDialogHelper( |
| 42 JNIEnv* env, | 39 JNIEnv* env, |
| 43 jobject obj, | 40 jobject obj, |
| 44 content::WebContents* web_contents, | 41 content::WebContents* web_contents) |
| 45 int ideal_splash_image_size_in_dp, | |
| 46 int ideal_icon_size_in_dp) | |
| 47 : add_shortcut_pending_(false), | 42 : add_shortcut_pending_(false), |
| 48 data_fetcher_(new AddToHomescreenDataFetcher(web_contents, | 43 data_fetcher_(new AddToHomescreenDataFetcher(web_contents, |
| 49 ideal_splash_image_size_in_dp, | 44 ShortcutHelper::GetIdealIconSizeInDp(), |
| 50 ideal_icon_size_in_dp, | 45 ShortcutHelper::GetMinimumIconSizeInDp(), |
| 46 ShortcutHelper::GetIdealSplashImageSizeInDp(), |
| 47 ShortcutHelper::GetMinimumSplashImageSizeInDp(), |
| 51 this)) { | 48 this)) { |
| 52 java_ref_.Reset(env, obj); | 49 java_ref_.Reset(env, obj); |
| 53 } | 50 } |
| 54 | 51 |
| 55 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() { | 52 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() { |
| 56 data_fetcher_->set_weak_observer(nullptr); | 53 data_fetcher_->set_weak_observer(nullptr); |
| 57 data_fetcher_ = nullptr; | 54 data_fetcher_ = nullptr; |
| 58 } | 55 } |
| 59 | 56 |
| 60 void AddToHomescreenDialogHelper::OnUserTitleAvailable( | 57 void AddToHomescreenDialogHelper::OnUserTitleAvailable( |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 content::WebContents* web_contents = data_fetcher_->web_contents(); | 162 content::WebContents* web_contents = data_fetcher_->web_contents(); |
| 166 if (!web_contents) | 163 if (!web_contents) |
| 167 return; | 164 return; |
| 168 | 165 |
| 169 AppBannerSettingsHelper::RecordBannerEvent( | 166 AppBannerSettingsHelper::RecordBannerEvent( |
| 170 web_contents, web_contents->GetURL(), | 167 web_contents, web_contents->GetURL(), |
| 171 data_fetcher_->shortcut_info().url.spec(), | 168 data_fetcher_->shortcut_info().url.spec(), |
| 172 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, | 169 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
| 173 base::Time::Now()); | 170 base::Time::Now()); |
| 174 } | 171 } |
| OLD | NEW |