| 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 "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/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() { | 47 AddToHomescreenDialogHelper::~AddToHomescreenDialogHelper() { |
| 48 data_fetcher_->set_weak_observer(nullptr); | 48 data_fetcher_->set_weak_observer(nullptr); |
| 49 data_fetcher_ = nullptr; | 49 data_fetcher_ = nullptr; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void AddToHomescreenDialogHelper::OnUserTitleAvailable( | 52 void AddToHomescreenDialogHelper::OnUserTitleAvailable( |
| 53 const base::string16& user_title) { | 53 const base::string16& user_title) { |
| 54 JNIEnv* env = base::android::AttachCurrentThread(); | 54 JNIEnv* env = base::android::AttachCurrentThread(); |
| 55 ScopedJavaLocalRef<jstring> j_user_title = | 55 ScopedJavaLocalRef<jstring> j_user_title = |
| 56 base::android::ConvertUTF16ToJavaString(env, user_title); | 56 base::android::ConvertUTF16ToJavaString(env, user_title); |
| 57 Java_AddToHomescreenDialogHelper_onUserTitleAvailable(env, | 57 Java_AddToHomescreenDialogHelper_onUserTitleAvailable(env, java_ref_, |
| 58 java_ref_.obj(), | 58 j_user_title); |
| 59 j_user_title.obj()); | |
| 60 } | 59 } |
| 61 | 60 |
| 62 void AddToHomescreenDialogHelper::OnDataAvailable(const ShortcutInfo& info, | 61 void AddToHomescreenDialogHelper::OnDataAvailable(const ShortcutInfo& info, |
| 63 const SkBitmap& icon) { | 62 const SkBitmap& icon) { |
| 64 JNIEnv* env = base::android::AttachCurrentThread(); | 63 JNIEnv* env = base::android::AttachCurrentThread(); |
| 65 ScopedJavaLocalRef<jobject> java_bitmap; | 64 ScopedJavaLocalRef<jobject> java_bitmap; |
| 66 if (icon.getSize()) | 65 if (icon.getSize()) |
| 67 java_bitmap = gfx::ConvertToJavaBitmap(&icon); | 66 java_bitmap = gfx::ConvertToJavaBitmap(&icon); |
| 68 | 67 |
| 69 Java_AddToHomescreenDialogHelper_onIconAvailable(env, | 68 Java_AddToHomescreenDialogHelper_onIconAvailable(env, java_ref_, java_bitmap); |
| 70 java_ref_.obj(), | |
| 71 java_bitmap.obj()); | |
| 72 | 69 |
| 73 if (add_shortcut_pending_) | 70 if (add_shortcut_pending_) |
| 74 AddShortcut(info, icon); | 71 AddShortcut(info, icon); |
| 75 } | 72 } |
| 76 | 73 |
| 77 void AddToHomescreenDialogHelper::Destroy(JNIEnv* env, | 74 void AddToHomescreenDialogHelper::Destroy(JNIEnv* env, |
| 78 const JavaParamRef<jobject>& obj) { | 75 const JavaParamRef<jobject>& obj) { |
| 79 delete this; | 76 delete this; |
| 80 } | 77 } |
| 81 | 78 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 content::WebContents* web_contents = data_fetcher_->web_contents(); | 134 content::WebContents* web_contents = data_fetcher_->web_contents(); |
| 138 if (!web_contents) | 135 if (!web_contents) |
| 139 return; | 136 return; |
| 140 | 137 |
| 141 AppBannerSettingsHelper::RecordBannerEvent( | 138 AppBannerSettingsHelper::RecordBannerEvent( |
| 142 web_contents, web_contents->GetURL(), | 139 web_contents, web_contents->GetURL(), |
| 143 data_fetcher_->shortcut_info().url.spec(), | 140 data_fetcher_->shortcut_info().url.spec(), |
| 144 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, | 141 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
| 145 base::Time::Now()); | 142 base::Time::Now()); |
| 146 } | 143 } |
| OLD | NEW |