| 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" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 const SkBitmap& icon) { | 114 const SkBitmap& icon) { |
| 115 DCHECK(add_shortcut_pending_); | 115 DCHECK(add_shortcut_pending_); |
| 116 if (!add_shortcut_pending_) | 116 if (!add_shortcut_pending_) |
| 117 return; | 117 return; |
| 118 add_shortcut_pending_ = false; | 118 add_shortcut_pending_ = false; |
| 119 | 119 |
| 120 RecordAddToHomescreen(); | 120 RecordAddToHomescreen(); |
| 121 | 121 |
| 122 const std::string& uid = base::GenerateGUID(); | 122 const std::string& uid = base::GenerateGUID(); |
| 123 content::BrowserThread::PostTask( | 123 content::BrowserThread::PostTask( |
| 124 content::BrowserThread::IO, | 124 content::BrowserThread::IO, FROM_HERE, |
| 125 FROM_HERE, | 125 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, info, |
| 126 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, | 126 uid, icon, |
| 127 info, | 127 data_fetcher_->FetchSplashScreenImageCallback(uid))); |
| 128 uid, | |
| 129 icon)); | |
| 130 | |
| 131 data_fetcher_->FetchSplashScreenImage(uid); | |
| 132 } | 128 } |
| 133 | 129 |
| 134 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper( | 130 bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper( |
| 135 JNIEnv* env) { | 131 JNIEnv* env) { |
| 136 return RegisterNativesImpl(env); | 132 return RegisterNativesImpl(env); |
| 137 } | 133 } |
| 138 | 134 |
| 139 void AddToHomescreenDialogHelper::RecordAddToHomescreen() { | 135 void AddToHomescreenDialogHelper::RecordAddToHomescreen() { |
| 140 // Record that the shortcut has been added, so no banners will be shown | 136 // Record that the shortcut has been added, so no banners will be shown |
| 141 // for this app. | 137 // for this app. |
| 142 content::WebContents* web_contents = data_fetcher_->web_contents(); | 138 content::WebContents* web_contents = data_fetcher_->web_contents(); |
| 143 if (!web_contents) | 139 if (!web_contents) |
| 144 return; | 140 return; |
| 145 | 141 |
| 146 AppBannerSettingsHelper::RecordBannerEvent( | 142 AppBannerSettingsHelper::RecordBannerEvent( |
| 147 web_contents, web_contents->GetURL(), | 143 web_contents, web_contents->GetURL(), |
| 148 data_fetcher_->shortcut_info().url.spec(), | 144 data_fetcher_->shortcut_info().url.spec(), |
| 149 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, | 145 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, |
| 150 base::Time::Now()); | 146 base::Time::Now()); |
| 151 } | 147 } |
| OLD | NEW |